public interface HttpResponseContext
The default state is a HTTP response with a status code of 204 (No Content) with no headers and entity.
Modifier and Type | Method and Description |
---|---|
java.lang.annotation.Annotation[] |
getAnnotations()
Get the annotations associated with the response entity (if any).
|
java.lang.Object |
getEntity() |
java.lang.reflect.Type |
getEntityType() |
MultivaluedMap<java.lang.String,java.lang.Object> |
getHttpHeaders()
Get the HTTP response headers.
|
java.lang.Throwable |
getMappedThrowable()
Get the throwable (if any) that was mapped to a response.
|
MediaType |
getMediaType()
Get the media type of the response entity.
|
java.lang.Object |
getOriginalEntity()
Get the original entity instance that was set by
setEntity(java.lang.Object) . |
java.io.OutputStream |
getOutputStream()
Get an
OutputStream to which an entity may be written. |
Response |
getResponse()
Get the response that was set.
|
int |
getStatus() |
Response.StatusType |
getStatusType() |
boolean |
isCommitted()
Ascertain if a response has been committed to the container.
|
boolean |
isResponseSet()
Check if the response has been set using the setReponse methods.
|
void |
setAnnotations(java.lang.annotation.Annotation[] annotations)
Set the annotations associated with the response entity (if any).
|
void |
setEntity(java.lang.Object entity)
Set the entity of the response.
|
void |
setResponse(Response response)
Set the response state from a Response instance.
|
void |
setStatus(int status)
Set the status of the response.
|
void |
setStatusType(Response.StatusType statusType)
Set the status type of the response.
|
Response getResponse()
void setResponse(Response response)
response
- the response.boolean isResponseSet()
java.lang.Throwable getMappedThrowable()
Response.StatusType getStatusType()
void setStatusType(Response.StatusType statusType)
statusType
- the status type.int getStatus()
void setStatus(int status)
status
- the status.java.lang.Object getEntity()
java.lang.reflect.Type getEntityType()
java.lang.Object getOriginalEntity()
setEntity(java.lang.Object)
.void setEntity(java.lang.Object entity)
If the entity is an instance of GenericEntity
then the entity
and entity type are set from the entity and type of that
GenericEntity
. Otherwise, the entity is set from the entity
parameter and the type is the class of that parameter.
If it is necessary to wrap an entity that may have been set with an
instance of GenericEntity
then utilize the
getOriginalEntity()
, for example:
HttpResponseContext r = ... r.setEntity(wrap(getOriginalEntity()));
entity
- the entity.java.lang.annotation.Annotation[] getAnnotations()
void setAnnotations(java.lang.annotation.Annotation[] annotations)
annotations
- the annotations.MultivaluedMap<java.lang.String,java.lang.Object> getHttpHeaders()
setResponse(javax.ws.rs.core.Response)
will replace any headers previously set.MediaType getMediaType()
java.io.OutputStream getOutputStream() throws java.io.IOException
OutputStream
to which an entity may be written.
The first byte written will result in the writing of thethe status code and headers.
java.io.IOException
- if an IO error occursboolean isCommitted()
A response is committed if the status code, headers have been written to the container.
Copyright © 2016 Oracle Corporation. All Rights Reserved.