com.sun.ws.rest.api.core
Interface HttpResponseContext

All Known Subinterfaces:
ContainerResponse
All Known Implementing Classes:
AbstractContainerResponse

public interface HttpResponseContext

Encapsulates the response to a HTTP request.

The default state of a response is a HTTP response with a status code of 204 (OK) with no HTTP response headers and no entity.


Method Summary
 java.lang.Object getEntity()
          Get the entity of the response
 javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.Object> getHttpHeaders()
          Get the HTTP response headers.
 java.io.OutputStream getOutputStream()
          Get an OutputStream to which an entity may be written.
 int getStatus()
          Get the status of the response.
 boolean isCommitted()
          Ascertain if a response has been committed to an underlying container.
 boolean isResponseSet()
          Check if the response has been set using the setReponse methods.
 void setEntity(java.lang.Object entity)
          Set the entity of the response
 void setResponse(javax.ws.rs.core.Response response)
          Set the response state from a Response instance.
 void setResponse(javax.ws.rs.core.Response response, javax.ws.rs.core.MediaType contentType)
          Set the response state from a Response instance.
 void setStatus(int status)
          Set the status of the response.
 

Method Detail

setResponse

void setResponse(javax.ws.rs.core.Response response)
Set the response state from a Response instance. This replaces a pre-existing response state.

If an entity is set but there is no MIME media type declared for the Content-Type response header then the MIME media type will be set to "application/octet-stream".

Parameters:
response - the response.

setResponse

void setResponse(javax.ws.rs.core.Response response,
                 javax.ws.rs.core.MediaType contentType)
Set the response state from a Response instance. This replaces a pre-existing response state.

Parameters:
response - the response.
contentType - the MIME media type to use fot the Content-Type response header if the header is not set by the response. If null then "application/octet-stream" will be used.

isResponseSet

boolean isResponseSet()
Check if the response has been set using the setReponse methods.

Returns:
true if the response has been set.

getStatus

int getStatus()
Get the status of the response.


setStatus

void setStatus(int status)
Set the status of the response.


getEntity

java.lang.Object getEntity()
Get the entity of the response


setEntity

void setEntity(java.lang.Object entity)
Set the entity of the response


getHttpHeaders

javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.Object> getHttpHeaders()
Get the HTTP response headers. The returned map is case-insensitive wrt keys. Note that setHttpResponse can change the HTTP response headers and may overwrite headers set previously.

Returns:
a mutable map of HTTP header names and values that will be included in the response. Any headers explicitly set will override automatically generated values.

getOutputStream

java.io.OutputStream getOutputStream()
                                     throws java.io.IOException
Get an OutputStream to which an entity may be written.

The first byte written will cause the status code and headers (if any) to be committed to the underlying container.

Returns:
the output stream
Throws:
java.io.IOException - if an IO error occurs

isCommitted

boolean isCommitted()
Ascertain if a response has been committed to an underlying container.

A response is committed if the status code, headers (if any) have been committed to the underlying container.

Returns:
true if the response has been committed.