org.apache.commons.vfs.provider
Class DelegateFileObject

java.lang.Object
  extended byorg.apache.commons.vfs.provider.AbstractFileObject
      extended byorg.apache.commons.vfs.provider.DelegateFileObject
All Implemented Interfaces:
FileListener, FileObject

public class DelegateFileObject
extends AbstractFileObject
implements FileListener

A file backed by another file.

Version:
$Revision: 480428 $ $Date: 2006-11-29 07:15:24 +0100 (Mi, 29 Nov 2006) $
Author:
Adam Murdoch, Gary D. Gregory

Constructor Summary
DelegateFileObject(FileName name, AbstractFileSystem fileSystem, FileObject file)
           
 
Method Summary
 void attachChild(FileName baseName, FileType type)
          Adds a child to this file.
 void close()
          Close the delegated file
protected  void doCreateFolder()
          Creates this file as a folder.
protected  void doDelete()
          Deletes the file.
protected  Map doGetAttributes()
          Returns the attributes of this file.
protected  Certificate[] doGetCertificates()
          Returns the certificates of this file.
protected  long doGetContentSize()
          Returns the size of the file content (in bytes).
protected  InputStream doGetInputStream()
          Creates an input stream to read the file content from.
protected  long doGetLastModifiedTime()
          Returns the last-modified time of this file.
protected  OutputStream doGetOutputStream(boolean bAppend)
          Creates an output stream to write the file content to.
protected  FileType doGetType()
          Determines the type of the file, returns null if the file does not exist.
protected  boolean doIsHidden()
          Determines if this file is hidden.
protected  boolean doIsReadable()
          Determines if this file can be read.
protected  boolean doIsWriteable()
          Determines if this file can be written to.
protected  String[] doListChildren()
          Lists the children of the file.
protected  void doSetAttribute(String atttrName, Object value)
          Sets an attribute of this file.
protected  void doSetLastModifiedTime(long modtime)
          Sets the last-modified time of this file.
 void fileChanged(FileChangeEvent event)
          Called when a file is changed.
 void fileCreated(FileChangeEvent event)
          Called when a file is created.
 void fileDeleted(FileChangeEvent event)
          Called when a file is deleted.
 void setFile(FileObject file)
          Attaches or detaches the target file.
 
Methods inherited from class org.apache.commons.vfs.provider.AbstractFileObject
canRenameTo, childrenChanged, childrenChanged, copyFrom, createFile, createFolder, delete, delete, doAttach, doDetach, doGetRandomAccessContent, doIsSameFile, doListChildrenResolved, doRename, endOutput, exists, finalize, findFiles, findFiles, getChild, getChildren, getContent, getFileContentInfoFactory, getFileOperations, getFileSystem, getInputStream, getName, getOutputStream, getOutputStream, getParent, getRandomAccessContent, getType, getURL, handleChanged, handleCreate, handleDelete, holdObject, injectType, isAttached, isContentOpen, isHidden, isReadable, isSameFile, isWriteable, moveTo, notifyAllStreamsClosed, onChange, onChildrenChanged, refresh, resolveFile, resolveFile, toString
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DelegateFileObject

public DelegateFileObject(FileName name,
                          AbstractFileSystem fileSystem,
                          FileObject file)
                   throws FileSystemException
Method Detail

attachChild

public void attachChild(FileName baseName,
                        FileType type)
                 throws Exception
Adds a child to this file.

Throws:
Exception

setFile

public void setFile(FileObject file)
             throws Exception
Attaches or detaches the target file.

Throws:
Exception

doGetType

protected FileType doGetType()
                      throws FileSystemException
Determines the type of the file, returns null if the file does not exist.

Specified by:
doGetType in class AbstractFileObject
Throws:
FileSystemException

doIsReadable

protected boolean doIsReadable()
                        throws FileSystemException
Determines if this file can be read.

Overrides:
doIsReadable in class AbstractFileObject
Throws:
FileSystemException

doIsWriteable

protected boolean doIsWriteable()
                         throws FileSystemException
Determines if this file can be written to.

Overrides:
doIsWriteable in class AbstractFileObject
Throws:
FileSystemException

doIsHidden

protected boolean doIsHidden()
                      throws FileSystemException
Determines if this file is hidden.

Overrides:
doIsHidden in class AbstractFileObject
Throws:
FileSystemException

doListChildren

protected String[] doListChildren()
                           throws Exception
Lists the children of the file.

Specified by:
doListChildren in class AbstractFileObject
Throws:
Exception

doCreateFolder

protected void doCreateFolder()
                       throws Exception
Creates this file as a folder.

Overrides:
doCreateFolder in class AbstractFileObject
Throws:
Exception

doDelete

protected void doDelete()
                 throws Exception
Deletes the file.

Overrides:
doDelete in class AbstractFileObject
Throws:
Exception

doGetContentSize

protected long doGetContentSize()
                         throws Exception
Returns the size of the file content (in bytes). Is only called if doGetType() returns FileType.FILE.

Specified by:
doGetContentSize in class AbstractFileObject
Throws:
Exception

doGetAttributes

protected Map doGetAttributes()
                       throws Exception
Returns the attributes of this file.

Overrides:
doGetAttributes in class AbstractFileObject
Throws:
Exception

doSetAttribute

protected void doSetAttribute(String atttrName,
                              Object value)
                       throws Exception
Sets an attribute of this file.

Overrides:
doSetAttribute in class AbstractFileObject
Throws:
Exception

doGetCertificates

protected Certificate[] doGetCertificates()
                                   throws Exception
Returns the certificates of this file.

Overrides:
doGetCertificates in class AbstractFileObject
Throws:
Exception

doGetLastModifiedTime

protected long doGetLastModifiedTime()
                              throws Exception
Returns the last-modified time of this file.

Overrides:
doGetLastModifiedTime in class AbstractFileObject
Throws:
Exception

doSetLastModifiedTime

protected void doSetLastModifiedTime(long modtime)
                              throws Exception
Sets the last-modified time of this file.

Overrides:
doSetLastModifiedTime in class AbstractFileObject
Throws:
Exception

doGetInputStream

protected InputStream doGetInputStream()
                                throws Exception
Creates an input stream to read the file content from.

Specified by:
doGetInputStream in class AbstractFileObject
Throws:
Exception

doGetOutputStream

protected OutputStream doGetOutputStream(boolean bAppend)
                                  throws Exception
Creates an output stream to write the file content to.

Overrides:
doGetOutputStream in class AbstractFileObject
Throws:
Exception

fileCreated

public void fileCreated(FileChangeEvent event)
                 throws Exception
Called when a file is created.

Specified by:
fileCreated in interface FileListener
Throws:
Exception

fileDeleted

public void fileDeleted(FileChangeEvent event)
                 throws Exception
Called when a file is deleted.

Specified by:
fileDeleted in interface FileListener
Throws:
Exception

fileChanged

public void fileChanged(FileChangeEvent event)
                 throws Exception
Called when a file is changed.

This will only happen if you monitor the file using FileMonitor.

Specified by:
fileChanged in interface FileListener
Throws:
Exception

close

public void close()
           throws FileSystemException
Close the delegated file

Specified by:
close in interface FileObject
Overrides:
close in class AbstractFileObject
Throws:
FileSystemException


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