public class ContainerResponseContextImpl extends Object implements ContainerResponseContext
| Modifier and Type | Field and Description |
|---|---|
protected HttpResponse |
httpResponse |
protected BuiltResponse |
jaxrsResponse |
protected HttpRequest |
request |
| Constructor and Description |
|---|
ContainerResponseContextImpl(HttpRequest request,
HttpResponse httpResponse,
BuiltResponse serverResponse) |
| Modifier and Type | Method and Description |
|---|---|
Set<String> |
getAllowedMethods()
Get the allowed HTTP methods from the Allow HTTP header.
|
Map<String,NewCookie> |
getCookies()
Get any new cookies set on the response message.
|
Date |
getDate()
Get message date.
|
Object |
getEntity()
Get the message entity Java instance.
|
Annotation[] |
getEntityAnnotations()
Get the annotations attached to the entity instance.
|
Class<?> |
getEntityClass()
Get the raw entity type information.
|
OutputStream |
getEntityStream()
Get the entity output stream.
|
EntityTag |
getEntityTag()
Get the entity tag.
|
Type |
getEntityType()
Get the generic entity type information.
|
MultivaluedMap<String,Object> |
getHeaders()
Get the mutable response headers multivalued map.
|
String |
getHeaderString(String name)
Get a message header as a single string value.
|
HttpResponse |
getHttpResponse() |
BuiltResponse |
getJaxrsResponse() |
Locale |
getLanguage()
Get the language of the entity.
|
Date |
getLastModified()
Get the last modified date.
|
int |
getLength()
Get Content-Length value.
|
Link |
getLink(String relation)
Get the link for the relation.
|
Link.Builder |
getLinkBuilder(String relation)
Convenience method that returns a
Link.Builder
for the relation. |
Set<Link> |
getLinks()
Get the links attached to the message as header.
|
URI |
getLocation()
Get the location.
|
MediaType |
getMediaType()
Get the media type of the entity.
|
int |
getStatus()
Get the status code associated with the response.
|
Response.StatusType |
getStatusInfo()
Get the complete status information associated with the response.
|
MultivaluedMap<String,String> |
getStringHeaders()
Get a string view of header values associated with the message.
|
boolean |
hasEntity()
Check if there is an entity available in the response.
|
boolean |
hasLink(String relation)
Check if link for relation exists.
|
void |
setEntity(Object entity)
Set a new message entity.
|
void |
setEntity(Object entity,
Annotation[] annotations,
MediaType mediaType)
Set a new message entity, including the attached annotations and the media type.
|
void |
setEntityStream(OutputStream entityStream)
Set a new entity output stream.
|
void |
setStatus(int code)
Set a new response status code.
|
void |
setStatusInfo(Response.StatusType statusInfo)
Set the complete status information (status code and reason phrase) associated
with the response.
|
protected final HttpRequest request
protected final HttpResponse httpResponse
protected final BuiltResponse jaxrsResponse
public ContainerResponseContextImpl(HttpRequest request, HttpResponse httpResponse, BuiltResponse serverResponse)
public BuiltResponse getJaxrsResponse()
public HttpResponse getHttpResponse()
public int getStatus()
ContainerResponseContextgetStatus in interface ContainerResponseContextpublic void setStatus(int code)
ContainerResponseContextsetStatus in interface ContainerResponseContextcode - new status code.public Response.StatusType getStatusInfo()
ContainerResponseContextgetStatusInfo in interface ContainerResponseContextnull if the status was
not set.public void setStatusInfo(Response.StatusType statusInfo)
ContainerResponseContextsetStatusInfo in interface ContainerResponseContextstatusInfo - the response status information.public Class<?> getEntityClass()
ContainerResponseContextgetEntityClass in interface ContainerResponseContextpublic Type getEntityType()
ContainerResponseContextgetEntityType in interface ContainerResponseContextpublic void setEntity(Object entity)
ContainerResponseContextannotations
and media type are preserved.
It is the callers responsibility to wrap the actual entity with
GenericEntity if preservation of its generic
type is required.
setEntity in interface ContainerResponseContextentity - entity object.ContainerResponseContext.setEntity(Object, java.lang.annotation.Annotation[], javax.ws.rs.core.MediaType),
MessageBodyWriterpublic void setEntity(Object entity, Annotation[] annotations, MediaType mediaType)
ContainerResponseContext
It is the callers responsibility to wrap the actual entity with
GenericEntity if preservation of its generic
type is required.
setEntity in interface ContainerResponseContextentity - entity object.annotations - annotations attached to the entity instance.mediaType - entity media type.ContainerResponseContext.setEntity(Object),
MessageBodyWriterpublic MultivaluedMap<String,Object> getHeaders()
ContainerResponseContextgetHeaders in interface ContainerResponseContextContainerResponseContext.getStringHeaders(),
ContainerResponseContext.getHeaderString(String)public Set<String> getAllowedMethods()
ContainerResponseContextgetAllowedMethods in interface ContainerResponseContextpublic Date getDate()
ContainerResponseContextgetDate in interface ContainerResponseContextnull if not present.public Locale getLanguage()
ContainerResponseContextgetLanguage in interface ContainerResponseContextnull if not specifiedpublic int getLength()
ContainerResponseContextgetLength in interface ContainerResponseContextpublic MediaType getMediaType()
ContainerResponseContextgetMediaType in interface ContainerResponseContextnull if not specified (e.g. there's no
response entity).public Map<String,NewCookie> getCookies()
ContainerResponseContextgetCookies in interface ContainerResponseContextnew cookie.public EntityTag getEntityTag()
ContainerResponseContextgetEntityTag in interface ContainerResponseContextnull if not present.public Date getLastModified()
ContainerResponseContextgetLastModified in interface ContainerResponseContextnull if not present.public URI getLocation()
ContainerResponseContextgetLocation in interface ContainerResponseContextnull if not present.public Set<Link> getLinks()
ContainerResponseContextgetLinks in interface ContainerResponseContextSet if no links are present. Never
returns null.public boolean hasLink(String relation)
ContainerResponseContexthasLink in interface ContainerResponseContextrelation - link relation.true if the for the relation link exists, false
otherwise.public Link getLink(String relation)
ContainerResponseContextgetLink in interface ContainerResponseContextrelation - link relation.null if not present.public Link.Builder getLinkBuilder(String relation)
ContainerResponseContextLink.Builder
for the relation.getLinkBuilder in interface ContainerResponseContextrelation - link relation.null if not
present.public boolean hasEntity()
ContainerResponseContexttrue if the entity is present, returns
false otherwise.hasEntity in interface ContainerResponseContexttrue if there is an entity present in the message,
false otherwise.public Object getEntity()
ContainerResponseContextnull if the message does not contain an entity.getEntity in interface ContainerResponseContextnull if message does not contain an
entity body.public OutputStream getEntityStream()
ContainerResponseContextgetEntityStream in interface ContainerResponseContextpublic void setEntityStream(OutputStream entityStream)
ContainerResponseContextsetEntityStream in interface ContainerResponseContextentityStream - new entity output stream.public Annotation[] getEntityAnnotations()
ContainerResponseContext
Note that the returned annotations array contains only those annotations
explicitly attached to entity instance (such as the ones attached using
Response.ResponseBuilder.entity(Object, java.lang.annotation.Annotation[]) method
or the ones attached to the resource method that returned the response).
The entity instance annotations array does not include annotations declared on the entity
implementation class or its ancestors.
getEntityAnnotations in interface ContainerResponseContextpublic MultivaluedMap<String,String> getStringHeaders()
ContainerResponseContextheaders map are reflected
in this view.
The method converts the non-string header values to strings using a
RuntimeDelegate.HeaderDelegate if one is available via
RuntimeDelegate.createHeaderDelegate(java.lang.Class) for the
class of the value or using the values toString method if a header delegate is
not available.
getStringHeaders in interface ContainerResponseContextContainerResponseContext.getHeaders(),
ContainerResponseContext.getHeaderString(String)public String getHeaderString(String name)
ContainerResponseContextRuntimeDelegate.HeaderDelegate if one is available
via RuntimeDelegate.createHeaderDelegate(java.lang.Class)
for the header value class or using its toString method if a header
delegate is not available.getHeaderString in interface ContainerResponseContextname - the message header.null is returned. If the message header is present but has no
value then the empty string is returned. If the message header is present
more than once then the values of joined together and separated by a ','
character.ContainerResponseContext.getHeaders(),
ContainerResponseContext.getStringHeaders()Copyright © 2013. All Rights Reserved.