: Class FileResource

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.w3c.tools.resources
Class FileResource

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

Direct Known Subclasses:
  HttpFileResource, ImageFileResource, MapResource, ZipFileResource

public class FileResource
extends FramedResource

A simple file resource.

Field Summary
`protected static int` | `ATTR_FILE_BACKUP` Attribute index - The index for the backup flag
`protected static int` | `ATTR_FILE_LENGTH` Attribute index - The index for the content length attribute.
`protected static int` | `ATTR_FILENAME` Attributes index - The filename attribute.
`protected static int` | `ATTR_FILESTAMP` Attribute index - The date at which we last checked the file content.
`protected java.io.File` | `file` The file we refer to.

Fields inherited from class org.w3c.tools.resources.FramedResource
`ATTR_OID, attrListener, debugEvent, event_disabled, framesRef, structListener`

Fields inherited from class org.w3c.tools.resources.Resource
`ATTR_CONTEXT, ATTR_HELP_URL, ATTR_IDENTIFIER, ATTR_LAST_MODIFIED, ATTR_PARENT, ATTR_RESOURCE_FRAMES, ATTR_STORE_ENTRY, ATTR_URL`

Fields inherited from class org.w3c.tools.resources.AttributeHolder
`attributes, slowpickle, values`

Constructor Summary
`FileResource()`

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

Methods inherited from class org.w3c.tools.resources.FramedResource
`addAttributeChangedListener, addStructureChangedListener, collectFramesReference, delete, disableEvent, displayEvent, enableEvent, eventDisabled, fireAttributeChangeEvent, fireStructureChangedEvent, fireStructureChangedEvent, frameAdded, frameModified, frameRemoved, getClone, getFrame, getFrame, getFrameReference, getFrameReference, getFramesReference, getOid, lookup, markModified, notifyUnload, perform, performFrames, postAttributeChangeEvent, postEvent, postStructureChangedEvent, postStructureChangedEvent, processEvent, registerFrame, registerFrameIfNone, removeAttributeChangedListener, removeStructureChangedListener, setSilentValue, setSilentValue, unregisterFrame`

Methods inherited from class org.w3c.tools.resources.Resource
`acceptUnload, checkMultipleLock, collectFrames, getContext, getFrame, getFrames, getHelpURL, getHelpURL, getIdentifier, getLastModified, getParent, getResourceReference, getServer, getSpace, getSpaceEntry, getStoreEntry, getURLPath, getValue, getValue, isInitialized, isUnloaded, setContext, setContext, setValue`

Methods inherited from class org.w3c.tools.resources.AttributeHolder
`definesAttribute, definesAttribute, getAttributes, getBoolean, getChar, getClone, getClone, getDouble, getFloat, getInt, getLong, getString, getValue, initialize, lookupAttribute, pickle, print, setBoolean, setChar, setDouble, setFloat, setInt, setLong, setString, setValue, unpickle, unpickle, unpickle, unpickleInstance, unpickleInstance`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

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

### ATTR_FILE_BACKUP

    protected static int ATTR_FILE_BACKUP

  Attribute index - The index for the backup flag

### file

    protected java.io.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.

Constructor Detail

### FileResource

    public FileResource()

Method Detail

### getFilename

    public java.lang.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.

### getBackupFlag

    public boolean getBackupFlag()

  Get the backup flag, create a backup file when content change if true.

### getBackupFile

    public java.io.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 boolean newContent(java.io.InputStream in)
                       throws java.io.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:
    java.io.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 void setValue(int idx,
                         java.lang.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
  Tags copied from class: Resource
  Parameters:
    `idx` - The index of the attribute to modify.
    `value` - The new attribute value.

### getFile

    public java.io.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.

### verify

    public 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)

### 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(java.lang.Object[] values)

  Initialize the FileResource instance.
  Overrides:
    initialize in class FramedResource
  Tags copied from class: FramedResource
  Parameters:
    `values` - Default attribute values.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD