    All Packages  Class Hierarchy  This Package  Previous  Next  Index

# Class org.w3c.tools.resources.FileResource

    java.lang.Object
       |
       +----org.w3c.tools.resources.AttributeHolder
               |
               +----org.w3c.tools.resources.Resource
                       |
                       +----org.w3c.tools.resources.FramedResource
                               |
                               +----org.w3c.tools.resources.FileResource

public class FileResource
extends FramedResource

A simple file resource.

##

ATTR_FILE_LENGTH
  Attribute index - The index for the content length attribute.
ATTR_FILENAME
  Attributes index - The filename attribute.
ATTR_FILESTAMP
  Attribute index - The date at which we last checked the file content.
file
  The file we refer to.

##

FileResource()

##

checkContent()
  Check this file content, and update attributes if needed.
getBackupFile()
  Get the name of the backup file for this resource.
getFile()
  Get this file resource file name.
getFileLength()
  Get this file length
getFilename()
  Get this resource filename attribute.
getFileStamp()
  Get the date at which we last examined the file.
initialize(Object[])
  Initialize the FileResource instance.
newContent(InputStream)
  Save the given stream as the underlying file content.
setValue(int, Object)
  Set some of this resource attribute.
updateAttributes()
  Update our computed attributes.
updateFileAttributes()
  Update the file related attributes.
verify()
  Is that resource still wrapping an existing file ? If the underlying file has disappeared and if the container directory is extensible, remove the resource.

##

ATTR_FILENAME

     protected static int ATTR_FILENAME

  Attributes index - The filename attribute.

ATTR_FILESTAMP

     protected static int ATTR_FILESTAMP

  Attribute index - The date at which we last checked the file content.

ATTR_FILE_LENGTH

     protected static int ATTR_FILE_LENGTH

  Attribute index - The index for the content length attribute.

file

     protected File file

  The file we refer to. This is a cached version of some attributes, so we need to override the setValue method in order to be able to catch any changes to it.

##

FileResource

     public FileResource()

##

getFilename

     public String getFilename()

  Get this resource filename attribute.

getFileLength

     public int getFileLength()

  Get this file length

getFileStamp

     public long getFileStamp()

  Get the date at which we last examined the file.

getBackupFile

     public File getBackupFile()

  Get the name of the backup file for this resource.

  Returns:
    A File object suitable to receive the backup version of this file.

newContent

     public synchronized boolean newContent(InputStream in) throws IOException

  Save the given stream as the underlying file content. This method preserve the old file version in a `~` file.

  Parameters:
    in - The input stream to use as the resource entity.
  Returns:
    A boolean, true if the resource was just created, false otherwise.
  Throws: IOException
    If dumping the content failed.

checkContent

     public long checkContent()

  Check this file content, and update attributes if needed. This method is normally called before any perform request is done, so that we make sure that all meta-informations is up to date before handling a request.

  Returns:
    The time of the last update to the resource.

setValue

     public synchronized void setValue(int idx,
                                       Object value)

  Set some of this resource attribute. We just catch here any write access to the filename's, to update our cache file object.

  Overrides:
    setValue in class FramedResource

getFile

     public synchronized File getFile()

  Get this file resource file name.

verify

     public synchronized boolean verify() throws MultipleLockException

  Is that resource still wrapping an existing file ? If the underlying file has disappeared and if the container directory is extensible, remove the resource.

updateFileAttributes

     public void updateFileAttributes()

  Update the file related attributes. The file we serve has changed since the last time we checked it, if any of the attribute values depend on the file content, this is the appropriate place to recompute them.

updateAttributes

     public void updateAttributes()

  Update our computed attributes.

  Overrides:
    updateAttributes in class Resource

initialize

     public void initialize(Object values[])

  Initialize the FileResource instance.

  Overrides:
    initialize in class FramedResource

    All Packages  Class Hierarchy  This Package  Previous  Next  Index