Class w3c.jigsaw.resources.NegotiatedResource
All Packages Class Hierarchy This Package Previous Next Index
Class w3c.jigsaw.resources.NegotiatedResource
java.lang.Object
|
+----w3c.jigsaw.resources.AttributeHolder
|
+----w3c.jigsaw.resources.Resource
|
+----w3c.jigsaw.resources.HTTPResource
|
+----w3c.jigsaw.resources.ContainerResource
|
+----w3c.jigsaw.resources.FilteredResource
|
+----w3c.jigsaw.resources.NegotiatedResource
- public class NegotiatedResource
- extends FilteredResource
This class provides content negociation among any other resources.
This resource tries to conform to the HTTP/1.0 specification of
content negociation.
A bit of terminology here: in HTTP terms, a resource should negotiate
among a set of entities, not among a set of variants. Jigsaw uses the
term resource as an object able to respond to HTTP requests, and
so is able to negotiate among resources (eg it can negotiate among
a CGIResource, a FileResource of whatever other resources).
-
ATTR_VARIANTS
- Attribute index - The set of names of variants.
-
NegotiatedResource()
-
-
getVariantNames()
- Get the variant names.
-
getVariantResources()
- Get the variant resources.
-
negociateCharsetQuality(Vector, Request)
- Negotiate on charsets.
-
negociateContentEncoding(Vector, Request)
- Negotiate among content encodings.
-
negociateLanguageQuality(Vector, Request)
- Negotiate among language qualities.
-
negotiate(Request)
- Negotiate among the various variants for the Resource.
-
negotiateContentType(Vector, Request)
- Negotiate among content types.
-
perform(Request)
- Perform an HTTP request.
-
printNegotiationState(String, Vector)
- Print the current negotiation state.
ATTR_VARIANTS
protected static int ATTR_VARIANTS
- Attribute index - The set of names of variants.
NegotiatedResource
public NegotiatedResource()
getVariantNames
public String[] getVariantNames()
- Get the variant names.
getVariantResources
public HTTPResource[] getVariantResources()
- Get the variant resources.
This is somehow broken, it shouldn't allocate the array of variants
on each call. However, don't forget that the list of variants can be
dynamically edited, this means that if we are to keep a cache of it
(as would be the case if we kept the array of variants as instance var)
we should also take care of editing of attributes (possible, but I
just don't have enough lifes).
- Returns:
- An array of HTTPResource, or null.
- Throws: HTTPException
- If one of the variants doesn't exist.
printNegotiationState
protected void printNegotiationState(String header,
Vector states)
- Print the current negotiation state.
- Parameters:
- header - The header to print first.
- states - The current negotiation states.
negociateContentEncoding
protected boolean negociateContentEncoding(Vector states,
Request request) throws HTTPException
- Negotiate among content encodings.
BUG: This will work only for single encoded variants.
- Parameters:
- states - The current negotiation states.
- request - The request to handle.
negociateCharsetQuality
protected boolean negociateCharsetQuality(Vector states,
Request request)
- Negotiate on charsets.
BUG: Not implemented yet.
- Parameters:
- states - The current states of negotiation.
- request - The request to handle.
negociateLanguageQuality
protected boolean negociateLanguageQuality(Vector states,
Request request) throws HTTPException
- Negotiate among language qualities.
BUG: This will only work for variants that have one language tag.
- Parameters:
- states - The current states of negotiation.
- request - The request to handle.
negotiateContentType
protected boolean negotiateContentType(Vector states,
Request request) throws HTTPException
- Negotiate among content types.
- Parameters:
- states - The current states of negotiation.
- request - The request to handle.
negotiate
protected HTTPResource negotiate(Request request) throws HTTPException
- Negotiate among the various variants for the Resource.
We made our best efforts to be as compliant as possible to the HTTP/1.0
content negotiation algorithm.
perform
public Reply perform(Request request) throws HTTPException
- Perform an HTTP request.
Negotiate among the variants, the best variant according to the request
fields, and make this elect3d variant serve the request.
- Parameters:
- request - The request to handle.
- Throws: HTTPException
- If negotiating among the resource variants
failed.
- Overrides:
- perform in class FilteredResource
All Packages Class Hierarchy This Package Previous Next Index