org.w3c.jigsaw.zip
Class ZipFileResource

java.lang.Object
  extended by org.w3c.tools.resources.AttributeHolder
      extended by org.w3c.tools.resources.Resource
          extended by org.w3c.tools.resources.FramedResource
              extended by org.w3c.tools.resources.FileResource
                  extended by org.w3c.jigsaw.zip.ZipFileResource
All Implemented Interfaces:
java.lang.Cloneable, java.util.EventListener, FrameEventListener

public class ZipFileResource
extends FileResource


Field Summary
protected static int ATTR_ENTRYPATH
          Attribute index - The index for our entry path.
protected static int ATTR_ZIPFILE
          Attributes index - The filename attribute.
 
Fields inherited from class org.w3c.tools.resources.FileResource
ATTR_FILE_BACKUP, ATTR_FILE_LENGTH, ATTR_FILENAME, ATTR_FILESTAMP, file
 
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, co, id
 
Fields inherited from class org.w3c.tools.resources.AttributeHolder
attributes, values
 
Constructor Summary
ZipFileResource()
           
 
Method Summary
 java.lang.String getEntryPath()
           
protected  long getEntrySize()
           
 java.io.File getFile()
          Get this zip file.
protected  java.io.InputStream getInputStream()
           
protected  boolean hasEntry()
           
 boolean newContent(java.io.InputStream in)
          Save the given stream as the underlying file content.
 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.FileResource
checkContent, getBackupFile, getBackupFlag, getFileLength, getFilename, getFileStamp, initialize, setValue, updateAttributes
 
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, initialize, isInitialized, isUnloaded, pickleValues, setContext, setContext, setValue, unsafeGetContext, unsafeGetFrame, unsafeGetFrames, unsafeGetIdentifier, unsafeGetResourceReference, unsafeGetURLPath, unsafeGetValue
 
Methods inherited from class org.w3c.tools.resources.AttributeHolder
definesAttribute, definesAttribute, getAttributes, getBoolean, getChar, getClone, getClone, getDouble, getFloat, getInt, getLong, getString, getValue, lookupAttribute, print, setBoolean, setChar, setDouble, setFloat, setInt, setLong, setString, setValue, unsafeDefinesAttribute, unsafeGetDouble, unsafeGetString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ATTR_ZIPFILE

protected static int ATTR_ZIPFILE
Attributes index - The filename attribute.


ATTR_ENTRYPATH

protected static int ATTR_ENTRYPATH
Attribute index - The index for our entry path.

Constructor Detail

ZipFileResource

public ZipFileResource()
Method Detail

getFile

public java.io.File getFile()
Get this zip file.

Overrides:
getFile in class FileResource
Returns:
a File instance.

getEntryPath

public java.lang.String getEntryPath()

getInputStream

protected java.io.InputStream getInputStream()

getEntrySize

protected long getEntrySize()

hasEntry

protected boolean hasEntry()

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.

Overrides:
updateFileAttributes in class FileResource

verify

public 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 FileResource
Returns:
A boolean.

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.

Overrides:
newContent in class FileResource
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.