public abstract class DatabaseFileSystem extends Object implements FileSystem
See the DbFileSystem for a detailed description of the available
configuration options and database behaviour.
| Modifier and Type | Field and Description |
|---|---|
protected ConnectionHelper |
conHelper
the
ConnectionHelper set in the init() method |
protected String |
copyFileSQL |
protected String |
copyFilesSQL |
protected String |
deleteFileSQL |
protected String |
deleteFolderSQL |
protected static int |
INITIAL_BUFFER_SIZE |
protected boolean |
initialized |
protected String |
insertFileSQL |
protected String |
insertFolderSQL |
protected String |
schema |
protected String |
schemaObjectPrefix |
protected String |
selectChildCountSQL |
protected String |
selectDataSQL |
protected String |
selectExistSQL |
protected String |
selectFileAndFolderNamesSQL |
protected String |
selectFileExistSQL |
protected String |
selectFileNamesSQL |
protected String |
selectFolderExistSQL |
protected String |
selectFolderNamesSQL |
protected String |
selectLastModifiedSQL |
protected String |
selectLengthSQL |
protected String |
updateDataSQL |
protected String |
updateLastModifiedSQL |
SEPARATOR, SEPARATOR_CHAR| Constructor and Description |
|---|
DatabaseFileSystem()
Default constructor
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
buildSQLStatements()
Builds the SQL statements
|
void |
close()
Close the file system.
|
protected CheckSchemaOperation |
createCheckSchemaOperation()
This method is called from
init() after the
createConnectionHelper(DataSource) method, and returns a default CheckSchemaOperation. |
protected ConnectionHelper |
createConnectionHelper(DataSource dataSrc)
This method is called from the
init() method of this class and returns a
ConnectionHelper instance which is assigned to the conHelper field. |
protected void |
createDeepFolder(String folderPath)
Creates the specified files system folder entry, recursively creating
any non-existing intermediate folder entries.
|
void |
createFolder(String folderPath)
Creates the folder named by this path, including any necessary but
nonexistent parent folders.
|
void |
deleteFile(String filePath)
Deletes the file denoted by this path.
|
void |
deleteFolder(String folderPath)
Deletes the folder denoted by this path.
|
boolean |
equals(Object obj) |
boolean |
exists(String path)
Tests whether the file system entry denoted by this path exists.
|
protected abstract DataSource |
getDataSource() |
InputStream |
getInputStream(String filePath)
Returns an input stream of the contents of the file denoted by this path.
|
OutputStream |
getOutputStream(String filePath)
Returns an output stream for writing bytes to the file denoted by this path.
|
String |
getSchema() |
String |
getSchemaObjectPrefix() |
boolean |
hasChildren(String path)
Tests whether the file system entry denoted by this path has child entries.
|
int |
hashCode()
Returns zero to satisfy the Object equals/hashCode contract.
|
void |
init()
Initialize the file system
|
boolean |
isFile(String path)
Tests whether the file system entry denoted by this path exists and
is a file.
|
boolean |
isFolder(String path)
Tests whether the file system entry denoted by this path exists and
is a folder.
|
boolean |
isSchemaCheckEnabled() |
long |
lastModified(String path)
Returns the time that the file system entry denoted by this path
was last modified.
|
long |
length(String filePath)
Returns the length of the file denoted by this path.
|
String[] |
list(String folderPath)
Returns an array of strings naming the files and folders
in the folder denoted by this path.
|
String[] |
listFiles(String folderPath)
Returns an array of strings naming the files in the folder
denoted by this path.
|
String[] |
listFolders(String folderPath)
Returns an array of strings naming the folders in the folder
denoted by this path.
|
void |
setSchema(String schema) |
void |
setSchemaCheckEnabled(boolean enabled) |
void |
setSchemaObjectPrefix(String schemaObjectPrefix) |
protected void |
verifyRootExists()
Verifies that the root file system entry exists.
|
protected boolean initialized
protected String schema
protected String schemaObjectPrefix
protected static final int INITIAL_BUFFER_SIZE
protected ConnectionHelper conHelper
ConnectionHelper set in the init() methodprotected String selectExistSQL
protected String selectFileExistSQL
protected String selectFolderExistSQL
protected String selectChildCountSQL
protected String selectDataSQL
protected String selectLastModifiedSQL
protected String selectLengthSQL
protected String selectFileNamesSQL
protected String selectFolderNamesSQL
protected String selectFileAndFolderNamesSQL
protected String deleteFileSQL
protected String deleteFolderSQL
protected String insertFileSQL
protected String insertFolderSQL
protected String updateDataSQL
protected String updateLastModifiedSQL
protected String copyFileSQL
protected String copyFilesSQL
public String getSchemaObjectPrefix()
public void setSchemaObjectPrefix(String schemaObjectPrefix)
public String getSchema()
public void setSchema(String schema)
public final boolean isSchemaCheckEnabled()
public final void setSchemaCheckEnabled(boolean enabled)
enabled - set whether the schema check is enabledpublic int hashCode()
hashCode in class ObjectObject.hashCode()public void init()
throws FileSystemException
init in interface FileSystemFileSystemException - if the file system initialization failsprotected abstract DataSource getDataSource() throws Exception
Exceptionprotected ConnectionHelper createConnectionHelper(DataSource dataSrc) throws Exception
init() method of this class and returns a
ConnectionHelper instance which is assigned to the conHelper field. Subclasses may
override it to return a specialized connection helper.dataSrc - the DataSource of this persistence managerConnectionHelperException - on errorprotected CheckSchemaOperation createCheckSchemaOperation()
init() after the
createConnectionHelper(DataSource) method, and returns a default CheckSchemaOperation.
Subclasses can overrride this implementation to get a customized implementation.CheckSchemaOperation instancepublic void close()
throws FileSystemException
close in interface FileSystemFileSystemExceptionpublic void createFolder(String folderPath) throws FileSystemException
createFolder in interface FileSystemfolderPath - the path of the folder to be created.FileSystemException - if a file system entry denoted by path
already exists or if another error occurs.public void deleteFile(String filePath) throws FileSystemException
deleteFile in interface FileSystemfilePath - the path of the file to be deleted.FileSystemException - if this path does not denote a file or if
another error occurs.public void deleteFolder(String folderPath) throws FileSystemException
deleteFolder in interface FileSystemfolderPath - the path of the folder to be deleted.FileSystemException - if this path does not denote a folder or if
another error occurs.public boolean exists(String path) throws FileSystemException
exists in interface FileSystempath - the path of a file system entry.FileSystemExceptionpublic boolean isFile(String path) throws FileSystemException
isFile in interface FileSystempath - the path of a file system entry.FileSystemExceptionpublic boolean isFolder(String path) throws FileSystemException
isFolder in interface FileSystempath - the path of a file system entry.FileSystemExceptionpublic long lastModified(String path) throws FileSystemException
lastModified in interface FileSystempath - the path of a file system entry.FileSystemException - if the file system entry does not exist.public long length(String filePath) throws FileSystemException
length in interface FileSystemfilePath - the path of the file.FileSystemException - if the path does not denote an existing file.public boolean hasChildren(String path) throws FileSystemException
hasChildren in interface FileSystempath - the path of a file system entry.FileSystemExceptionpublic String[] list(String folderPath) throws FileSystemException
list in interface FileSystemfolderPath - the path of the folder whose contents is to be listed.FileSystemException - if this path does not denote a folder or if
another error occurs.public String[] listFiles(String folderPath) throws FileSystemException
listFiles in interface FileSystemfolderPath - the path of the folder whose contents is to be listed.FileSystemException - if this path does not denote a folder or if
another error occurs.public String[] listFolders(String folderPath) throws FileSystemException
listFolders in interface FileSystemfolderPath - the path of the folder whose contents is to be listed.FileSystemException - if this path does not denote a folder or if
another error occurs.public InputStream getInputStream(String filePath) throws FileSystemException
getInputStream in interface FileSystemfilePath - the path of the file.FileSystemException - if the file does not exist
or if it cannot be read frompublic OutputStream getOutputStream(String filePath) throws FileSystemException
getOutputStream in interface FileSystemfilePath - the path of the file.FileSystemException - if the file cannot be written to or createdprotected void buildSQLStatements()
protected void verifyRootExists()
throws Exception
Exception - if an error occursprotected void createDeepFolder(String folderPath) throws FileSystemException
folderPath - folder entry to createFileSystemException - if an error occursCopyright © 2004–2024 The Apache Software Foundation. All rights reserved.