Package org.apache.commons.vfs.provider
Class AbstractFileSystem
java.lang.Object
org.apache.commons.vfs.provider.AbstractVfsComponent
org.apache.commons.vfs.provider.AbstractFileSystem
- All Implemented Interfaces:
FileSystem,VfsComponent
- Direct Known Subclasses:
CompressedFileFileSystem,FtpFileSystem,HttpFileSystem,LocalFileSystem,RamFileSystem,SftpFileSystem,TarFileSystem,UrlFileSystem,VirtualFileSystem,ZipFileSystem
A partial
FileSystem implementation.- Version:
- $Revision: 484648 $ $Date: 2006-12-08 17:18:36 +0100 (Fri, 08 Dec 2006) $
- Author:
- Adam Murdoch
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractFileSystem(FileName rootName, FileObject parentLayer, FileSystemOptions fileSystemOptions) -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract voidaddCapabilities(Collection caps) Adds the capabilities of this file system.voidaddJunction(String junctionPoint, FileObject targetFile) Adds a junction to this file system.voidaddListener(FileObject file, FileListener listener) Adds a listener on a file in this file system.voidclose()Closes this component.voidClose the underlaying link used to access the filesprotected abstract FileObjectcreateFile(FileName name) Creates a file object.protected FileObjectdecorateFileObject(FileObject file) protected voidClose the underlaying link used to access the filesprotected FiledoReplicateFile(FileObject file, FileSelector selector) Creates a temporary local copy of a file and its descendents.voidfireFileChanged(FileObject file) Fires a file changed event.voidfireFileCreated(FileObject file) Fires a file create event.voidfireFileDeleted(FileObject file) Fires a file delete event.getAttribute(String attrName) Retrieves the attribute with the specified name.protected FileObjectgetFileFromCache(FileName name) Returns a cached file.Return the FileSystemManager used to instantiate this filesystemReturn the FileSystemOptions used to instantiate this filesystemdoubleReturns the accuracy of the last modification timeReturns the parent layer if this is a layered file system.getRoot()Returns the root file of this file system.Returns the name of the root of this file system.booleanhasCapability(Capability capability) Determines if this file system has a particular capability.voidinit()Initialises this component.booleanisOpen()check if this filesystem has open streamsbooleanreturns true if no file is using this filesystemprotected voidwill be called after all file-objects closed their streams.protected voidputFileToCache(FileObject file) Adds a file object to the cache.protected voidremoveFileFromCache(FileName name) remove a cached file.voidremoveJunction(String junctionPoint) Removes a junction from this file system.voidremoveListener(FileObject file, FileListener listener) Removes a listener from a file in this file system.replicateFile(FileObject file, FileSelector selector) Creates a temporary local copy of a file and its descendents.resolveFile(String nameStr) Finds a file in this file system.resolveFile(FileName name) Finds a file in this file system.voidsetAttribute(String attrName, Object value) Sets the attribute with the specified name.Methods inherited from class org.apache.commons.vfs.provider.AbstractVfsComponent
getContext, getLogger, setContext, setLogger
-
Constructor Details
-
AbstractFileSystem
protected AbstractFileSystem(FileName rootName, FileObject parentLayer, FileSystemOptions fileSystemOptions)
-
-
Method Details
-
init
Initialises this component.- Specified by:
initin interfaceVfsComponent- Overrides:
initin classAbstractVfsComponent- Throws:
FileSystemException
-
close
public void close()Closes this component.- Specified by:
closein interfaceVfsComponent- Overrides:
closein classAbstractVfsComponent
-
closeCommunicationLink
public void closeCommunicationLink()Close the underlaying link used to access the files -
doCloseCommunicationLink
protected void doCloseCommunicationLink()Close the underlaying link used to access the files -
createFile
Creates a file object. This method is called only if the requested file is not cached.- Throws:
Exception
-
addCapabilities
Adds the capabilities of this file system. -
getRootName
Returns the name of the root of this file system.- Specified by:
getRootNamein interfaceFileSystem
-
putFileToCache
Adds a file object to the cache. -
getFileFromCache
Returns a cached file. -
removeFileFromCache
remove a cached file. -
hasCapability
Determines if this file system has a particular capability.- Specified by:
hasCapabilityin interfaceFileSystem- Parameters:
capability- The capability to check for.- Returns:
- true if this filesystem has the requested capability. Note that not all files in the file system may have the capability.
-
getAttribute
Retrieves the attribute with the specified name. The default implementation simply throws an exception.- Specified by:
getAttributein interfaceFileSystem- Parameters:
attrName- The name of the attribute.- Returns:
- The value of the attribute.
- Throws:
FileSystemException- If the file does not exist, or is being written, or if the attribute is unknown.- See Also:
-
setAttribute
Sets the attribute with the specified name. The default implementation simply throws an exception.- Specified by:
setAttributein interfaceFileSystem- Parameters:
attrName- The name of the attribute.value- The value of the attribute.- Throws:
FileSystemException- If the file is read-only, or is being read, or if the attribute is not supported, or on error setting the attribute.- See Also:
-
getParentLayer
Returns the parent layer if this is a layered file system.- Specified by:
getParentLayerin interfaceFileSystem- Returns:
- The parent layer, or null if this is not a layered file system.
- Throws:
FileSystemException
-
getRoot
Returns the root file of this file system.- Specified by:
getRootin interfaceFileSystem- Throws:
FileSystemException
-
resolveFile
Finds a file in this file system.- Specified by:
resolveFilein interfaceFileSystem- Parameters:
nameStr- The name of the file. This must be an absolute path.- Returns:
- The file. Never returns null.
- Throws:
FileSystemException
-
resolveFile
Finds a file in this file system.- Specified by:
resolveFilein interfaceFileSystem- Parameters:
name- The name of the file.- Returns:
- The file. Never returns null.
- Throws:
FileSystemException
-
decorateFileObject
- Throws:
FileSystemException
-
replicateFile
Creates a temporary local copy of a file and its descendents.- Specified by:
replicateFilein interfaceFileSystem- Parameters:
file- The file to replicate.selector- The selector to use to select the files to replicate.- Returns:
- The local copy of this file.
- Throws:
FileSystemException- If this file does not exist, or on error replicating the file.
-
getFileSystemOptions
Return the FileSystemOptions used to instantiate this filesystem- Specified by:
getFileSystemOptionsin interfaceFileSystem
-
getFileSystemManager
Return the FileSystemManager used to instantiate this filesystem- Specified by:
getFileSystemManagerin interfaceFileSystem
-
getLastModTimeAccuracy
public double getLastModTimeAccuracy()Returns the accuracy of the last modification time- Specified by:
getLastModTimeAccuracyin interfaceFileSystem- Returns:
- ms 0 perfectly accurate, >0 might be off by this value e.g. sftp 1000ms
-
doReplicateFile
Creates a temporary local copy of a file and its descendents.- Throws:
Exception
-
addJunction
Adds a junction to this file system.- Specified by:
addJunctionin interfaceFileSystem- Parameters:
junctionPoint- The point in this file system to add the junction.targetFile- The file to link to.- Throws:
FileSystemException- If this file system does not support junctions, or the junction point or target file is invalid (the file system may not support nested junctions, for example).
-
removeJunction
Removes a junction from this file system.- Specified by:
removeJunctionin interfaceFileSystem- Parameters:
junctionPoint- The junction to remove.- Throws:
FileSystemException- On error removing the junction.
-
addListener
Adds a listener on a file in this file system.- Specified by:
addListenerin interfaceFileSystem- Parameters:
file- The file to attach the listener to.listener- The listener to add.
-
removeListener
Removes a listener from a file in this file system.- Specified by:
removeListenerin interfaceFileSystem- Parameters:
file- The file to remove the listener from.listener- The listener to remove.
-
fireFileCreated
Fires a file create event. -
fireFileDeleted
Fires a file delete event. -
fireFileChanged
Fires a file changed event.
This will only happen if you monitor the file usingFileMonitor. -
isReleaseable
public boolean isReleaseable()returns true if no file is using this filesystem -
notifyAllStreamsClosed
protected void notifyAllStreamsClosed()will be called after all file-objects closed their streams. -
isOpen
public boolean isOpen()check if this filesystem has open streams
-