org.restlet.data
Class Response

java.lang.Object
  extended by org.restlet.data.Message
      extended by org.restlet.data.Response
Direct Known Subclasses:
WrapperResponse

public class Response
extends Message

Generic response sent by server connectors. It is then received by client connectors. Responses are uniform across all types of connectors, protocols and components.

Author:
Jerome Louvel
See Also:
Request, Uniform

Constructor Summary
Response(Request request)
          Constructor.
 
Method Summary
 java.util.Set<Method> getAllowedMethods()
          Returns the modifiable set of methods allowed on the requested resource.
 ChallengeRequest getChallengeRequest()
          Deprecated. Use the getChallengeRequests() method instead.
 java.util.List<ChallengeRequest> getChallengeRequests()
          Returns the list of authentication requests sent by an origin server to a client.
 Series<CookieSetting> getCookieSettings()
          Returns the modifiable series of cookie settings provided by the server.
static Response getCurrent()
          Returns the response associated to the current thread.
 java.util.Set<Dimension> getDimensions()
          Returns the modifiable set of selecting dimensions on which the response entity may vary.
 Reference getLocationRef()
          Returns the reference that the client should follow for redirections or resource creations.
 Reference getRedirectRef()
          Deprecated. Use getLocationRef() instead.
 Request getRequest()
          Returns the associated request
 ServerInfo getServerInfo()
          Returns the server-specific information.
 Status getStatus()
          Returns the status.
 boolean isConfidential()
          Indicates if the message was or will be exchanged confidentially, for example via a SSL-secured connection.
 void redirectPermanent(Reference targetRef)
          Permanently redirects the client to a target URI.
 void redirectPermanent(java.lang.String targetUri)
          Permanently redirects the client to a target URI.
 void redirectSeeOther(Reference targetRef)
          Redirects the client to a different URI that SHOULD be retrieved using a GET method on that resource.
 void redirectSeeOther(java.lang.String targetUri)
          Redirects the client to a different URI that SHOULD be retrieved using a GET method on that resource.
 void redirectTemporary(Reference targetRef)
          Temporarily redirects the client to a target URI.
 void redirectTemporary(java.lang.String targetUri)
          Temporarily redirects the client to a target URI.
 void setAllowedMethods(java.util.Set<Method> allowedMethods)
          Sets the set of methods allowed on the requested resource.
 void setChallengeRequest(ChallengeRequest request)
          Sets the authentication request sent by an origin server to a client.
 void setChallengeRequests(java.util.List<ChallengeRequest> requests)
          Sets the list of authentication requests sent by an origin server to a client.
 void setCookieSettings(Series<CookieSetting> cookieSettings)
          Sets the cookie settings provided by the server.
static void setCurrent(Response response)
          Sets the response associated with the current thread.
 void setDimensions(java.util.Set<Dimension> dimensions)
          Sets the set of dimensions on which the response entity may vary.
 void setLocationRef(Reference locationRef)
          Sets the reference that the client should follow for redirections or resource creations.
 void setLocationRef(java.lang.String locationUri)
          Sets the reference that the client should follow for redirections or resource creations.
 void setRedirectRef(Reference locationRef)
          Deprecated. Use the setLocationRef() method instead.
 void setRedirectRef(java.lang.String locationUri)
          Deprecated. Use the setLocationRef() method instead.
 void setRequest(Request request)
          Sets the associated request.
 void setServerInfo(ServerInfo serverInfo)
          Sets the server-specific information.
 void setStatus(Status status)
          Sets the status.
 void setStatus(Status status, java.lang.String message)
          Sets the status.
 void setStatus(Status status, java.lang.Throwable throwable)
          Sets the status.
 void setStatus(Status status, java.lang.Throwable throwable, java.lang.String message)
          Sets the status.
 
Methods inherited from class org.restlet.data.Message
getAttributes, getEntity, getEntityAsDom, getEntityAsForm, getEntityAsObject, getEntityAsSax, isEntityAvailable, release, setAttributes, setEntity, setEntity, setEntity
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Response

public Response(Request request)
Constructor.

Parameters:
request - The request associated to this response.
Method Detail

getCurrent

public static Response getCurrent()
Returns the response associated to the current thread. Warning: this method should only be used under duress. You should by default prefer obtaining the current context using methods such as Handler.getResponse(). This variable is stored internally as a thread local variable and updated each time a call is handled by a Restlet via the Restlet.handle(org.restlet.data.Request, org.restlet.data.Response) method.

Returns:
The current context.

setCurrent

public static void setCurrent(Response response)
Sets the response associated with the current thread.

Parameters:
response - The thread's response.

getAllowedMethods

public java.util.Set<Method> getAllowedMethods()
Returns the modifiable set of methods allowed on the requested resource. This property only has to be updated when a status CLIENT_ERROR_METHOD_NOT_ALLOWED is set. Creates a new instance if no one has been set.

Returns:
The list of allowed methods.

getChallengeRequest

@Deprecated
public ChallengeRequest getChallengeRequest()
Deprecated. Use the getChallengeRequests() method instead.

Returns the authentication request sent by an origin server to a client.

Returns:
The authentication request sent by an origin server to a client.

getChallengeRequests

public java.util.List<ChallengeRequest> getChallengeRequests()
Returns the list of authentication requests sent by an origin server to a client. If none is found, an empty list is returned.

Returns:
The list of authentication requests.

getCookieSettings

public Series<CookieSetting> getCookieSettings()
Returns the modifiable series of cookie settings provided by the server. Creates a new instance if no one has been set.

Returns:
The cookie settings provided by the server.

getDimensions

public java.util.Set<Dimension> getDimensions()
Returns the modifiable set of selecting dimensions on which the response entity may vary. If some server-side content negotiation is done, this set should be properly updated, other it can be left empty. Creates a new instance if no one has been set.

Returns:
The set of dimensions on which the response entity may vary.

getLocationRef

public Reference getLocationRef()
Returns the reference that the client should follow for redirections or resource creations.

Returns:
The redirection reference.

getRedirectRef

@Deprecated
public Reference getRedirectRef()
Deprecated. Use getLocationRef() instead.

Returns the reference that the client should follow for redirections or resource creations.

Returns:
The redirection reference.

getRequest

public Request getRequest()
Returns the associated request

Returns:
The associated request

getServerInfo

public ServerInfo getServerInfo()
Returns the server-specific information. Creates a new instance if no one has been set.

Returns:
The server-specific information.

getStatus

public Status getStatus()
Returns the status.

Returns:
The status.

isConfidential

public boolean isConfidential()
Description copied from class: Message
Indicates if the message was or will be exchanged confidentially, for example via a SSL-secured connection.

Specified by:
isConfidential in class Message
Returns:
True if the message is confidential.

redirectPermanent

public void redirectPermanent(Reference targetRef)
Permanently redirects the client to a target URI. The client is expected to reuse the same method for the new request.

Parameters:
targetRef - The target URI reference.

redirectPermanent

public void redirectPermanent(java.lang.String targetUri)
Permanently redirects the client to a target URI. The client is expected to reuse the same method for the new request.

If you pass a relative target URI, it will be resolved with the current base reference of the request's resource reference (see Request.getResourceRef() and Reference.getBaseRef().

Parameters:
targetUri - The target URI.

redirectSeeOther

public void redirectSeeOther(Reference targetRef)
Redirects the client to a different URI that SHOULD be retrieved using a GET method on that resource. This method exists primarily to allow the output of a POST-activated script to redirect the user agent to a selected resource. The new URI is not a substitute reference for the originally requested resource.

Parameters:
targetRef - The target reference.

redirectSeeOther

public void redirectSeeOther(java.lang.String targetUri)
Redirects the client to a different URI that SHOULD be retrieved using a GET method on that resource. This method exists primarily to allow the output of a POST-activated script to redirect the user agent to a selected resource. The new URI is not a substitute reference for the originally requested resource.

If you pass a relative target URI, it will be resolved with the current base reference of the request's resource reference (see Request.getResourceRef() and Reference.getBaseRef().

Parameters:
targetUri - The target URI.

redirectTemporary

public void redirectTemporary(Reference targetRef)
Temporarily redirects the client to a target URI. The client is expected to reuse the same method for the new request.

Parameters:
targetRef - The target reference.

redirectTemporary

public void redirectTemporary(java.lang.String targetUri)
Temporarily redirects the client to a target URI. The client is expected to reuse the same method for the new request.

If you pass a relative target URI, it will be resolved with the current base reference of the request's resource reference (see Request.getResourceRef() and Reference.getBaseRef().

Parameters:
targetUri - The target URI.

setAllowedMethods

public void setAllowedMethods(java.util.Set<Method> allowedMethods)
Sets the set of methods allowed on the requested resource. The set instance set must be thread-safe (use CopyOnWriteArraySet for example.

Parameters:
allowedMethods - The set of methods allowed on the requested resource.

setChallengeRequest

public void setChallengeRequest(ChallengeRequest request)
Sets the authentication request sent by an origin server to a client.

Parameters:
request - The authentication request sent by an origin server to a client.

setChallengeRequests

public void setChallengeRequests(java.util.List<ChallengeRequest> requests)
Sets the list of authentication requests sent by an origin server to a client. The list instance set must be thread-safe (use CopyOnWriteArrayList for example.

Parameters:
requests - The list of authentication requests sent by an origin server to a client.

setCookieSettings

public void setCookieSettings(Series<CookieSetting> cookieSettings)
Sets the cookie settings provided by the server.

Parameters:
cookieSettings - The cookie settings provided by the server.

setDimensions

public void setDimensions(java.util.Set<Dimension> dimensions)
Sets the set of dimensions on which the response entity may vary. The set instance set must be thread-safe (use CopyOnWriteArraySet for example.

Parameters:
dimensions - The set of dimensions on which the response entity may vary.

setLocationRef

public void setLocationRef(Reference locationRef)
Sets the reference that the client should follow for redirections or resource creations.

Parameters:
locationRef - The reference to set.

setLocationRef

public void setLocationRef(java.lang.String locationUri)
Sets the reference that the client should follow for redirections or resource creations. If you pass a relative location URI, it will be resolved with the current base reference of the request's resource reference (see Request.getResourceRef() and Reference.getBaseRef().

Parameters:
locationUri - The URI to set.

setRedirectRef

@Deprecated
public void setRedirectRef(Reference locationRef)
Deprecated. Use the setLocationRef() method instead.

Sets the reference that the client should follow for redirections or resource creations.

Parameters:
locationRef - The reference to set.

setRedirectRef

@Deprecated
public void setRedirectRef(java.lang.String locationUri)
Deprecated. Use the setLocationRef() method instead.

Sets the reference that the client should follow for redirections or resource creations.

Parameters:
locationUri - The URI to set.

setRequest

public void setRequest(Request request)
Sets the associated request.

Parameters:
request - The associated request

setServerInfo

public void setServerInfo(ServerInfo serverInfo)
Sets the server-specific information.

Parameters:
serverInfo - The server-specific information.

setStatus

public void setStatus(Status status)
Sets the status.

Parameters:
status - The status to set.

setStatus

public void setStatus(Status status,
                      java.lang.String message)
Sets the status.

Parameters:
status - The status to set.
message - The status message.

setStatus

public void setStatus(Status status,
                      java.lang.Throwable throwable)
Sets the status.

Parameters:
status - The status to set.
throwable - The related error or exception.

setStatus

public void setStatus(Status status,
                      java.lang.Throwable throwable,
                      java.lang.String message)
Sets the status.

Parameters:
status - The status to set.
throwable - The related error or exception.
message - The status message.


Copyright © 2005-2008 Noelios Technologies.