com.sun.ws.rest.api.response
Class HttpResponse

java.lang.Object
  extended by com.sun.ws.rest.api.response.HttpResponse
Direct Known Subclasses:
Created, NotModified, TemporaryRedirect

public class HttpResponse
extends java.lang.Object

Base class for HTTP responses. Subclasses offer specializations for various common response types.


Constructor Summary
HttpResponse()
          Create a new instance, the HTTP status code defaults to 204.
HttpResponse(int status)
          Create a new instance with the specified status code.
HttpResponse(int status, Representation<?> representation)
          Create a new instance
HttpResponse(Representation<?> representation)
          Create a new instance, the HTTP status code defaults to 200.
 
Method Summary
 void addResponseHeaders(HttpContext context)
          Add the HTTP headers associated with any representation and cache control.
 CacheControl getCacheControl()
           
 void getCacheControl(CacheControl cacheControl)
          Get the cache control information that will be sent with the response
 Representation<?> getRepresentation()
          Get the representation associated with the response.
 int getStatus()
          Get the response status code.
 void setRepresentation(Representation<?> representation)
          Set the representation associated with the response.
 void setStatus(int status)
          Set the response status code.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HttpResponse

public HttpResponse()
Create a new instance, the HTTP status code defaults to 204.


HttpResponse

public HttpResponse(Representation<?> representation)
Create a new instance, the HTTP status code defaults to 200.

Parameters:
representation - the representation that will form the entity body of the HTTP response

HttpResponse

public HttpResponse(int status)
Create a new instance with the specified status code.

Parameters:
status - the HTTP status code

HttpResponse

public HttpResponse(int status,
                    Representation<?> representation)
Create a new instance

Parameters:
status - the HTTP status code
representation - the representation that will form the entity body of the HTTP response
Method Detail

getRepresentation

public Representation<?> getRepresentation()
Get the representation associated with the response. The representation forms the entity body of the HTTP response.

Returns:
the representation or null if none is set.

setRepresentation

public void setRepresentation(Representation<?> representation)
Set the representation associated with the response. The representation forms the entity body of the HTTP response.

Parameters:
representation - the representation

setStatus

public void setStatus(int status)
               throws java.lang.IllegalArgumentException
Set the response status code.

Parameters:
status - the status code, see RFC 2616.
Throws:
java.lang.IllegalArgumentException - if the status code is outside the permitted range

getStatus

public int getStatus()
Get the response status code.

Returns:
the response status code.

getCacheControl

public void getCacheControl(CacheControl cacheControl)
Get the cache control information that will be sent with the response


getCacheControl

public CacheControl getCacheControl()

addResponseHeaders

public void addResponseHeaders(HttpContext context)
Add the HTTP headers associated with any representation and cache control. Subclasses that override this method to write their own headers should also call the superclass method to ensure that all response headers are written.

Parameters:
context - the current HTTP context