Class w3c.jigsaw.resources.FileResource
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class w3c.jigsaw.resources.FileResource

java.lang.Object
   |
   +----w3c.tools.store.AttributeHolder
           |
           +----w3c.tools.store.Resource
                   |
                   +----w3c.jigsaw.resources.HTTPResource
                           |
                           +----w3c.jigsaw.resources.FilteredResource
                                   |
                                   +----w3c.jigsaw.resources.FileResource

public class FileResource
extends FilteredResource

Variable Index

 o ATTR_FILENAME
Attributes index - The filename attribute.
 o ATTR_FILESTAMP
Attribute index - The date at which we last checked the file content.
 o ATTR_PUTABLE
Attribute index - Do we allow PUT method on this file.
 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 checkIfMatch(Request)
Check the If-Match condition of that request.
 o checkIfModifiedSince(Request)
Check the If-Modified-Since condition of that request.
 o checkIfNoneMatch(Request)
Check the If-None-Match condition of that request.
 o checkIfUnmodifiedSince(Request)
Check the If-Unmodified-Since condition of that request.
 o createDefaultReply(Request, int)
Create a reply to answer to request on this file.
 o get(Request)
The GET method on files.
 o getBackupFile()
Get the name of the backup file for this resource.
 o getFile()
Get this file resource file name.
 o getFilename()
Get this resource filename attribute.
 o getFileStamp()
Get the date at which we last examined the file.
 o getPutableFlag()
Get the PUT'able flag (are we allow to PUT to the resource ?)
 o head(Request)
The HEAD method on files, and their sub-classes.
 o initialize(Object[])
Initialize the FileResource instance.
 o newContent(InputStream)
Save the given stream as the underlying file content.
 o put(Request)
Put a new entity in this resource.
 o setValue(int, Object)
Set some of this resource attribute.
 o updateAttributes()
Update our computed attributes.
 o updateCachedHeaders()
Uupdate the cached headers for this resource.
 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_PUTABLE
  protected static int ATTR_PUTABLE
Attribute index - Do we allow PUT method on this file.
 o ATTR_FILESTAMP
  protected static int ATTR_FILESTAMP
Attribute index - The date at which we last checked the file content.
 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 getPutableFlag
  public boolean getPutableFlag()
Get the PUT'able flag (are we allow to PUT to the resource ?)
 o getFileStamp
  public long getFileStamp()
Get the date at which we last examined the file.
 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
  protected 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
  protected 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 updateCachedHeaders
  protected void updateCachedHeaders()
Uupdate the cached headers for this resource.
Overrides:
updateCachedHeaders in class HTTPResource
 o createDefaultReply
  public Reply createDefaultReply(Request request,
                                  int status)
Create a reply to answer to request on this file. This method will create a suitable reply (matching the given request) and will set all its default header values to the appropriate values.
Parameters:
request - The request to make a reply for.
Returns:
An instance of Reply, suited to answer this request.
Overrides:
createDefaultReply in class HTTPResource
 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 HTTPResource
 o getFile
  public synchronized File getFile()
Get this file resource file name.
 o checkIfMatch
  public int checkIfMatch(Request request)
Check the If-Match condition of that request.
Overrides:
checkIfMatch in class HTTPResource
 o checkIfNoneMatch
  public int checkIfNoneMatch(Request request)
Check the If-None-Match condition of that request.
Overrides:
checkIfNoneMatch in class HTTPResource
 o checkIfModifiedSince
  public int checkIfModifiedSince(Request request)
Check the If-Modified-Since condition of that request.
Overrides:
checkIfModifiedSince in class HTTPResource
 o checkIfUnmodifiedSince
  public int checkIfUnmodifiedSince(Request request)
Check the If-Unmodified-Since condition of that request.
Overrides:
checkIfUnmodifiedSince in class HTTPResource
 o head
  public Reply head(Request request)
The HEAD method on files, and their sub-classes.
Returns:
A Reply instance.
Overrides:
head in class HTTPResource
 o get
  public Reply get(Request request) throws HTTPException
The GET method on files. Check for the last modified time against the IMS if any. If OK, emit a not modified reply, otherwise, emit the whole file.
Parameters:
request - The request to handle.
Throws: HTTPException
If some error occured.
Overrides:
get in class HTTPResource
 o verify
  public synchronized boolean 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.
Overrides:
verify in class HTTPResource
 o put
  public synchronized Reply put(Request request) throws HTTPException, ClientException
Put a new entity in this resource.
Parameters:
request - The request to handle.
Overrides:
put in class HTTPResource
 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 AttributeHolder

All Packages  Class Hierarchy  This Package  Previous  Next  Index