Package org.apache.commons.vfs2.provider
Class AbstractFileProvider
- java.lang.Object
-
- org.apache.commons.vfs2.provider.AbstractVfsComponent
-
- org.apache.commons.vfs2.provider.AbstractVfsContainer
-
- org.apache.commons.vfs2.provider.AbstractFileProvider
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,FileProvider
,VfsComponent
- Direct Known Subclasses:
AbstractLayeredFileProvider
,AbstractOriginatingFileProvider
,CompositeFileProvider
,ResourceFileProvider
,TemporaryFileProvider
,UrlFileProvider
public abstract class AbstractFileProvider extends AbstractVfsContainer implements FileProvider
A partialFileProvider
implementation. Takes care of managing the file systems created by the provider.
-
-
Field Summary
Fields Modifier and Type Field Description private static AbstractFileSystem[]
EMPTY_ABSTRACT_FILE_SYSTEMS
private java.util.Map<FileSystemKey,FileSystem>
fileSystemMap
The cached file systems.private FileNameParser
parser
-
Constructor Summary
Constructors Constructor Description AbstractFileProvider()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addFileSystem(java.lang.Comparable<?> key, FileSystem fs)
Adds a file system to those cached by this provider.void
close()
Closes the file systems created by this provider.void
closeFileSystem(FileSystem fileSystem)
Close the FileSystem.FileObject
createFileSystem(java.lang.String scheme, FileObject file, FileSystemOptions fileSystemOptions)
Creates a layered file system.protected FileSystem
findFileSystem(java.lang.Comparable<?> key, FileSystemOptions fileSystemOptions)
Locates a cached file system.void
freeUnusedResources()
Free unused resources.FileSystemConfigBuilder
getConfigBuilder()
Returns the FileSystemConfigBuidler.protected FileNameParser
getFileNameParser()
FileName
parseUri(FileName base, java.lang.String uri)
Parses an absolute URI.protected void
setFileNameParser(FileNameParser parser)
-
Methods inherited from class org.apache.commons.vfs2.provider.AbstractVfsContainer
addComponent, removeComponent
-
Methods inherited from class org.apache.commons.vfs2.provider.AbstractVfsComponent
getContext, getLogger, init, setContext, setLogger
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.commons.vfs2.provider.FileProvider
findFile, getCapabilities
-
-
-
-
Field Detail
-
EMPTY_ABSTRACT_FILE_SYSTEMS
private static final AbstractFileSystem[] EMPTY_ABSTRACT_FILE_SYSTEMS
-
fileSystemMap
private final java.util.Map<FileSystemKey,FileSystem> fileSystemMap
The cached file systems.This is a mapping from
FileSystemKey
(root URI and options) toFileSystem
.
-
parser
private FileNameParser parser
-
-
Method Detail
-
getFileNameParser
protected FileNameParser getFileNameParser()
-
setFileNameParser
protected void setFileNameParser(FileNameParser parser)
-
close
public void close()
Closes the file systems created by this provider.- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Specified by:
close
in interfaceVfsComponent
- Overrides:
close
in classAbstractVfsContainer
-
createFileSystem
public FileObject createFileSystem(java.lang.String scheme, FileObject file, FileSystemOptions fileSystemOptions) throws FileSystemException
Creates a layered file system. This method throws a 'not supported' exception.- Specified by:
createFileSystem
in interfaceFileProvider
- Parameters:
scheme
- The protocol to use to access the file.file
- a FileObject.fileSystemOptions
- Options to the file system.- Returns:
- A FileObject associated with the new FileSystem.
- Throws:
FileSystemException
- if an error occurs.
-
addFileSystem
protected void addFileSystem(java.lang.Comparable<?> key, FileSystem fs) throws FileSystemException
Adds a file system to those cached by this provider.The file system may implement
VfsComponent
, in which case it is initialized.- Parameters:
key
- The root file of the file system, part of the cache key.fs
- the file system to add.- Throws:
FileSystemException
- if any error occurs.
-
findFileSystem
protected FileSystem findFileSystem(java.lang.Comparable<?> key, FileSystemOptions fileSystemOptions)
Locates a cached file system.- Parameters:
key
- The root file of the file system, part of the cache key.fileSystemOptions
- file system options the file system instance must have, may be null.- Returns:
- The file system instance, or null if it is not cached.
-
getConfigBuilder
public FileSystemConfigBuilder getConfigBuilder()
Returns the FileSystemConfigBuidler.- Specified by:
getConfigBuilder
in interfaceFileProvider
- Returns:
- the FileSystemConfigBuilder.
-
freeUnusedResources
public void freeUnusedResources()
Free unused resources.
-
closeFileSystem
public void closeFileSystem(FileSystem fileSystem)
Close the FileSystem.- Parameters:
fileSystem
- The FileSystem to close.
-
parseUri
public FileName parseUri(FileName base, java.lang.String uri) throws FileSystemException
Parses an absolute URI.- Specified by:
parseUri
in interfaceFileProvider
- Parameters:
base
- The base file - if null theuri
needs to be absoluteuri
- The URI to parse.- Returns:
- The FileName.
- Throws:
FileSystemException
- if an error occurs.
-
-