public abstract class AbstractFileSystem extends AbstractVfsComponent implements FileSystem
FileSystem
implementation.Modifier | Constructor and Description |
---|---|
protected |
AbstractFileSystem(FileName rootName,
FileObject parentLayer,
FileSystemOptions fileSystemOptions)
Constructs a new instance.
|
Modifier and Type | Method and Description |
---|---|
protected abstract void |
addCapabilities(Collection<Capability> caps)
Adds the capabilities of this file system.
|
void |
addJunction(String junctionPoint,
FileObject targetFile)
Adds a junction to this file system.
|
void |
addListener(FileObject file,
FileListener listener)
Adds a listener on a file in this file system.
|
void |
close()
Closes this component.
|
void |
closeCommunicationLink()
Closes the underlying link used to access the files.
|
protected abstract FileObject |
createFile(AbstractFileName name)
Creates a file object.
|
protected FileObject |
decorateFileObject(FileObject file)
Decorates the given file object.
|
protected void |
doCloseCommunicationLink()
Closes the underlying link used to access the files.
|
protected File |
doReplicateFile(FileObject file,
FileSelector selector)
Creates a temporary local copy of a file and its descendants.
|
void |
fireFileChanged(FileObject file)
Fires a file changed event.
|
void |
fireFileCreated(FileObject file)
Fires a file create event.
|
void |
fireFileDeleted(FileObject file)
Fires a file delete event.
|
Object |
getAttribute(String attrName)
Gets the attribute with the specified name.
|
protected FileObject |
getFileFromCache(FileName name)
Gets a cached file.
|
FileSystemManager |
getFileSystemManager()
Gets the FileSystemManager used to instantiate this file system.
|
FileSystemOptions |
getFileSystemOptions()
Gets the FileSystemOptions used to instantiate this file system.
|
double |
getLastModTimeAccuracy()
Gets the accuracy of the last modification time.
|
FileObject |
getParentLayer()
Gets the parent layer if this is a layered file system.
|
FileObject |
getRoot()
Gets the root file of this file system.
|
FileName |
getRootName()
Gets the name of the root of this file system.
|
String |
getRootURI()
Gets the root URI specified for this file System.
|
boolean |
hasCapability(Capability capability)
Tests whether this file system has a particular capability.
|
void |
init()
Initializes this component.
|
boolean |
isOpen()
Tests whether this file system has open streams.
|
boolean |
isReleaseable()
Tests whether any files are using this FileSystem.
|
protected void |
notifyAllStreamsClosed()
Called after all file-objects closed their streams.
|
protected void |
putFileToCache(FileObject file)
Adds a file object to the cache.
|
protected void |
removeFileFromCache(FileName name)
Removes a cached file.
|
void |
removeJunction(String junctionPoint)
Removes a junction from this file system.
|
void |
removeListener(FileObject file,
FileListener listener)
Removes a listener from a file in this file system.
|
File |
replicateFile(FileObject file,
FileSelector selector)
Creates a temporary local copy of a file and its descendants.
|
FileObject |
resolveFile(FileName name)
Finds a file in this file system.
|
FileObject |
resolveFile(String nameStr)
Finds a file in this file system.
|
void |
setAttribute(String attrName,
Object value)
Sets the attribute with the specified name.
|
getContext, getLogger, setContext, setLogger
protected AbstractFileSystem(FileName rootName, FileObject parentLayer, FileSystemOptions fileSystemOptions)
rootName
- The root file name of this file system.parentLayer
- The parent layer of this file system.fileSystemOptions
- Options to build this file system.protected abstract void addCapabilities(Collection<Capability> caps)
caps
- collections of Capabilities, can be immutable.public void addJunction(String junctionPoint, FileObject targetFile) throws FileSystemException
addJunction
in interface FileSystem
junctionPoint
- The junction point.targetFile
- The target to add.FileSystemException
- if an error occurs.public void addListener(FileObject file, FileListener listener)
addListener
in interface FileSystem
file
- The FileObject to be monitored.listener
- The FileListenerpublic void close()
close
in interface Closeable
close
in interface AutoCloseable
close
in interface VfsComponent
close
in class AbstractVfsComponent
public void closeCommunicationLink()
protected abstract FileObject createFile(AbstractFileName name) throws Exception
This method is called only if the requested file is not cached.
name
- name referencing the new file.Exception
- might throw an Exception, which is then wrapped in FileSystemException.protected FileObject decorateFileObject(FileObject file) throws FileSystemException
file
- the file object.FileSystemException
- if a file system error occurs.protected void doCloseCommunicationLink()
protected File doReplicateFile(FileObject file, FileSelector selector) throws Exception
file
- the start of the tree.selector
- selection what to do with children.Exception
- any Exception is wrapped as FileSystemException.public void fireFileChanged(FileObject file)
This will only happen if you monitor the file using FileMonitor
.
file
- The FileObject that changed.public void fireFileCreated(FileObject file)
file
- The FileObject that was created.public void fireFileDeleted(FileObject file)
file
- The FileObject that was deleted.public Object getAttribute(String attrName) throws FileSystemException
getAttribute
in interface FileSystem
attrName
- The name of the attribute.FileSystemException
- if an error occurs.FileContent.getAttribute(java.lang.String)
protected FileObject getFileFromCache(FileName name)
name
- name to search for.public FileSystemManager getFileSystemManager()
getFileSystemManager
in interface FileSystem
public FileSystemOptions getFileSystemOptions()
getFileSystemOptions
in interface FileSystem
public double getLastModTimeAccuracy()
getLastModTimeAccuracy
in interface FileSystem
> 0
might be off by this value, for examnple, sftp is 1000 milliseconds.public FileObject getParentLayer() throws FileSystemException
getParentLayer
in interface FileSystem
FileSystemException
- if an error occurs.public FileObject getRoot() throws FileSystemException
getRoot
in interface FileSystem
FileSystemException
- if an error occurs.public FileName getRootName()
getRootName
in interface FileSystem
public String getRootURI()
getRootURI
in interface FileSystem
public boolean hasCapability(Capability capability)
hasCapability
in interface FileSystem
capability
- the Capability to check for.public void init() throws FileSystemException
init
in interface VfsComponent
init
in class AbstractVfsComponent
FileSystemException
- if an error occurs.public boolean isOpen()
public boolean isReleaseable()
protected void notifyAllStreamsClosed()
protected void putFileToCache(FileObject file)
file
- the file to add.protected void removeFileFromCache(FileName name)
name
- The file name to remove.public void removeJunction(String junctionPoint) throws FileSystemException
removeJunction
in interface FileSystem
junctionPoint
- The junction point.FileSystemException
- if an error occurspublic void removeListener(FileObject file, FileListener listener)
removeListener
in interface FileSystem
file
- The FileObject to be monitored.listener
- The FileListenerpublic File replicateFile(FileObject file, FileSelector selector) throws FileSystemException
replicateFile
in interface FileSystem
file
- The FileObject to replicate.selector
- The FileSelector.FileSystemException
- if an error occurs.public FileObject resolveFile(FileName name) throws FileSystemException
resolveFile
in interface FileSystem
name
- The name of the file to locate.FileSystemException
- if an error occurs.public FileObject resolveFile(String nameStr) throws FileSystemException
resolveFile
in interface FileSystem
nameStr
- The name of the file to resolve.FileSystemException
- if an error occurs.public void setAttribute(String attrName, Object value) throws FileSystemException
setAttribute
in interface FileSystem
attrName
- the attribute name.value
- The object to associate with the attribute.FileSystemException
- if an error occurs.FileContent.setAttribute(java.lang.String, java.lang.Object)
Copyright © 2002–2025 The Apache Software Foundation. All rights reserved.