org.w3c.jigsaw.filters
Class RequestedHeaderFilter

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.ResourceFilter
                      extended by org.w3c.jigsaw.filters.RequestedHeaderFilter
All Implemented Interfaces:
java.lang.Cloneable, java.util.EventListener, AttributeChangedListener, FrameEventListener, FilterInterface

public class RequestedHeaderFilter
extends ResourceFilter

Enforces a specific header value on all replies. Usefull for testing.


Field Summary
protected static int ATTR_HEADER_NAMES
          Attribute index - The header name to add to replies.
protected static int ATTR_SEND_HEADER_LIST
          Attribute index - Are we sending the list of headers in HTML.
 
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
RequestedHeaderFilter()
           
 
Method Summary
 ReplyInterface exceptionFilter(RequestInterface request, ProtocolException ex, FilterInterface[] filters, int i)
           
protected  java.lang.String[] getHeaderNames()
          Get the header to set, if any.
protected  boolean getSendHeaderList()
           
 ReplyInterface ingoingFilter(RequestInterface request)
          Simplified ingoingFilter API.
 void initialize(java.lang.Object[] values)
          Initialize the filter.
 ReplyInterface outgoingFilter(RequestInterface req, ReplyInterface rep)
          The outgoing filter decorates the reply appropriately.
 void setValue(int idx, java.lang.Object value)
          We override setValues to compute locally everything we need 8 As the purpose here is to bail out fast when needed
 
Methods inherited from class org.w3c.tools.resources.ResourceFilter
getTargetResource, ingoingFilter, initialize, lookup, outgoingFilter, outputFilter, pickleValues
 
Methods inherited from class org.w3c.tools.resources.ResourceFrame
addFrameEventListener, attributeChanged, checkRequest, eventDisabled, fireFrameEvent, frameModified, getFilters, getFilters, getFrameReference, getResource, getResourceReference, getSpaceEntry, getURLPath, lookupFilters, lookupFrames, perform, postFrameEvent, processEvent, registerResource, 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, markModified, notifyUnload, performFrames, 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, getHelpURL, getHelpURL, getIdentifier, getLastModified, 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

ATTR_HEADER_NAMES

protected static int ATTR_HEADER_NAMES
Attribute index - The header name to add to replies.


ATTR_SEND_HEADER_LIST

protected static int ATTR_SEND_HEADER_LIST
Attribute index - Are we sending the list of headers in HTML.

Constructor Detail

RequestedHeaderFilter

public RequestedHeaderFilter()
Method Detail

setValue

public void setValue(int idx,
                     java.lang.Object value)
We override setValues to compute locally everything we need 8 As the purpose here is to bail out fast when needed

Overrides:
setValue in class ResourceFrame
Parameters:
idx - The index of the attribute to modify.
value - The new attribute value.

initialize

public void initialize(java.lang.Object[] values)
Initialize the filter.

Overrides:
initialize in class FramedResource
Parameters:
values - Default attribute values.

getHeaderNames

protected java.lang.String[] getHeaderNames()
Get the header to set, if any.

Returns:
A String encoded header name, or null.

getSendHeaderList

protected boolean getSendHeaderList()

ingoingFilter

public ReplyInterface ingoingFilter(RequestInterface request)
                             throws ProtocolException
Description copied from class: ResourceFilter
Simplified ingoingFilter API. This is a default, simplified API to the ingoing filter method.

Overrides:
ingoingFilter in class ResourceFilter
Parameters:
request - The request to filter.
Returns:
A Reply instance, if the filter did know how to answer the request without further processing, null otherwise.
Throws:
ProtocolException - If processing should be interrupted, because an abnormal situation occured.

outgoingFilter

public ReplyInterface outgoingFilter(RequestInterface req,
                                     ReplyInterface rep)
                              throws ProtocolException
The outgoing filter decorates the reply appropriately.

Overrides:
outgoingFilter in class ResourceFilter
Parameters:
request - The original request.
reply - The originial reply.
Returns:
Always null.
Throws:
ProtocolException - If processing should be interrupted, because an abnormal situation occured.

exceptionFilter

public ReplyInterface exceptionFilter(RequestInterface request,
                                      ProtocolException ex,
                                      FilterInterface[] filters,
                                      int i)
Specified by:
exceptionFilter in interface FilterInterface
Overrides:
exceptionFilter in class ResourceFilter
Parameters:
request - The request being processed.
ex - The exception that occured during processing the request. and which has already been processed by the first filters.
filters - The whole array of filters to be applied before actually continuing the process.
i - The index in the above array of the filter being called.