Package org.apache.commons.vfs.impl
Class DecoratedFileObject
java.lang.Object
org.apache.commons.vfs.impl.DecoratedFileObject
- All Implemented Interfaces:
FileObject
- Direct Known Subclasses:
OnCallRefreshFileObject,SynchronizedFileObject
Base class to build a fileObject decoration
- Version:
- $Revision: 480428 $ $Date: 2006-11-29 07:15:24 +0100 (Wed, 29 Nov 2006) $
- Author:
- Mario Ivankovits
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancanRenameTo(FileObject newfile) Queries the file if it is possible to rename it to newfile.voidclose()Closes this file, and its content.voidcopyFrom(FileObject srcFile, FileSelector selector) Copies another file, and all its descendents, to this file.voidCreates this file, if it does not exist.voidCreates this folder, if it does not exist.booleandelete()Deletes this file.intdelete(FileSelector selector) Deletes all descendents of this file that match a selector.booleanexists()Determines if this file exists.findFiles(FileSelector selector) Finds the set of matching descendents of this file, in depthwise order.voidfindFiles(FileSelector selector, boolean depthwise, List selected) Finds the set of matching descendents of this file.Returns a child of this file.Lists the children of this file.Returns this file's content.Returns the file system that contains this file.getName()Returns the name of this file.Returns the folder that contains this file.getType()Returns this file's type.getURL()Returns a URL representing this file.booleancheck if the fileObject is attacedbooleancheck if someone reads/write to this filebooleanisHidden()Determines if this file is hidden.booleanDetermines if this file can be read.booleanDetermines if this file can be written to.voidmoveTo(FileObject destFile) Move this file.voidrefresh()This will prepare the fileObject to get resynchronized with the underlaying filesystem if requiredresolveFile(String path) Finds a file, relative to this file.resolveFile(String name, NameScope scope) Finds a file, relative to this file.toString()
-
Constructor Details
-
DecoratedFileObject
-
-
Method Details
-
canRenameTo
Description copied from interface:FileObjectQueries the file if it is possible to rename it to newfile.- Specified by:
canRenameToin interfaceFileObject- Parameters:
newfile- the new file(-name)- Returns:
- true it this is the case
-
close
Description copied from interface:FileObjectCloses this file, and its content. This method is a hint to the implementation that it can release any resources associated with the file.The file object can continue to be used after this method is called.
- Specified by:
closein interfaceFileObject- Throws:
FileSystemException- On error closing the file.- See Also:
-
copyFrom
Description copied from interface:FileObjectCopies another file, and all its descendents, to this file. If this file does not exist, it is created. Its parent folder is also created, if necessary. If this file does exist, it is deleted first.This method is not transactional. If it fails and throws an exception, this file will potentially only be partially copied.
- Specified by:
copyFromin interfaceFileObject- Parameters:
srcFile- The source file to copy.selector- The selector to use to select which files to copy.- Throws:
FileSystemException- If this file is read-only, or if the source file does not exist, or on error copying the file.
-
createFile
Description copied from interface:FileObjectCreates this file, if it does not exist. Also creates any ancestor folders which do not exist. This method does nothing if the file already exists and is a file.- Specified by:
createFilein interfaceFileObject- Throws:
FileSystemException- If the file already exists with the wrong type, or the parent folder is read-only, or on error creating this file or one of its ancestors.
-
createFolder
Description copied from interface:FileObjectCreates this folder, if it does not exist. Also creates any ancestor folders which do not exist. This method does nothing if the folder already exists.- Specified by:
createFolderin interfaceFileObject- Throws:
FileSystemException- If the folder already exists with the wrong type, or the parent folder is read-only, or on error creating this folder or one of its ancestors.
-
delete
Description copied from interface:FileObjectDeletes this file. Does nothing if this file does not exist of if it is a folder that has children. Does not delete any descendents of this file, useFileObject.delete(FileSelector)for that.- Specified by:
deletein interfaceFileObject- Returns:
- true if this object has been deleted
- Throws:
FileSystemException- If this file is a non-empty folder, or if this file is read-only, or on error deleteing this file.
-
delete
Description copied from interface:FileObjectDeletes all descendents of this file that match a selector. Does nothing if this file does not exist.This method is not transactional. If it fails and throws an exception, this file will potentially only be partially deleted.
- Specified by:
deletein interfaceFileObject- Parameters:
selector- The selector to use to select which files to delete.- Returns:
- the number of deleted objects
- Throws:
FileSystemException- If this file or one of its descendents is read-only, or on error deleting this file or one of its descendents.
-
exists
Description copied from interface:FileObjectDetermines if this file exists.- Specified by:
existsin interfaceFileObject- Returns:
trueif this file exists,falseif not.- Throws:
FileSystemException- On error determining if this file exists.
-
findFiles
public void findFiles(FileSelector selector, boolean depthwise, List selected) throws FileSystemException Description copied from interface:FileObjectFinds the set of matching descendents of this file.- Specified by:
findFilesin interfaceFileObject- Parameters:
selector- the selector used to determine if the file should be selecteddepthwise- controls the ordering in the list. e.g. deepest firstselected- container for selected files. list needs not to be empty.- Throws:
FileSystemException
-
findFiles
Description copied from interface:FileObjectFinds the set of matching descendents of this file, in depthwise order.- Specified by:
findFilesin interfaceFileObject- Parameters:
selector- The selector to use to select matching files.- Returns:
- The matching files. The files are returned in depthwise order (that is, a child appears in the list before its parent).
- Throws:
FileSystemException
-
getChild
Description copied from interface:FileObjectReturns a child of this file. Note that this method returnsnullwhen the child does not exist. This differs fromFileObject.resolveFile(String, NameScope)which never returns null.- Specified by:
getChildin interfaceFileObject- Parameters:
name- The name of the child.- Returns:
- The child, or null if there is no such child.
- Throws:
FileSystemException- If this file does not exist, or is not a folder, or on error determining this file's children.
-
getChildren
Description copied from interface:FileObjectLists the children of this file.- Specified by:
getChildrenin interfaceFileObject- Returns:
- An array containing the children of this file. The array is unordered. If the file does not have any children, a zero-length array is returned. This method never returns null.
- Throws:
FileSystemException- If this file does not exist, or is not a folder, or on error listing this file's children.
-
getContent
Description copied from interface:FileObjectReturns this file's content. TheFileContentreturned by this method can be used to read and write the content of the file.This method can be called if the file does not exist, and the returned
FileContentcan be used to create the file by writing its content.- Specified by:
getContentin interfaceFileObject- Returns:
- This file's content.
- Throws:
FileSystemException- On error getting this file's content.
-
getFileSystem
Description copied from interface:FileObjectReturns the file system that contains this file.- Specified by:
getFileSystemin interfaceFileObject- Returns:
- The file system.
-
getName
Description copied from interface:FileObjectReturns the name of this file.- Specified by:
getNamein interfaceFileObject
-
getParent
Description copied from interface:FileObjectReturns the folder that contains this file.- Specified by:
getParentin interfaceFileObject- Returns:
- The folder that contains this file. Returns null if this file is the root of a file system.
- Throws:
FileSystemException- On error finding the file's parent.
-
getType
Description copied from interface:FileObjectReturns this file's type.- Specified by:
getTypein interfaceFileObject- Returns:
- One of the
FileTypeconstants. Never returns null. - Throws:
FileSystemException- On error determining the file's type.
-
getURL
Description copied from interface:FileObjectReturns a URL representing this file.- Specified by:
getURLin interfaceFileObject- Throws:
FileSystemException
-
isHidden
Description copied from interface:FileObjectDetermines if this file is hidden.- Specified by:
isHiddenin interfaceFileObject- Returns:
trueif this file is hidden,falseif not.- Throws:
FileSystemException- On error determining if this file exists.
-
isReadable
Description copied from interface:FileObjectDetermines if this file can be read.- Specified by:
isReadablein interfaceFileObject- Returns:
trueif this file is readable,falseif not.- Throws:
FileSystemException- On error determining if this file exists.
-
isWriteable
Description copied from interface:FileObjectDetermines if this file can be written to.- Specified by:
isWriteablein interfaceFileObject- Returns:
trueif this file is writeable,falseif not.- Throws:
FileSystemException- On error determining if this file exists.
-
moveTo
Description copied from interface:FileObjectMove this file.If the destFile exists, it is deleted first
- Specified by:
moveToin interfaceFileObject- Parameters:
destFile- the New filename.- Throws:
FileSystemException- If this file is read-only, or if the source file does not exist, or on error copying the file.
-
resolveFile
Description copied from interface:FileObjectFinds a file, relative to this file. Refer toNameScopefor a description of how names are resolved in the different scopes.- Specified by:
resolveFilein interfaceFileObject- Parameters:
name- The name to resolve.- Returns:
- The file.
- Throws:
FileSystemException- On error parsing the path, or on error finding the file.
-
resolveFile
Description copied from interface:FileObjectFinds a file, relative to this file. Equivalent to callingresolveFile( path, NameScope.FILE_SYSTEM ).- Specified by:
resolveFilein interfaceFileObject- Parameters:
path- The path of the file to locate. Can either be a relative path or an absolute path.- Returns:
- The file.
- Throws:
FileSystemException- On error parsing the path, or on error finding the file.
-
refresh
Description copied from interface:FileObjectThis will prepare the fileObject to get resynchronized with the underlaying filesystem if required- Specified by:
refreshin interfaceFileObject- Throws:
FileSystemException
-
getDecoratedFileObject
-
isAttached
public boolean isAttached()Description copied from interface:FileObjectcheck if the fileObject is attaced- Specified by:
isAttachedin interfaceFileObject
-
isContentOpen
public boolean isContentOpen()Description copied from interface:FileObjectcheck if someone reads/write to this file- Specified by:
isContentOpenin interfaceFileObject
-
toString
-
getFileOperations
- Specified by:
getFileOperationsin interfaceFileObject- Returns:
- FileOperations interface that provides access to the operations API.
- Throws:
FileSystemException
-