org.apache.commons.vfs.impl
Class SynchronizedFileObject

java.lang.Object
  extended byorg.apache.commons.vfs.impl.DecoratedFileObject
      extended byorg.apache.commons.vfs.impl.SynchronizedFileObject
All Implemented Interfaces:
FileObject

public class SynchronizedFileObject
extends DecoratedFileObject

This decorator synchronize all access to the FileObject

Version:
$Revision: 485638 $ $Date: 2006-12-11 13:20:55 +0100 (Mo, 11 Dez 2006) $
Author:
Mario Ivankovits

Constructor Summary
SynchronizedFileObject(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, List selected)
          Finds the set of matching descendents of this file.
 FileObject getChild(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(String path)
          Finds a file, relative to this file.
 FileObject resolveFile(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

SynchronizedFileObject

public SynchronizedFileObject(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

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
Throws:
FileSystemException

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

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

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
Throws:
FileSystemException

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
Throws:
FileSystemException

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
Throws:
FileSystemException

findFiles

public void findFiles(FileSelector selector,
                      boolean depthwise,
                      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
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
Throws:
FileSystemException

getChild

public FileObject getChild(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
Throws:
FileSystemException

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
Throws:
FileSystemException

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
Throws:
FileSystemException

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
Throws:
FileSystemException

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
Throws:
FileSystemException

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
Throws:
FileSystemException

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
Throws:
FileSystemException

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
Throws:
FileSystemException

resolveFile

public FileObject resolveFile(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
Throws:
FileSystemException

resolveFile

public FileObject resolveFile(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
Throws:
FileSystemException


Copyright © 2002-2006 The Apache Software Foundation. All Rights Reserved.