org.apache.commons.vfs
Interface FileSystemManager

All Known Implementing Classes:
DefaultFileSystemManager

public interface FileSystemManager

A FileSystemManager manages a set of file systems. This interface is used to locate a FileObject by name from one of those file systems.

To locate a FileObject, use one of the resolveFile() methods.

File Naming

A file system manager can recognise several types of file names:

Version:
$Revision: 484648 $ $Date: 2006-12-08 17:18:36 +0100 (Fr, 08 Dez 2006) $
Author:
Adam Murdoch

Method Summary
 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.
 void closeFileSystem(FileSystem filesystem)
          Closes the given filesystem.
 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()
          Get the cache strategy used
 FileContentInfoFactory getFileContentInfoFactory()
          The class to use to determine the content-type (mime-type)
 Class getFileObjectDecorator()
          Get the file object decorator used
 Constructor getFileObjectDecoratorConst()
          The constructor associated to the fileObjectDecorator.
 FilesCache getFilesCache()
          Get the cache used to cache fileobjects.
 FileSystemConfigBuilder getFileSystemConfigBuilder(String scheme)
          Get the configuration builder for the given scheme
 FileOperationProvider[] getOperationProviders(String scheme)
           
 Collection getProviderCapabilities(String scheme)
          Get the capabilities for a given scheme.
 String[] getSchemes()
          Get the schemes currently available.
 URLStreamHandlerFactory getURLStreamHandlerFactory()
          Returns a streamhandler factory to enable URL lookup using this FileSystemManager.
 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.
 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)
          Resolve the uri to a filename
 void setLogger(org.apache.commons.logging.Log log)
          Sets the logger to use.
 FileObject toFileObject(File file)
          Converts a local file into a FileObject.
 

Method Detail

getBaseFile

public FileObject getBaseFile()
                       throws FileSystemException
Returns the base file used to resolve relative paths.

Throws:
FileSystemException

resolveFile

public FileObject resolveFile(String name)
                       throws FileSystemException
Locates a file by name. Equivalent to calling resolveFile(uri, getBaseName()).

Parameters:
name - The name of the file.
Returns:
The file. Never returns null.
Throws:
FileSystemException - On error parsing the file name.

resolveFile

public FileObject resolveFile(String name,
                              FileSystemOptions fileSystemOptions)
                       throws FileSystemException
Locates a file by name. Equivalent to calling resolveFile(uri, getBaseName()).

Parameters:
name - The name of the file.
fileSystemOptions - The FileSystemOptions used for FileSystem creation
Returns:
The file. Never returns null.
Throws:
FileSystemException - On error parsing the file name.

resolveFile

public FileObject resolveFile(FileObject baseFile,
                              String name)
                       throws FileSystemException
Locates a file by name. The name is resolved as described above. That is, the name can be either an absolute URI, an absolute file name, or a relative path to be resolved against baseFile.

Note that the file does not have to exist when this method is called.

Parameters:
name - The name of the file.
baseFile - The base file to use to resolve relative paths. May be null.
Returns:
The file. Never returns null.
Throws:
FileSystemException - On error parsing the file name.

resolveFile

public FileObject resolveFile(File baseFile,
                              String name)
                       throws FileSystemException
Locates a file by name. See resolveFile(FileObject, String) for details.

Parameters:
baseFile - The base file to use to resolve relative paths. May be null.
name - The name of the file.
Returns:
The file. Never returns null.
Throws:
FileSystemException - On error parsing the file name.

resolveName

public FileName resolveName(FileName root,
                            String name)
                     throws FileSystemException
Resolves a name, relative to this file name. Equivalent to calling resolveName( path, NameScope.FILE_SYSTEM ).

Parameters:
root - the base filename
name - The name to resolve.
Returns:
A FileName object representing the resolved file name.
Throws:
FileSystemException - If the name is invalid.

resolveName

public FileName resolveName(FileName root,
                            String name,
                            NameScope scope)
                     throws FileSystemException
Resolves a name, relative to the "root" file name. Refer to NameScope for a description of how names are resolved.

Parameters:
root - the base filename
name - The name to resolve.
scope - The NameScope to use when resolving the name.
Returns:
A FileName object representing the resolved file name.
Throws:
FileSystemException - If the name is invalid.

toFileObject

public FileObject toFileObject(File file)
                        throws FileSystemException
Converts a local file into a FileObject.

Parameters:
file - The file to convert.
Returns:
The FileObject that represents the local file. Never returns null.
Throws:
FileSystemException - On error converting the file.

createFileSystem

public FileObject createFileSystem(String provider,
                                   FileObject file)
                            throws FileSystemException
Creates a layered file system. A layered file system is a file system that is created from the contents of a file, such as a zip or tar file.

Parameters:
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.
Returns:
The root file of the new file system.
Throws:
FileSystemException - On error creating the file system.

closeFileSystem

public void closeFileSystem(FileSystem filesystem)
Closes the given filesystem.
If you use VFS as singleton it is VERY dangerous to call this method.


createFileSystem

public FileObject createFileSystem(FileObject file)
                            throws FileSystemException
Creates a layered file system. A layered file system is a file system that is created from the contents of a file, such as a zip or tar file.

Parameters:
file - The file to use to create the file system.
Returns:
The root file of the new file system.
Throws:
FileSystemException - On error creating the file system.

createVirtualFileSystem

public FileObject createVirtualFileSystem(String rootUri)
                                   throws FileSystemException
Creates an empty virtual file system. Can be populated by adding junctions to it.

Parameters:
rootUri - The root URI to use for the new file system. Can be null.
Returns:
The root file of the new file system.
Throws:
FileSystemException

createVirtualFileSystem

public FileObject createVirtualFileSystem(FileObject rootFile)
                                   throws FileSystemException
Creates a virtual file system. The file system will contain a junction at the fs root to the supplied root file.

Parameters:
rootFile - The root file to backs the file system.
Returns:
The root of the new file system.
Throws:
FileSystemException

getURLStreamHandlerFactory

public URLStreamHandlerFactory getURLStreamHandlerFactory()
Returns a streamhandler factory to enable URL lookup using this FileSystemManager.


canCreateFileSystem

public boolean canCreateFileSystem(FileObject file)
                            throws FileSystemException
Determines if a layered file system can be created for a given file.

Parameters:
file - The file to check for.
Throws:
FileSystemException

getFilesCache

public FilesCache getFilesCache()
Get the cache used to cache fileobjects.


getCacheStrategy

public CacheStrategy getCacheStrategy()
Get the cache strategy used


getFileObjectDecorator

public Class getFileObjectDecorator()
Get the file object decorator used


getFileObjectDecoratorConst

public Constructor getFileObjectDecoratorConst()
The constructor associated to the fileObjectDecorator. We cache it here for performance reasons.


getFileContentInfoFactory

public FileContentInfoFactory getFileContentInfoFactory()
The class to use to determine the content-type (mime-type)


getSchemes

public String[] getSchemes()
Get the schemes currently available.


getProviderCapabilities

public Collection getProviderCapabilities(String scheme)
                                   throws FileSystemException
Get the capabilities for a given scheme.

Throws:
FileSystemException - if the given scheme is not konwn

setLogger

public void setLogger(org.apache.commons.logging.Log log)
Sets the logger to use.


getFileSystemConfigBuilder

public FileSystemConfigBuilder getFileSystemConfigBuilder(String scheme)
                                                   throws FileSystemException
Get the configuration builder for the given scheme

Throws:
FileSystemException - if the given scheme is not konwn

resolveURI

public FileName resolveURI(String uri)
                    throws FileSystemException
Resolve the uri to a filename

Throws:
FileSystemException - if this is not possible

addOperationProvider

public void addOperationProvider(String scheme,
                                 FileOperationProvider operationProvider)
                          throws FileSystemException
Adds the specified FileOperationProvider for the specified scheme. Several FileOperationProvider's might be registered for the same scheme. For example, for "file" scheme we can register SvnWsOperationProvider and CvsOperationProvider.

Parameters:
scheme -
operationProvider -
Throws:
FileSystemException

addOperationProvider

public void addOperationProvider(String[] schemes,
                                 FileOperationProvider operationProvider)
                          throws FileSystemException
Parameters:
schemes -
operationProvider -
Throws:
FileSystemException
See Also:
addOperationProvider(String, org.apache.commons.vfs.operations.FileOperationProvider)

getOperationProviders

public FileOperationProvider[] getOperationProviders(String scheme)
                                              throws FileSystemException
Parameters:
scheme - the scheme for wich we want to get the list af registered providers.
Returns:
the registered FileOperationProviders for the specified scheme. If there were no providers registered for the scheme, it returns null.
Throws:
FileSystemException


Copyright © 2002-2006 The Apache Software Foundation. All Rights Reserved.