org.restlet.util
Class WrapperRequest

java.lang.Object
  extended by org.restlet.data.Message
      extended by org.restlet.data.Request
          extended by org.restlet.util.WrapperRequest

public class WrapperRequest
extends Request

Request wrapper. Useful for application developer who need to enrich the request with application related properties and behavior.

Author:
Jerome Louvel
See Also:
The decorator (aka wrapper) pattern

Constructor Summary
WrapperRequest(Request wrappedRequest)
          Constructor.
 
Method Summary
 java.util.Map<java.lang.String,java.lang.Object> getAttributes()
          Returns a modifiable attributes map that can be used by developers to save information relative to the message.
 ChallengeResponse getChallengeResponse()
          Returns the authentication response sent by a client to an origin server.
 ClientInfo getClientInfo()
          Returns the client-specific information.
 Conditions getConditions()
          Returns the conditions applying to this call.
 Series<Cookie> getCookies()
          Returns the cookies provided by the client.
 Representation getEntity()
          Returns the entity representation.
 DomRepresentation getEntityAsDom()
          Returns the entity as a DOM representation.
This method can be called several times and will always return the same representation instance.
 Form getEntityAsForm()
          Returns the entity as a DOM representation.
Note that this triggers the parsing of the entity into a reusable DOM document stored in memory.
This method and the related getEntity*() methods can only be invoked once.
 java.lang.Object getEntityAsObject()
          Deprecated. Since 1.1, the ConverterService is deprecated, with no replacement as it doesn't fit well with content negotiation. Most users prefer to handle those conversion in Resource subclasses.
 SaxRepresentation getEntityAsSax()
          Returns the entity as a SAX representation.
Note that this kind of representation can only be parsed once.
 Reference getHostRef()
          Returns the host reference.
 Method getMethod()
          Returns the method.
 Protocol getProtocol()
          Returns the protocol by first returning the baseRef.schemeProtocol property if it is set, or the resourceRef.schemeProtocol property otherwise.
 Reference getReferrerRef()
          Returns the referrer reference if available.
 Reference getResourceRef()
          Returns the reference of the target resource.
 Reference getRootRef()
          Returns the application root reference.
protected  Request getWrappedRequest()
          Returns the wrapped request.
 boolean isConfidential()
          Indicates if the call came over a confidential channel such as an SSL-secured connection.
 boolean isEntityAvailable()
          Indicates if a content is available and can be sent.
 void setChallengeResponse(ChallengeResponse response)
          Sets the authentication response sent by a client to an origin server.
 void setEntity(java.lang.Object object)
          Deprecated. Since 1.1, the ConverterService is deprecated, with no replacement as it doesn't fit well with content negotiation. Most users prefer to handle those conversion in Resource subclasses.
 void setEntity(Representation entity)
          Sets the entity representation.
 void setEntity(java.lang.String value, MediaType mediaType)
          Sets a textual entity.
 void setHostRef(Reference hostRef)
          Sets the host reference.
 void setHostRef(java.lang.String hostUri)
          Sets the host reference using an URI string.
 void setMethod(Method method)
          Sets the method called.
 void setReferrerRef(Reference referrerRef)
          Sets the referrer reference if available.
 void setReferrerRef(java.lang.String referrerUri)
          Sets the referrer reference if available using an URI string.
 void setResourceRef(Reference resourceRef)
          Sets the target resource reference.
 void setResourceRef(java.lang.String resourceUri)
          Sets the target resource reference using an URI string.
 void setRootRef(Reference rootRef)
          Sets the application root reference.
 
Methods inherited from class org.restlet.data.Request
getCurrent, getOriginalRef, getRanges, setClientInfo, setConditions, setCookies, setOriginalRef, setRanges
 
Methods inherited from class org.restlet.data.Message
release, setAttributes
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WrapperRequest

public WrapperRequest(Request wrappedRequest)
Constructor.

Parameters:
wrappedRequest - The wrapped request.
Method Detail

getAttributes

public java.util.Map<java.lang.String,java.lang.Object> getAttributes()
Returns a modifiable attributes map that can be used by developers to save information relative to the message. This is an easier alternative to the creation of a wrapper instance around the whole message.

In addition, this map is a shared space between the developer and the connectors. In this case, it is used to exchange information that is not uniform across all protocols and couldn't therefore be directly included in the API. For this purpose, all attribute names starting with "org.restlet" are reserved. Currently the following attributes are used:
Attribute name Class name Description
org.restlet.http.headers org.restlet.data.Form Server HTTP connectors must provide all request headers and client HTTP connectors must provide all response headers, exactly as they were received. In addition, developers can also use this attribute to specify non-standard headers that should be added to the request or to the response.
Adding standard HTTP headers is forbidden because it could conflict with the connector's internal behavior, limit portability or prevent future optimizations.

Overrides:
getAttributes in class Message
Returns:
The modifiable attributes map.

getChallengeResponse

public ChallengeResponse getChallengeResponse()
Returns the authentication response sent by a client to an origin server.

Overrides:
getChallengeResponse in class Request
Returns:
The authentication response sent by a client to an origin server.

getClientInfo

public ClientInfo getClientInfo()
Returns the client-specific information.

Overrides:
getClientInfo in class Request
Returns:
The client-specific information.

getConditions

public Conditions getConditions()
Returns the conditions applying to this call.

Overrides:
getConditions in class Request
Returns:
The conditions applying to this call.

getCookies

public Series<Cookie> getCookies()
Returns the cookies provided by the client.

Overrides:
getCookies in class Request
Returns:
The cookies provided by the client.

getEntity

public Representation getEntity()
Returns the entity representation.

Overrides:
getEntity in class Message
Returns:
The entity representation.

getEntityAsDom

public DomRepresentation getEntityAsDom()
Description copied from class: Message
Returns the entity as a DOM representation.
This method can be called several times and will always return the same representation instance. Note that if the entity is large this method can result in important memory consumption. In this case, consider using a SAX representation.

Overrides:
getEntityAsDom in class Message
Returns:
The entity as a DOM representation.

getEntityAsForm

public Form getEntityAsForm()
Returns the entity as a DOM representation.
Note that this triggers the parsing of the entity into a reusable DOM document stored in memory.
This method and the related getEntity*() methods can only be invoked once.

Overrides:
getEntityAsForm in class Message
Returns:
The entity as a DOM representation.

getEntityAsObject

@Deprecated
public java.lang.Object getEntityAsObject()
Deprecated. Since 1.1, the ConverterService is deprecated, with no replacement as it doesn't fit well with content negotiation. Most users prefer to handle those conversion in Resource subclasses.

Returns the entity as a higher-level object. This object is created by the Application's converter service. If you want to use this method to facilitate the processing of request entities, you need to provide a custom implementation of the ConverterService class, overriding the toObject(Representation) method.
Note that this triggers the parsing of the entity.
This method and the related getEntity*() methods can only be invoked once.

Overrides:
getEntityAsObject in class Message
Returns:
The entity as a higher-level object.
See Also:
ConverterService

getEntityAsSax

public SaxRepresentation getEntityAsSax()
Returns the entity as a SAX representation.
Note that this kind of representation can only be parsed once. If you evaluate an XPath expression, it can also only be done once. If you need to reuse the entity multiple times, consider using the getEntityAsDom() method instead.

Overrides:
getEntityAsSax in class Message
Returns:
The entity as a SAX representation.

getHostRef

public Reference getHostRef()
Returns the host reference. This may be different from the resourceRef's host, for example for URNs and other URIs that don't contain host information.

Overrides:
getHostRef in class Request
Returns:
The host reference.

getMethod

public Method getMethod()
Returns the method.

Overrides:
getMethod in class Request
Returns:
The method.

getProtocol

public Protocol getProtocol()
Returns the protocol by first returning the baseRef.schemeProtocol property if it is set, or the resourceRef.schemeProtocol property otherwise.

Overrides:
getProtocol in class Request
Returns:
The protocol or null if not available.

getReferrerRef

public Reference getReferrerRef()
Returns the referrer reference if available.

Overrides:
getReferrerRef in class Request
Returns:
The referrer reference.

getResourceRef

public Reference getResourceRef()
Returns the reference of the target resource.

Overrides:
getResourceRef in class Request
Returns:
The reference of the target resource.
See Also:
Request.getOriginalRef()

getRootRef

public Reference getRootRef()
Returns the application root reference.

Overrides:
getRootRef in class Request
Returns:
The application root reference.

getWrappedRequest

protected Request getWrappedRequest()
Returns the wrapped request.

Returns:
The wrapped request.

isConfidential

public boolean isConfidential()
Indicates if the call came over a confidential channel such as an SSL-secured connection.

Overrides:
isConfidential in class Request
Returns:
True if the call came over a confidential channel.

isEntityAvailable

public boolean isEntityAvailable()
Indicates if a content is available and can be sent. Several conditions must be met: the method must allow the sending of content, the content must exists and have some available data.

Overrides:
isEntityAvailable in class Request
Returns:
True if a content is available and can be sent.

setChallengeResponse

public void setChallengeResponse(ChallengeResponse response)
Sets the authentication response sent by a client to an origin server.

Overrides:
setChallengeResponse in class Request
Parameters:
response - The authentication response sent by a client to an origin server.

setEntity

@Deprecated
public void setEntity(java.lang.Object object)
Deprecated. Since 1.1, the ConverterService is deprecated, with no replacement as it doesn't fit well with content negotiation. Most users prefer to handle those conversion in Resource subclasses.

Sets the entity from a higher-level object. This object is converted to a representation using the Application's converter service. If you want to use this method to facilitate the setting of entities, you need to provide a custom implementation of the ConverterService class, overriding the toRepresentation(Object) method.

Overrides:
setEntity in class Message
Parameters:
object - The higher-level object.
See Also:
ConverterService

setEntity

public void setEntity(Representation entity)
Sets the entity representation.

Overrides:
setEntity in class Message
Parameters:
entity - The entity representation.

setEntity

public void setEntity(java.lang.String value,
                      MediaType mediaType)
Sets a textual entity.

Overrides:
setEntity in class Message
Parameters:
value - The represented string.
mediaType - The representation's media type.

setHostRef

public void setHostRef(Reference hostRef)
Sets the host reference.

Overrides:
setHostRef in class Request
Parameters:
hostRef - The host reference.

setHostRef

public void setHostRef(java.lang.String hostUri)
Sets the host reference using an URI string.

Overrides:
setHostRef in class Request
Parameters:
hostUri - The host URI.

setMethod

public void setMethod(Method method)
Sets the method called.

Overrides:
setMethod in class Request
Parameters:
method - The method called.

setReferrerRef

public void setReferrerRef(Reference referrerRef)
Sets the referrer reference if available.

Overrides:
setReferrerRef in class Request
Parameters:
referrerRef - The referrer reference.

setReferrerRef

public void setReferrerRef(java.lang.String referrerUri)
Sets the referrer reference if available using an URI string.

Overrides:
setReferrerRef in class Request
Parameters:
referrerUri - The referrer URI.

setResourceRef

public void setResourceRef(Reference resourceRef)
Sets the target resource reference. If the reference is relative, it will be resolved as an absolute reference. Also, the context's base reference will be reset. Finally, the reference will be normalized to ensure a consistent handling of the call.

Overrides:
setResourceRef in class Request
Parameters:
resourceRef - The resource reference.
See Also:
Request.getResourceRef()

setResourceRef

public void setResourceRef(java.lang.String resourceUri)
Sets the target resource reference using an URI string. Note that the URI can be either absolute or relative to the context's base reference.

Overrides:
setResourceRef in class Request
Parameters:
resourceUri - The resource URI.
See Also:
Request.setResourceRef(Reference)

setRootRef

public void setRootRef(Reference rootRef)
Sets the application root reference.

Overrides:
setRootRef in class Request
Parameters:
rootRef - The application root reference.


Copyright © 2005-2008 Noelios Technologies.