public interface FileSystemManager extends AutoCloseable
FileObject by name from
one of those file systems.
To locate a FileObject, use one of the resolveFile() methods.
A file system manager can recognise several types of file names:
file: or ftp:, followed by a scheme
dependent file name. Some examples: file:/c:/somefile or ftp://somewhere.org/somefile./home/someuser/a-file or c:\dir\somefile.html. Elements in
the name can be separated using any of the following characters: /, \, or the native file separator
character. For example, the following file names are the same: c:\somedir\somefile.xml and
c:/somedir/somefile.xml.../somefile or somedir/file.txt. The file system manager resolves
relative paths against its base file. Elements in the relative path can be separated using /,
\, or file system specific separator characters. Relative paths may also contain .. and .
elements. See FileObject.resolveFile(java.lang.String) for more details.| Modifier and Type | Method and Description |
|---|---|
void |
addOperationProvider(String[] schemes,
FileOperationProvider operationProvider) |
void |
addOperationProvider(String scheme,
FileOperationProvider operationProvider)
Adds the specified FileOperationProvider for the specified scheme.
|
boolean |
canCreateFileSystem(FileObject file)
Determines if a layered file system can be created for a given file.
|
default void |
close()
Closes this file system manager.
|
void |
closeFileSystem(FileSystem fileSystem)
Closes the given file system.
|
FileObject |
createFileSystem(FileObject file)
Creates a layered file system.
|
FileObject |
createFileSystem(String provider,
FileObject file)
Creates a layered file system.
|
FileObject |
createVirtualFileSystem(FileObject rootFile)
Creates a virtual file system.
|
FileObject |
createVirtualFileSystem(String rootUri)
Creates an empty virtual file system.
|
FileObject |
getBaseFile()
Returns the base file used to resolve relative paths.
|
CacheStrategy |
getCacheStrategy()
Gets the cache strategy used.
|
FileContentInfoFactory |
getFileContentInfoFactory()
Gets the class to use to determine the content-type (mime-type).
|
Class<?> |
getFileObjectDecorator()
Gets the file object decorator used.
|
Constructor<?> |
getFileObjectDecoratorConst()
Gets the constructor associated to the fileObjectDecorator.
|
FilesCache |
getFilesCache()
Gets the cache used to cache file objects.
|
FileSystemConfigBuilder |
getFileSystemConfigBuilder(String scheme)
Gets the configuration builder for the given scheme.
|
FileOperationProvider[] |
getOperationProviders(String scheme)
Gets Providers for file operations.
|
Collection<Capability> |
getProviderCapabilities(String scheme)
Gets the capabilities for a given scheme.
|
String[] |
getSchemes()
Gets the schemes currently available.
|
URLStreamHandlerFactory |
getURLStreamHandlerFactory()
Returns a stream handler factory to enable URL lookup using this FileSystemManager.
|
boolean |
hasProvider(String scheme)
Returns true if this manager has a provider for a particular scheme.
|
FileObject |
resolveFile(FileObject baseFile,
String name)
Locates a file by name.
|
FileObject |
resolveFile(File baseFile,
String name)
Locates a file by name.
|
FileObject |
resolveFile(String name)
Locates a file by name.
|
FileObject |
resolveFile(String name,
FileSystemOptions fileSystemOptions)
Locates a file by name.
|
FileObject |
resolveFile(URI uri)
Resolves a URI into a
FileObject. |
FileObject |
resolveFile(URL url)
Resolves a URL into a
FileObject. |
FileName |
resolveName(FileName root,
String name)
Resolves a name, relative to this file name.
|
FileName |
resolveName(FileName root,
String name,
NameScope scope)
Resolves a name, relative to the "root" file name.
|
FileName |
resolveURI(String uri)
Resolves the URI to a file name.
|
void |
setLogger(org.apache.commons.logging.Log log)
Sets the logger to use.
|
FileObject |
toFileObject(File file)
Converts a local file into a
FileObject. |
void addOperationProvider(String scheme, FileOperationProvider operationProvider) throws FileSystemException
Several FileOperationProvider's might be registered for the same scheme. For example, for "file" scheme
we can register SvnWsOperationProvider and CvsOperationProvider.
scheme - The scheme assoicated with this provider.operationProvider - The FileOperationProvider to add.FileSystemException - if an error occurs.void addOperationProvider(String[] schemes, FileOperationProvider operationProvider) throws FileSystemException
schemes - The schemes that will be associated with the provider.operationProvider - The FileOperationProvider to add.FileSystemException - if an error occurs.addOperationProvider(String, org.apache.commons.vfs2.operations.FileOperationProvider)boolean canCreateFileSystem(FileObject file) throws FileSystemException
file - The file to check for.FileSystemException - if an error occurs.default void close()
close in interface AutoCloseablevoid closeFileSystem(FileSystem fileSystem)
If you use VFS as singleton it is VERY dangerous to call this method.
fileSystem - The FileSystem to close.FileObject createFileSystem(FileObject file) throws FileSystemException
file - The file to use to create the file system.FileSystemException - On error creating the file system.FileObject createFileSystem(String provider, FileObject file) throws FileSystemException
provider - The name of the file system provider to use. This name is the same as the scheme used in URI to
identify the provider.file - The file to use to create the file system.FileSystemException - On error creating the file system.FileObject createVirtualFileSystem(FileObject rootFile) throws FileSystemException
rootFile - The root file to backs the file system.FileSystemException - if an error occurs creating the VirtualFileSystem.FileObject createVirtualFileSystem(String rootUri) throws FileSystemException
rootUri - The root URI to use for the new file system. Can be null.FileSystemException - if an error occurs creating the VirtualFileSystem.FileObject getBaseFile() throws FileSystemException
FileSystemException - if an error occurs.CacheStrategy getCacheStrategy()
FileContentInfoFactory getFileContentInfoFactory()
Class<?> getFileObjectDecorator()
Constructor<?> getFileObjectDecoratorConst()
FilesCache getFilesCache()
FileSystemConfigBuilder getFileSystemConfigBuilder(String scheme) throws FileSystemException
scheme - The schem to use to obtain the FileSystemConfigBuidler.FileSystemException - if the given scheme is not konwn.FileOperationProvider[] getOperationProviders(String scheme) throws FileSystemException
scheme - the scheme for wich we want to get the list af registered providers.FileSystemException - if an error occurs.Collection<Capability> getProviderCapabilities(String scheme) throws FileSystemException
scheme - The scheme to use to locate the provider's capabilities.FileSystemException - if the given scheme is not konwn.String[] getSchemes()
URLStreamHandlerFactory getURLStreamHandlerFactory()
boolean hasProvider(String scheme)
scheme - The scheme for which a provider should be checked.FileObject resolveFile(File baseFile, String name) throws FileSystemException
resolveFile(FileObject, String) for details.baseFile - The base file to use to resolve relative paths. Must not be null, not even if the
name is absolute.name - The name of the file.FileSystemException - On error parsing the file name.FileObject resolveFile(FileObject baseFile, String name) throws FileSystemException
baseFile.
Note that the file does not have to exist when this method is called.
baseFile - The base file to use to resolve relative paths. May be null if the name is an absolute file name.name - The name of the file.FileSystemException - On error parsing the file name.FileObject resolveFile(String name) throws FileSystemException
resolveFile(getBaseFile(), name).name - The name of the file.FileSystemException - On error parsing the file name.FileObject resolveFile(String name, FileSystemOptions fileSystemOptions) throws FileSystemException
resolveFile(getBaseFile(), name).name - The name of the file.fileSystemOptions - The FileSystemOptions used for FileSystem creation. All files that are later resolved
relative to the returned FileObject share the options.FileSystemException - On error parsing the file name.FileObject resolveFile(URI uri) throws FileSystemException
FileObject.uri - The URI to convert.FileObject that represents the URI. Never returns null.FileSystemException - On error converting the file.FileObject resolveFile(URL url) throws FileSystemException
FileObject.url - The URL to convert.FileObject that represents the URL. Never returns null.FileSystemException - On error converting the file.FileName resolveName(FileName root, String name) throws FileSystemException
resolveName( path, NameScope.FILE_SYSTEM ).root - the base file namename - The name to resolve.FileName object representing the resolved file name.FileSystemException - If the name is invalid.FileName resolveName(FileName root, String name, NameScope scope) throws FileSystemException
NameScope for a description of how names are
resolved.root - the base file namename - The name to resolve.scope - The NameScope to use when resolving the name.FileName object representing the resolved file name.FileSystemException - If the name is invalid.FileName resolveURI(String uri) throws FileSystemException
uri - The URI to resolve.FileSystemException - if this is not possible.void setLogger(org.apache.commons.logging.Log log)
log - The logger to use.FileObject toFileObject(File file) throws FileSystemException
FileObject.file - The file to convert.FileObject that represents the local file. Never returns null.FileSystemException - On error converting the file.Copyright © 2002–2020 The Apache Software Foundation. All rights reserved.