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.


Variable Index

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

Constructor Index

 o FileResource()

Method Index

 o checkContent()
Check this file content, and update attributes if needed.
 o getBackupFile()
Get the name of the backup file for this resource.
 o getBackupFlag()
Get the backup flag, create a backup file when content change if true.
 o getFile()
Get this file resource file name.
 o getFileLength()
Get this file length
 o getFilename()
Get this resource filename attribute.
 o getFileStamp()
Get the date at which we last examined the file.
 o initialize(Object[])
Initialize the FileResource instance.
 o newContent(InputStream)
Save the given stream as the underlying file content.
 o setValue(int, Object)
Set some of this resource attribute.
 o updateAttributes()
Update our computed attributes.
 o updateFileAttributes()
Update the file related attributes.
 o 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.

Variables

 o ATTR_FILENAME
 protected static int ATTR_FILENAME
Attributes index - The filename attribute.

 o ATTR_FILESTAMP
 protected static int ATTR_FILESTAMP
Attribute index - The date at which we last checked the file content.

 o ATTR_FILE_LENGTH
 protected static int ATTR_FILE_LENGTH
Attribute index - The index for the content length attribute.

 o ATTR_FILE_BACKUP
 protected static int ATTR_FILE_BACKUP
Attribute index - The index for the backup flag

 o 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.

Constructors

 o FileResource
 public FileResource()

Methods

 o getFilename
 public String getFilename()
Get this resource filename attribute.

 o getFileLength
 public int getFileLength()
Get this file length

 o getFileStamp
 public long getFileStamp()
Get the date at which we last examined the file.

 o getBackupFlag
 public boolean getBackupFlag()
Get the backup flag, create a backup file when content change if true.

 o 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.
 o 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.
 o 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.
 o 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
 o getFile
 public synchronized File getFile()
Get this file resource file name.

Returns:
a File instance.
Throws: InvalidParentException
If no parent is available, and then the FileReource is unable to get its file.
 o 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.

Returns:
true if that resource is wrapping an existing file
Throws: MultipleLockException
When the resource try to delete itself (because there is no more file)
 o 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.

 o updateAttributes
 public void updateAttributes()
Update our computed attributes.

Overrides:
updateAttributes in class Resource
 o initialize
 public void initialize(Object values[])
Initialize the FileResource instance.

Overrides:
initialize in class FramedResource

All Packages  Class Hierarchy  This Package  Previous  Next  Index