|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.glassfish.jersey.server.ContainerResponse
public class ContainerResponse
Jersey container response context.
| Constructor Summary | |
|---|---|
ContainerResponse(ContainerRequest requestContext,
Response response)
Create a new Jersey container response context. |
|
| Method Summary | |
|---|---|
void |
close()
Closes the response. |
void |
commitStream()
Commit the entity stream unless already committed. |
void |
enableBuffering(Configuration configuration)
Enable a buffering of serialized entity. |
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. |
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. |
ContainerRequest |
getRequestContext()
Get the associated container request context paired with this response context. |
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. |
OutboundMessageContext |
getWrappedMessageContext()
Get the wrapped response message context. |
boolean |
hasEntity()
Check if there is an entity available in the response. |
boolean |
hasLink(String relation)
Check if link for relation exists. |
boolean |
isChunked()
Returns true if the response entity is a ChunkedOutput instance. |
boolean |
isCommitted()
Returns true if the entity stream has been committed. |
boolean |
isMappedFromException()
Returns true if the response is result of the exception (for example created during .ExceptionMapper exception mapping). |
void |
setEntity(Object entity)
Set a new message message entity. |
void |
setEntity(Object entity,
Annotation[] annotations)
Set a new message message entity. |
void |
setEntity(Object entity,
Annotation[] annotations,
MediaType mediaType)
Set a new message entity, including the attached annotations and the media type. |
void |
setEntity(Object entity,
Type type,
Annotation[] annotations)
Set a new message message entity. |
void |
setEntityAnnotations(Annotation[] annotations)
Set the annotations attached to the entity. |
void |
setEntityStream(OutputStream outputStream)
Set a new entity output stream. |
void |
setEntityType(Type type)
Set the message entity type information. |
void |
setMappedFromException(boolean mappedFromException)
Sets the flag indicating whether the response was created based on the exception. |
void |
setMediaType(MediaType mediaType)
Set the message content media type. |
void |
setStatus(int code)
Set a new response status code. |
void |
setStatusInfo(Response.StatusType status)
Set the complete status information (status code and reason phrase) associated with the response. |
void |
setStreamProvider(OutboundMessageContext.StreamProvider streamProvider)
Set the output stream provider callback. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ContainerResponse(ContainerRequest requestContext,
Response response)
requestContext - associated container request context.response - response instance initializing the response context.| Method Detail |
|---|
public boolean isMappedFromException()
.ExceptionMapper exception mapping).
public void setMappedFromException(boolean mappedFromException)
mappedFromException - True if this exception if result of the exception (for example result of
exception mapping).public int getStatus()
ContainerResponseContext
getStatus in interface ContainerResponseContextpublic void setStatus(int code)
ContainerResponseContext
setStatus in interface ContainerResponseContextcode - new status code.public void setStatusInfo(Response.StatusType status)
ContainerResponseContext
setStatusInfo in interface ContainerResponseContextstatus - the response status information.public Response.StatusType getStatusInfo()
ContainerResponseContext
getStatusInfo in interface ContainerResponseContextnull if the status was
not set.public ContainerRequest getRequestContext()
public Map<String,NewCookie> getCookies()
ContainerResponseContext
getCookies in interface ContainerResponseContextnew cookie.public OutboundMessageContext getWrappedMessageContext()
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()public MultivaluedMap<String,Object> getHeaders()
ContainerResponseContext
getHeaders in interface ContainerResponseContextContainerResponseContext.getStringHeaders(),
ContainerResponseContext.getHeaderString(String)public 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 Date getDate()
ContainerResponseContext
getDate in interface ContainerResponseContextnull if not present.public Locale getLanguage()
ContainerResponseContext
getLanguage in interface ContainerResponseContextnull if not specifiedpublic MediaType getMediaType()
ContainerResponseContext
getMediaType in interface ContainerResponseContextnull if not specified (e.g. there's no
response entity).public Set<String> getAllowedMethods()
ContainerResponseContext
getAllowedMethods in interface ContainerResponseContextpublic int getLength()
ContainerResponseContext
getLength in interface ContainerResponseContextpublic EntityTag getEntityTag()
ContainerResponseContext
getEntityTag in interface ContainerResponseContextnull if not present.public Date getLastModified()
ContainerResponseContext
getLastModified in interface ContainerResponseContextnull if not present.public URI getLocation()
ContainerResponseContext
getLocation in interface ContainerResponseContextnull if not present.public Set<Link> getLinks()
ContainerResponseContext
getLinks in interface ContainerResponseContextSet if no links are present. Never
returns null.public boolean hasLink(String relation)
ContainerResponseContext
hasLink in interface ContainerResponseContextrelation - link relation.
true if the for the relation link exists, false
otherwise.public Link getLink(String relation)
ContainerResponseContext
getLink 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 void setEntity(Object entity)
setEntity in interface ContainerResponseContextentity - entity object.MessageBodyWriter
public void setEntity(Object entity,
Annotation[] annotations)
entity - entity object.annotations - annotations attached to the entity.MessageBodyWriter
public void setEntity(Object entity,
Type type,
Annotation[] annotations)
entity - entity object.type - declared entity class.annotations - annotations attached to the entity.MessageBodyWriter
public 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 void setMediaType(MediaType mediaType)
mediaType - message content media type.public Class<?> getEntityClass()
ContainerResponseContext
getEntityClass in interface ContainerResponseContextpublic Type getEntityType()
ContainerResponseContext
getEntityType in interface ContainerResponseContextpublic void setEntityType(Type type)
type - overriding message entity type.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 void setEntityAnnotations(Annotation[] annotations)
annotations - entity annotations.public OutputStream getEntityStream()
ContainerResponseContext
getEntityStream in interface ContainerResponseContextpublic void setEntityStream(OutputStream outputStream)
ContainerResponseContext
setEntityStream in interface ContainerResponseContextoutputStream - new entity output stream.public void setStreamProvider(OutboundMessageContext.StreamProvider streamProvider)
entity stream.
streamProvider - non-null output stream provider.public void enableBuffering(Configuration configuration)
CommonProperties.OUTBOUND_CONTENT_LENGTH_BUFFER.
The buffering functionality is by default disabled and could be enabled by calling this method. In this case
this method must be called before first bytes are written to the entity stream.
configuration - runtime configuration.
public void commitStream()
throws IOException
entity stream unless already committed.
IOException - in case of the IO error.public boolean isCommitted()
true if the entity stream has been committed.
true if the entity stream has been committed. Otherwise returns false.public void close()
public boolean isChunked()
true if the response entity is a ChunkedOutput instance.
true if the entity is a ChunkedOutput instance, false otherwise.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||