org.apache.commons.vfs.cache
Class OnCallRefreshFileObject

java.lang.Object
  extended by org.apache.commons.vfs.impl.DecoratedFileObject
      extended by org.apache.commons.vfs.cache.OnCallRefreshFileObject
All Implemented Interfaces:
FileObject

public class OnCallRefreshFileObject
extends DecoratedFileObject

This decorator refreshes the fileObject data on every call

Version:
$Revision: 480428 $ $Date: 2006-11-29 07:15:24 +0100 (Mi, 29 Nov 2006) $
Author:
Mario Ivankovits

Constructor Summary
OnCallRefreshFileObject(FileObject fileObject)
           
 
Method Summary
 void close()
          Closes this file, and its content.
 void copyFrom(FileObject srcFile, FileSelector selector)
          Copies another file, and all its descendents, to this file.
 void createFile()
          Creates this file, if it does not exist.
 void createFolder()
          Creates this folder, if it does not exist.
 boolean delete()
          Deletes this file.
 int delete(FileSelector selector)
          Deletes all descendents of this file that match a selector.
 boolean exists()
          Determines if this file exists.
 FileObject[] findFiles(FileSelector selector)
          Finds the set of matching descendents of this file, in depthwise order.
 void findFiles(FileSelector selector, boolean depthwise, java.util.List selected)
          Finds the set of matching descendents of this file.
 FileObject getChild(java.lang.String name)
          Returns a child of this file.
 FileObject[] getChildren()
          Lists the children of this file.
 FileContent getContent()
          Returns this file's content.
 FileType getType()
          Returns this file's type.
 boolean isHidden()
          Determines if this file is hidden.
 boolean isReadable()
          Determines if this file can be read.
 boolean isWriteable()
          Determines if this file can be written to.
 void moveTo(FileObject destFile)
          Move this file.
 FileObject resolveFile(java.lang.String path)
          Finds a file, relative to this file.
 FileObject resolveFile(java.lang.String name, NameScope scope)
          Finds a file, relative to this file.
 
Methods inherited from class org.apache.commons.vfs.impl.DecoratedFileObject
canRenameTo, getDecoratedFileObject, getFileOperations, getFileSystem, getName, getParent, getURL, isAttached, isContentOpen, refresh, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

OnCallRefreshFileObject

public OnCallRefreshFileObject(FileObject fileObject)
Method Detail

close

public void close()
           throws FileSystemException
Description copied from interface: FileObject
Closes 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:
close in interface FileObject
Overrides:
close in class DecoratedFileObject
Throws:
FileSystemException - On error closing the file.
See Also:
FileContent.close()

copyFrom

public void copyFrom(FileObject srcFile,
                     FileSelector selector)
              throws FileSystemException
Description copied from interface: FileObject
Copies 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:
copyFrom in interface FileObject
Overrides:
copyFrom in class DecoratedFileObject
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

public void createFile()
                throws FileSystemException
Description copied from interface: FileObject
Creates 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:
createFile in interface FileObject
Overrides:
createFile in class DecoratedFileObject
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

public void createFolder()
                  throws FileSystemException
Description copied from interface: FileObject
Creates 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:
createFolder in interface FileObject
Overrides:
createFolder in class DecoratedFileObject
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

public boolean delete()
               throws FileSystemException
Description copied from interface: FileObject
Deletes 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, use FileObject.delete(FileSelector) for that.

Specified by:
delete in interface FileObject
Overrides:
delete in class DecoratedFileObject
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

public int delete(FileSelector selector)
           throws FileSystemException
Description copied from interface: FileObject
Deletes 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:
delete in interface FileObject
Overrides:
delete in class DecoratedFileObject
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

public boolean exists()
               throws FileSystemException
Description copied from interface: FileObject
Determines if this file exists.

Specified by:
exists in interface FileObject
Overrides:
exists in class DecoratedFileObject
Returns:
true if this file exists, false if not.
Throws:
FileSystemException - On error determining if this file exists.

findFiles

public void findFiles(FileSelector selector,
                      boolean depthwise,
                      java.util.List selected)
               throws FileSystemException
Description copied from interface: FileObject
Finds the set of matching descendents of this file.

Specified by:
findFiles in interface FileObject
Overrides:
findFiles in class DecoratedFileObject
Parameters:
selector - the selector used to determine if the file should be selected
depthwise - controls the ordering in the list. e.g. deepest first
selected - container for selected files. list needs not to be empty.
Throws:
FileSystemException

findFiles

public FileObject[] findFiles(FileSelector selector)
                       throws FileSystemException
Description copied from interface: FileObject
Finds the set of matching descendents of this file, in depthwise order.

Specified by:
findFiles in interface FileObject
Overrides:
findFiles in class DecoratedFileObject
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

public FileObject getChild(java.lang.String name)
                    throws FileSystemException
Description copied from interface: FileObject
Returns a child of this file. Note that this method returns null when the child does not exist. This differs from FileObject.resolveFile( String, NameScope) which never returns null.

Specified by:
getChild in interface FileObject
Overrides:
getChild in class DecoratedFileObject
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

public FileObject[] getChildren()
                         throws FileSystemException
Description copied from interface: FileObject
Lists the children of this file.

Specified by:
getChildren in interface FileObject
Overrides:
getChildren in class DecoratedFileObject
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

public FileContent getContent()
                       throws FileSystemException
Description copied from interface: FileObject
Returns this file's content. The FileContent returned 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 FileContent can be used to create the file by writing its content.

Specified by:
getContent in interface FileObject
Overrides:
getContent in class DecoratedFileObject
Returns:
This file's content.
Throws:
FileSystemException - On error getting this file's content.

getType

public FileType getType()
                 throws FileSystemException
Description copied from interface: FileObject
Returns this file's type.

Specified by:
getType in interface FileObject
Overrides:
getType in class DecoratedFileObject
Returns:
One of the FileType constants. Never returns null.
Throws:
FileSystemException - On error determining the file's type.

isHidden

public boolean isHidden()
                 throws FileSystemException
Description copied from interface: FileObject
Determines if this file is hidden.

Specified by:
isHidden in interface FileObject
Overrides:
isHidden in class DecoratedFileObject
Returns:
true if this file is hidden, false if not.
Throws:
FileSystemException - On error determining if this file exists.

isReadable

public boolean isReadable()
                   throws FileSystemException
Description copied from interface: FileObject
Determines if this file can be read.

Specified by:
isReadable in interface FileObject
Overrides:
isReadable in class DecoratedFileObject
Returns:
true if this file is readable, false if not.
Throws:
FileSystemException - On error determining if this file exists.

isWriteable

public boolean isWriteable()
                    throws FileSystemException
Description copied from interface: FileObject
Determines if this file can be written to.

Specified by:
isWriteable in interface FileObject
Overrides:
isWriteable in class DecoratedFileObject
Returns:
true if this file is writeable, false if not.
Throws:
FileSystemException - On error determining if this file exists.

moveTo

public void moveTo(FileObject destFile)
            throws FileSystemException
Description copied from interface: FileObject
Move this file.

If the destFile exists, it is deleted first

Specified by:
moveTo in interface FileObject
Overrides:
moveTo in class DecoratedFileObject
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

public FileObject resolveFile(java.lang.String name,
                              NameScope scope)
                       throws FileSystemException
Description copied from interface: FileObject
Finds a file, relative to this file. Refer to NameScope for a description of how names are resolved in the different scopes.

Specified by:
resolveFile in interface FileObject
Overrides:
resolveFile in class DecoratedFileObject
Parameters:
name - The name to resolve.
Returns:
The file.
Throws:
FileSystemException - On error parsing the path, or on error finding the file.

resolveFile

public FileObject resolveFile(java.lang.String path)
                       throws FileSystemException
Description copied from interface: FileObject
Finds a file, relative to this file. Equivalent to calling resolveFile( path, NameScope.FILE_SYSTEM ).

Specified by:
resolveFile in interface FileObject
Overrides:
resolveFile in class DecoratedFileObject
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.