Package org.apache.commons.vfs2.provider
Class DelegateFileObject<AFS extends AbstractFileSystem>
java.lang.Object
org.apache.commons.vfs2.provider.AbstractFileObject<AFS>
org.apache.commons.vfs2.provider.DelegateFileObject<AFS>
- Type Parameters:
- AFS- A subclass of AbstractFileSystem.
- All Implemented Interfaces:
- Closeable,- AutoCloseable,- Comparable<FileObject>,- Iterable<FileObject>,- FileListener,- FileObject
public class DelegateFileObject<AFS extends AbstractFileSystem>
extends AbstractFileObject<AFS>
implements FileListener
A file backed by another file.
 
TODO - Extract subclass that overlays the children.
- 
Field SummaryFields inherited from class org.apache.commons.vfs2.provider.AbstractFileObjectDEFAULT_BUFFER_SIZEFields inherited from interface org.apache.commons.vfs2.FileObjectEMPTY_ARRAY
- 
Constructor SummaryConstructorsConstructorDescriptionDelegateFileObject(AbstractFileName fileName, AFS fileSystem, FileObject fileObject) Constructs a new instance.
- 
Method SummaryModifier and TypeMethodDescriptionvoidattachChild(FileName baseName, FileType type) Adds a child to this file.voidclose()Close the delegated file.protected voidCreates this file as a folder.protected voiddoDelete()Deletes the file.Returns the attributes of this file.protected Certificate[]Returns the certificates of this file.protected FileContentInfoGets file content info.protected longReturns the size of the file content (in bytes).protected InputStreamdoGetInputStream(int bufferSize) Creates an input stream to read the file content from.protected longReturns the last-modified time of this file.protected OutputStreamdoGetOutputStream(boolean bAppend) Creates an output stream to write the file content to.protected RandomAccessContentCreates access to the file for random I/O.protected FileTypeDetermines the type of the file, returns null if the file does not exist.protected booleanDetermines if this file is executable.protected booleanDetermines if this file is hidden.protected booleanDetermines if this file can be read.protected booleanDetermines if this file can be written to.protected String[]Lists the children of the file.protected voiddoRemoveAttribute(String attrName) Removes an attribute of this file.protected voiddoRename(FileObject newFile) Renames the file.protected voiddoSetAttribute(String attrName, Object value) Sets an attribute of this file.protected booleandoSetLastModifiedTime(long modtime) Sets the last-modified time of this file.voidfileChanged(FileChangeEvent event) Called when a file is changed.voidfileCreated(FileChangeEvent event) Called when a file is created.voidfileDeleted(FileChangeEvent event) Called when a file is deleted.Gets access to the delegated file.voidrefresh()Refresh file information.voidsetFile(FileObject fileObject) Attaches or detaches the target file.Methods inherited from class org.apache.commons.vfs2.provider.AbstractFileObjectcanRenameTo, childrenChanged, compareTo, copyFrom, createFile, createFolder, delete, delete, deleteAll, doAttach, doCreateFileContent, doDetach, doGetInputStream, doIsSameFile, doIsSymbolicLink, doListChildrenResolved, doSetExecutable, doSetReadable, doSetWritable, endOutput, exists, finalize, findFiles, findFiles, getAbstractFileSystem, getChild, getChildren, getContent, getFileContentInfoFactory, getFileOperations, getFileSystem, getInputStream, getInputStream, getName, getOutputStream, getOutputStream, getParent, getPublicURIString, getRandomAccessContent, getType, getURL, handleChanged, handleCreate, handleDelete, holdObject, injectType, isAttached, isContentOpen, isExecutable, isFile, isFolder, isHidden, isReadable, isSameFile, isSymbolicLink, isWriteable, iterator, listFiles, moveTo, notifyAllStreamsClosed, onChange, onChildrenChanged, resolveFile, resolveFile, setExecutable, setReadable, setWritable, toStringMethods inherited from class java.lang.Objectclone, equals, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.commons.vfs2.FileObjectgetPath, getURIMethods inherited from interface java.lang.IterableforEach, spliterator
- 
Constructor Details- 
DelegateFileObjectpublic DelegateFileObject(AbstractFileName fileName, AFS fileSystem, FileObject fileObject) throws FileSystemException Constructs a new instance.- Parameters:
- fileName- the file name.
- fileSystem- the file system.
- fileObject- My file object.
- Throws:
- FileSystemException- For subclasses to throw.
 
 
- 
- 
Method Details- 
attachChildAdds a child to this file.- Parameters:
- baseName- The base FileName.
- type- The FileType.
- Throws:
- Exception- if an error occurs.
 
- 
closeClose the delegated file.- Specified by:
- closein interface- AutoCloseable
- Specified by:
- closein interface- Closeable
- Specified by:
- closein interface- FileObject
- Overrides:
- closein class- AbstractFileObject<AFS extends AbstractFileSystem>
- Throws:
- FileSystemException- if an error occurs.
- See Also:
 
- 
doCreateFolderCreates this file as a folder.- Overrides:
- doCreateFolderin class- AbstractFileObject<AFS extends AbstractFileSystem>
- Throws:
- Exception- if an error occurs.
 
- 
doDeleteDeletes the file.- Overrides:
- doDeletein class- AbstractFileObject<AFS extends AbstractFileSystem>
- Throws:
- Exception- if an error occurs.
 
- 
doGetAttributesReturns the attributes of this file.- Overrides:
- doGetAttributesin class- AbstractFileObject<AFS extends AbstractFileSystem>
- Returns:
- The attributes of the file.
- Throws:
- Exception- if an error occurs.
 
- 
doGetCertificatesReturns the certificates of this file.- Overrides:
- doGetCertificatesin class- AbstractFileObject<AFS extends AbstractFileSystem>
- Returns:
- The certificates used to sign the file.
- Throws:
- Exception- if an error occurs.
 
- 
doGetContentInfoGets file content info.- Returns:
- the file content info of the delegee.
- Throws:
- Exception- Any thrown Exception is wrapped in FileSystemException.
- Since:
- 2.0
 
- 
doGetContentSizeReturns the size of the file content (in bytes). Is only called ifdoGetType()returnsFileType.FILE.- Specified by:
- doGetContentSizein class- AbstractFileObject<AFS extends AbstractFileSystem>
- Returns:
- The size of the file in bytes.
- Throws:
- Exception- if an error occurs.
 
- 
doGetInputStreamCreates an input stream to read the file content from.- Overrides:
- doGetInputStreamin class- AbstractFileObject<AFS extends AbstractFileSystem>
- Parameters:
- bufferSize- Buffer size hint.
- Returns:
- An InputStream to read the file content.
- Throws:
- Exception- if an error occurs.
 
- 
doGetLastModifiedTimeReturns the last-modified time of this file.- Overrides:
- doGetLastModifiedTimein class- AbstractFileObject<AFS extends AbstractFileSystem>
- Returns:
- The last modification time.
- Throws:
- Exception- if an error occurs.
 
- 
doGetOutputStreamCreates an output stream to write the file content to.- Overrides:
- doGetOutputStreamin class- AbstractFileObject<AFS extends AbstractFileSystem>
- Parameters:
- bAppend- true if the file should be appended to, false if it should be overwritten.
- Returns:
- An OutputStream to write to the file.
- Throws:
- Exception- if an error occurs.
 
- 
doGetRandomAccessContentCreates access to the file for random I/O.- Overrides:
- doGetRandomAccessContentin class- AbstractFileObject<AFS extends AbstractFileSystem>
- Parameters:
- mode- The mode to access the file.
- Returns:
- The RandomAccessContext.
- Throws:
- Exception- if an error occurs.
- Since:
- 2.0
 
- 
doGetTypeDetermines the type of the file, returns null if the file does not exist.- Specified by:
- doGetTypein class- AbstractFileObject<AFS extends AbstractFileSystem>
- Returns:
- the type of the file.
- Throws:
- FileSystemException
 
- 
doIsExecutableDetermines if this file is executable.- Overrides:
- doIsExecutablein class- AbstractFileObject<AFS extends AbstractFileSystem>
- Returns:
- true if the file is executable, false otherwise.
- Throws:
- FileSystemException
 
- 
doIsHiddenDetermines if this file is hidden.- Overrides:
- doIsHiddenin class- AbstractFileObject<AFS extends AbstractFileSystem>
- Returns:
- true if the file is hidden, false otherwise.
- Throws:
- FileSystemException
 
- 
doIsReadableDetermines if this file can be read.- Overrides:
- doIsReadablein class- AbstractFileObject<AFS extends AbstractFileSystem>
- Returns:
- true if the file is readable, false otherwise.
- Throws:
- FileSystemException
 
- 
doIsWriteableDetermines if this file can be written to.- Overrides:
- doIsWriteablein class- AbstractFileObject<AFS extends AbstractFileSystem>
- Returns:
- true if the file is writable.
- Throws:
- FileSystemException
 
- 
doListChildrenLists the children of the file.- Specified by:
- doListChildrenin class- AbstractFileObject<AFS extends AbstractFileSystem>
- Returns:
- a possible empty String array if the file is a directory or null or an exception if the file is not a directory or can't be read.
- Throws:
- Exception- if an error occurs.
 
- 
doRemoveAttributeRemoves an attribute of this file.- Overrides:
- doRemoveAttributein class- AbstractFileObject<AFS extends AbstractFileSystem>
- Parameters:
- attrName- The name of the attribute to remove.
- Throws:
- Exception- if an error occurs.
- Since:
- 2.0
 
- 
doRenameRenames the file.- Overrides:
- doRenamein class- AbstractFileObject<AFS extends AbstractFileSystem>
- Parameters:
- newFile- the new location/name.
- Throws:
- Exception- Any thrown Exception is wrapped in FileSystemException.
- Since:
- 2.0
 
- 
doSetAttributeSets an attribute of this file.- Overrides:
- doSetAttributein class- AbstractFileObject<AFS extends AbstractFileSystem>
- Parameters:
- attrName- The attribute name.
- value- The value to be associated with the attribute name.
- Throws:
- Exception- if an error occurs.
 
- 
doSetLastModifiedTimeSets the last-modified time of this file.- Overrides:
- doSetLastModifiedTimein class- AbstractFileObject<AFS extends AbstractFileSystem>
- Parameters:
- modtime- The last modification time.
- Returns:
- true if the time was set.
- Throws:
- Exception- Any Exception thrown is wrapped in FileSystemException.
- Since:
- 2.0
 
- 
fileChangedCalled when a file is changed.This will only happen if you monitor the file using FileMonitor.- Specified by:
- fileChangedin interface- FileListener
- Parameters:
- event- The FileChangeEvent.
- Throws:
- Exception- if an error occurs.
 
- 
fileCreatedCalled when a file is created.- Specified by:
- fileCreatedin interface- FileListener
- Parameters:
- event- The FileChangeEvent.
- Throws:
- Exception- if an error occurs.
 
- 
fileDeletedCalled when a file is deleted.- Specified by:
- fileDeletedin interface- FileListener
- Parameters:
- event- The FileChangeEvent.
- Throws:
- Exception- if an error occurs.
 
- 
getDelegateFileGets access to the delegated file.- Returns:
- The FileObject.
- Since:
- 2.0
 
- 
refreshRefresh file information.- Specified by:
- refreshin interface- FileObject
- Overrides:
- refreshin class- AbstractFileObject<AFS extends AbstractFileSystem>
- Throws:
- FileSystemException- if an error occurs.
- Since:
- 2.0
 
- 
setFileAttaches or detaches the target file.- Parameters:
- fileObject- The FileObject.
- Throws:
- Exception- if an error occurs.
 
 
-