org.w3c.jigsaw.ssi
Class SSIFrame

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.ResourceFrame
                  extended by org.w3c.tools.resources.ProtocolFrame
                      extended by org.w3c.jigsaw.frames.HTTPFrame
                          extended by org.w3c.jigsaw.ssi.SSIFrame
All Implemented Interfaces:
java.lang.Cloneable, java.util.EventListener, AttributeChangedListener, FrameEventListener

public class SSIFrame
extends HTTPFrame

This resource implements server-side parsing of HTML documents. Any comment of the form <!--#commandName param1=val1 ... paramn=valn --> will be interpreted as an include directive.

Commands are looked up in an instance of the class supplied in the registryClass attribute, which must be a subclass of org.w3c.jigsaw.ssi.CommandRegistry.

See Also:
CommandRegistry, Command

Field Summary
static boolean debug
           
static java.lang.String STATE_DEPTH
          Message state - the current recursion depth
static java.lang.String STATE_VARIABLES
          Message state - the current variables
protected  java.util.Dictionary vars
          Our "very global" variables
 
Fields inherited from class org.w3c.jigsaw.frames.HTTPFrame
acceptRanges, allowed, ATTR_ALLOW_DEL, ATTR_BROWSABLE, ATTR_CHARSET, ATTR_CONTENT_ENCODING, ATTR_CONTENT_LANGUAGE, ATTR_CONTENT_LENGTH, ATTR_CONTENT_TYPE, ATTR_ICON, ATTR_ICONDIR, ATTR_INDEX, ATTR_INDEXES, ATTR_MAXAGE, ATTR_MD5, ATTR_PUTABLE, ATTR_QUALITY, ATTR_RELOCATE, ATTR_STYLE_LINK, ATTR_TITLE, browsetype, COND_FAILED, COND_OK, COND_WEAK, dresource, fresource, listing, listing_stamp, STATE_CONTENT_LOCATION
 
Fields inherited from class org.w3c.tools.resources.ResourceFrame
filterClass, frameListener, resource
 
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
SSIFrame()
           
 
Method Summary
 void attributeChanged(AttributeChangedEvent evt)
          Listen its resource.
static boolean byteArrayNEquals(byte[] ba1, int off1, byte[] ba2, int off2, int n)
          Analogous to standard C's strncmp, for byte arrays.
protected  boolean cacheReplies()
           
 Reply createCommandReply(Request request, int status)
           
 Reply createDefaultReply(Request request, int status)
          Create a reply to answer to request on this file.
protected  void doNotCacheReply()
           
protected  Reply getFileResource(Request request)
          Perform a get (associated with a FileResource)
 long getLastModified()
          Get this resource last modification time.
 Reply handle(Request request)
          Handles all relevant HTTP methods.
 ReplyInterface perform(RequestInterface request)
          Makes sure that checkContent() is called on _any_ HTTP method, so that the internal representation of commands is always consistent.
 Reply post(Request request)
          Perform a post.
 
Methods inherited from class org.w3c.jigsaw.frames.HTTPFrame
addStyleSheet, browse, checkExpect, checkIfMatch, checkIfModifiedSince, checkIfNoneMatch, checkIfUnmodifiedSince, checkRequest, checkValidators, computeContainerListing, computeETag, computeTrashDir, computeTrashFile, createFileReply, delete, deleteDirectoryResource, deleteFileResource, deleteMe, deleteOtherResource, extended, get, getAllow, getAllowDeleteFlag, getBrowsableFlag, getBrowseType, getCharset, getContentEncoding, getContentLanguage, getContentLength, getContentType, getDirectoryListing, getDirectoryResource, getDirectoryResource, getETag, getFileResource, getHelpURL, getHelpURL, getIcon, getIconDirectory, getIndex, getIndexes, getMaxAge, getMD5Flag, getOtherResource, getPutableFlag, getQuality, getRelocateFlag, getStyleSheetURL, getTitle, getURL, handleRangeRequest, head, headDirectoryResource, headFileResource, headOtherResource, initialize, link, lookup, lookupDirectory, lookupFile, lookupOther, lookupResource, options, performFrames, pickleValues, put, putFileResource, putOtherResource, registerOtherResource, registerResource, setValue, trace, unlink, unsafeGetQuality, updateCachedHeaders
 
Methods inherited from class org.w3c.tools.resources.ResourceFrame
addFrameEventListener, eventDisabled, fireFrameEvent, frameModified, getFilters, getFilters, getFrameReference, getResource, getResourceReference, getSpaceEntry, getURLPath, lookupFilters, lookupFrames, postFrameEvent, processEvent, removeFrameEventListener, unregisterResource, updateDefaultChildAttributes
 
Methods inherited from class org.w3c.tools.resources.FramedResource
addAttributeChangedListener, addStructureChangedListener, collectFramesReference, delete, disableEvent, displayEvent, enableEvent, fireAttributeChangeEvent, fireStructureChangedEvent, fireStructureChangedEvent, frameAdded, frameRemoved, getClone, getFrame, getFrame, getFrameReference, getFrameReference, getFramesReference, getOid, initialize, markModified, notifyUnload, postAttributeChangeEvent, postEvent, postStructureChangedEvent, postStructureChangedEvent, registerFrame, registerFrameIfNone, removeAttributeChangedListener, removeStructureChangedListener, setSilentValue, setSilentValue, unregisterFrame
 
Methods inherited from class org.w3c.tools.resources.Resource
acceptUnload, checkMultipleLock, collectFrames, getContext, getFrame, getFrames, getIdentifier, getParent, getServer, getSpace, getStoreEntry, getValue, getValue, isInitialized, isUnloaded, setContext, setContext, setValue, unsafeGetContext, unsafeGetFrame, unsafeGetFrames, unsafeGetIdentifier, unsafeGetResourceReference, unsafeGetURLPath, unsafeGetValue, updateAttributes
 
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

debug

public static final boolean debug
See Also:
Constant Field Values

vars

protected java.util.Dictionary vars
Our "very global" variables


STATE_DEPTH

public static final java.lang.String STATE_DEPTH
Message state - the current recursion depth

See Also:
Constant Field Values

STATE_VARIABLES

public static final java.lang.String STATE_VARIABLES
Message state - the current variables

See Also:
Constant Field Values
Constructor Detail

SSIFrame

public SSIFrame()
Method Detail

doNotCacheReply

protected void doNotCacheReply()

cacheReplies

protected boolean cacheReplies()

attributeChanged

public void attributeChanged(AttributeChangedEvent evt)
Listen its resource.

Specified by:
attributeChanged in interface AttributeChangedListener
Overrides:
attributeChanged in class HTTPFrame
Parameters:
evt - The AttributeChangeEvent describing the change.

perform

public ReplyInterface perform(RequestInterface request)
                       throws ProtocolException,
                              ResourceException
Makes sure that checkContent() is called on _any_ HTTP method, so that the internal representation of commands is always consistent.

Overrides:
perform in class HTTPFrame
Parameters:
request - The HTTPRequest
filters - The filters to apply
Returns:
a ReplyInterface instance
Throws:
ProtocolException - If processing the request failed.
ResourceException - If this resource got a fatal error.

getFileResource

protected Reply getFileResource(Request request)
                         throws ProtocolException,
                                ResourceException
Perform a get (associated with a FileResource)

Overrides:
getFileResource in class HTTPFrame
Parameters:
request - the HTTP request
Returns:
a Reply instance.
Throws:
ProtocolException - If processing the request failed.
ResourceException - If this resource got a fatal error.

post

public Reply post(Request request)
           throws ProtocolException,
                  ResourceException
Perform a post.

Overrides:
post in class HTTPFrame
Parameters:
request - the HTTP request
Returns:
a Reply instance.
Throws:
ProtocolException - If processing the request failed.
ResourceException - If this resource got a fatal error.

handle

public Reply handle(Request request)
             throws ProtocolException
Handles all relevant HTTP methods. Merges the partial replies from each of the segments into one global reply. Remark: no direct relation to PostableResource.handle()

Parameters:
request - The HTTP request
Returns:
a Reply instance.
Throws:
ProtocolException - If processing the request failed.

byteArrayNEquals

public static final boolean byteArrayNEquals(byte[] ba1,
                                             int off1,
                                             byte[] ba2,
                                             int off2,
                                             int n)
Analogous to standard C's strncmp, for byte arrays. (Should be in some utility package, I'll put it here for now)

Parameters:
ba1 - the first byte array
off1 - where to start in the first array
ba2 - the second byte array
off2 - where to start in the second array
n - the length to compare up to
Returns:
true if both specified parts of the arrays are equal, false if they aren't .

getLastModified

public long getLastModified()
Description copied from class: Resource
Get this resource last modification time.

Overrides:
getLastModified in class Resource
Returns:
A long giving the date of the last modification time, or -1 if undefined.

createDefaultReply

public final Reply createDefaultReply(Request request,
                                      int status)
Description copied from class: HTTPFrame
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.

Overrides:
createDefaultReply in class HTTPFrame
Parameters:
request - The request to make a reply for.
Returns:
An instance of Reply, suited to answer this request.

createCommandReply

public final Reply createCommandReply(Request request,
                                      int status)