    All Packages  Class Hierarchy  This Package  Previous  Next  Index

# Class org.w3c.jigsaw.frames.NegotiatedFrame

    java.lang.Object
       |
       +----org.w3c.tools.resources.AttributeHolder
               |
               +----org.w3c.tools.resources.Resource
                       |
                       +----org.w3c.tools.resources.FramedResource
                               |
                               +----org.w3c.tools.resources.ResourceFrame
                                       |
                                       +----org.w3c.tools.resources.ProtocolFrame
                                               |
                                               +----org.w3c.jigsaw.frames.HTTPFrame
                                                       |
                                                       +----org.w3c.jigsaw.frames.NegotiatedFrame

public class NegotiatedFrame
extends HTTPFrame

Content negotiation.

##

ATTR_VARIANTS
  Attribute index - The set of names of variants.
VARY
  The Vary header field for this resource is always the same.

##

NegotiatedFrame()

##

getVariantNames()
  Get the variant names.
getVariantResources()
  Get the variant resources.
negotiate(Request)
  Negotiate among the various variants for the Resource.
negotiateCharsetQuality(Vector, Request)
  Negotiate on charsets.
negotiateContentEncoding(Vector, Request)
  Negotiate among content encodings.
negotiateContentType(Vector, Request)
  Negotiate among content types.
negotiateLanguageQuality(Vector, Request)
  Negotiate among language qualities.
perform(RequestInterface)
  Perform an HTTP request.
printNegotiationState(String, Vector)
  Print the current negotiation state.
registerResource(FramedResource)
  Register this frame to the given resource.
setVariants(String[])

##

VARY

     protected static HttpTokenList VARY

  The Vary header field for this resource is always the same.

ATTR_VARIANTS

     protected static int ATTR_VARIANTS

  Attribute index - The set of names of variants.

##

NegotiatedFrame

     public NegotiatedFrame()

##

getVariantNames

     public String[] getVariantNames()

  Get the variant names.

setVariants

     public void setVariants(String variants[])

getVariantResources

     public ResourceReference[] getVariantResources() throws ProtocolException

  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 ResourceReference, or null.
  Throws: ProtocolException
    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.

negotiateContentEncoding

     protected boolean negotiateContentEncoding(Vector states,
                                                Request request) throws ProtocolException

  Negotiate among content encodings.

  BUG: This will work only for single encoded variants.

  Parameters:
    states - The current negotiation states.
    request - The request to handle.
  Returns:
    a boolean.
  Throws: ProtocolException
    If one of the variants doesn't exist.

negotiateCharsetQuality

     protected boolean negotiateCharsetQuality(Vector states,
                                               Request request)

  Negotiate on charsets.

  BUG: Not implemented yet.

  Parameters:
    states - The current states of negotiation.
    request - The request to handle.

negotiateLanguageQuality

     protected boolean negotiateLanguageQuality(Vector states,
                                                Request request) throws ProtocolException

  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.
  Returns:
    a boolean.
  Throws: ProtocolException
    If one of the variants doesn't exist.

negotiateContentType

     protected boolean negotiateContentType(Vector states,
                                            Request request) throws ProtocolException

  Negotiate among content types.

  Parameters:
    states - The current states of negotiation.
    request - The request to handle.
  Returns:
    a boolean.
  Throws: ProtocolException
    If one of the variants doesn't exist.

negotiate

     protected ResourceReference negotiate(Request request) throws ProtocolException

  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.

  Parameters:
    request - the incomming request.
  Returns:
    a RefourceReference instance.
  Throws: ProtocolException
    If one of the variants doesn't exist.

registerResource

     public void registerResource(FramedResource resource)

  Register this frame to the given resource.

  Overrides:
    registerResource in class HTTPFrame

perform

     public ReplyInterface perform(RequestInterface req) throws ProtocolException, ResourceException

  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: ProtocolException
    If negotiating among the resource variants failed.
  Throws: ResourceException
    If the resource got a fatal error.
  Overrides:
    perform in class HTTPFrame

    All Packages  Class Hierarchy  This Package  Previous  Next  Index