|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjavax.ws.rs.core.Response
org.glassfish.jersey.message.internal.OutboundJaxrsResponse
public class OutboundJaxrsResponse
An outbound JAX-RS response message.
The implementation delegates method calls to an underlying
outbound message context.
| Nested Class Summary | |
|---|---|
static class |
OutboundJaxrsResponse.Builder
Outbound JAX-RS Response.ResponseBuilder implementation. |
| Nested classes/interfaces inherited from class javax.ws.rs.core.Response |
|---|
Response.ResponseBuilder, Response.Status, Response.StatusType |
| Constructor Summary | |
|---|---|
OutboundJaxrsResponse(Response.StatusType status,
OutboundMessageContext context)
Create new outbound JAX-RS response message instance. |
|
| Method Summary | ||
|---|---|---|
boolean |
bufferEntity()
Buffer the message entity data. |
|
void |
close()
Close the underlying message entity input stream (if available and open) as well as releases any other resources associated with the response (e.g. |
|
java.util.Set<java.lang.String> |
getAllowedMethods()
Get the allowed HTTP methods from the Allow HTTP header. |
|
OutboundMessageContext |
getContext()
Get the underlying outbound message context. |
|
java.util.Map<java.lang.String,NewCookie> |
getCookies()
Get any new cookies set on the response message. |
|
java.util.Date |
getDate()
Get message date. |
|
java.lang.Object |
getEntity()
Get the message entity Java instance. |
|
EntityTag |
getEntityTag()
Get the entity tag. |
|
java.lang.String |
getHeaderString(java.lang.String name)
Get a message header as a single string value. |
|
java.util.Locale |
getLanguage()
Get the language of the message entity. |
|
java.util.Date |
getLastModified()
Get the last modified date. |
|
int |
getLength()
Get Content-Length value. |
|
Link |
getLink(java.lang.String relation)
Get the link for the relation. |
|
Link.Builder |
getLinkBuilder(java.lang.String relation)
Convenience method that returns a Link.Builder for the relation. |
|
java.util.Set<Link> |
getLinks()
Get the links attached to the message as header. |
|
java.net.URI |
getLocation()
Get the location. |
|
MediaType |
getMediaType()
Get the media type of the message entity. |
|
MultivaluedMap<java.lang.String,java.lang.Object> |
getMetadata()
See Response.getHeaders(). |
|
int |
getStatus()
Get the status code associated with the response. |
|
Response.StatusType |
getStatusInfo()
Get the complete status information associated with the response. |
|
MultivaluedMap<java.lang.String,java.lang.String> |
getStringHeaders()
Get view of the response headers and their string values. |
|
boolean |
hasEntity()
Check if there is an entity available in the response. |
|
boolean |
hasLink(java.lang.String relation)
Check if link for relation exists. |
|
|
readEntity(java.lang.Class<T> type)
Read the message entity input stream as an instance of specified Java type using a MessageBodyReader that supports mapping the
message entity stream onto the requested type. |
|
|
readEntity(java.lang.Class<T> type,
java.lang.annotation.Annotation[] annotations)
Read the message entity input stream as an instance of specified Java type using a MessageBodyReader that supports mapping the
message entity stream onto the requested type. |
|
|
readEntity(GenericType<T> entityType)
Read the message entity input stream as an instance of specified Java type using a MessageBodyReader that supports mapping the
message entity stream onto the requested type. |
|
|
readEntity(GenericType<T> entityType,
java.lang.annotation.Annotation[] annotations)
Read the message entity input stream as an instance of specified Java type using a MessageBodyReader that supports mapping the
message entity stream onto the requested type. |
|
static OutboundJaxrsResponse |
unwrap(Response response)
Unwrap an OutboundJaxrsResponse instance from a given response. |
|
| Methods inherited from class javax.ws.rs.core.Response |
|---|
accepted, accepted, created, fromResponse, getHeaders, noContent, notAcceptable, notModified, notModified, notModified, ok, ok, ok, ok, ok, seeOther, serverError, status, status, status, temporaryRedirect |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public OutboundJaxrsResponse(Response.StatusType status,
OutboundMessageContext context)
status - response status.context - underlying outbound message context.| Method Detail |
|---|
public static OutboundJaxrsResponse unwrap(Response response)
response - response instance to unwrap.
OutboundJaxrsResponse instance.
java.lang.IllegalArgumentException - in case the instance cannot be down-casted.public OutboundMessageContext getContext()
public int getStatus()
Response
getStatus in class Responsepublic Response.StatusType getStatusInfo()
Response
getStatusInfo in class Responsenull.public java.lang.Object getEntity()
Responsenull if the message
does not contain an entity body.
If the entity is represented by an un-consumed input stream
the method will return the input stream.
getEntity in class Responsenull if message does not contain an
entity body.
public <T> T readEntity(java.lang.Class<T> type)
throws MessageProcessingException
ResponseMessageBodyReader that supports mapping the
message entity stream onto the requested type.
Method throws an MessageProcessingException if the content of the
message cannot be mapped to an entity of the requested type and
IllegalStateException in case the entity is not backed by an input
stream or if the entity input stream has already been consumed and has not
been buffered prior consuming.
If the message does not contain an entity body null is returned.
A non-null message instance returned from this method will be cached for
subsequent retrievals via Response.getEntity(). Unless the supplied entity
type is an input stream, this method automatically
closes the consumed response entity stream if it is not
buffered. In case he entity input stream has been buffered, it will be
reset when the method returns to enable
subsequent invocations of the readEntity(...) methods on this response.
readEntity in class ResponseT - entity instance Java type.type - the type of entity.
null if message does not contain an
entity body.
MessageProcessingException - if the content of the message cannot be
mapped to an entity of the requested type.MessageBodyReader
public <T> T readEntity(GenericType<T> entityType)
throws MessageProcessingException
ResponseMessageBodyReader that supports mapping the
message entity stream onto the requested type.
Method throws an MessageProcessingException if the content of the
message cannot be mapped to an entity of the requested type and
IllegalStateException in case the entity is not backed by an input
stream or if the entity input stream has already been consumed and has not
been buffered prior consuming.
If the message does not contain an entity body null is returned.
A non-null message instance returned from this method will be cached for
subsequent retrievals via Response.getEntity(). Unless the supplied entity
type is an input stream, this method automatically
closes the consumed response entity stream if it is not
buffered. In case he entity input stream has been buffered, it will be
reset when the method returns to enable
subsequent invocations of the readEntity(...) methods on this response.
readEntity in class ResponseT - entity instance Java type.entityType - the type of entity; may be generic.
null if message does not contain an
entity body.
MessageProcessingException - if the content of the message cannot be
mapped to an entity of the requested type.MessageBodyReader
public <T> T readEntity(java.lang.Class<T> type,
java.lang.annotation.Annotation[] annotations)
throws MessageProcessingException
ResponseMessageBodyReader that supports mapping the
message entity stream onto the requested type.
Method throws an MessageProcessingException if the content of the
message cannot be mapped to an entity of the requested type and
IllegalStateException in case the entity is not backed by an input
stream or if the entity input stream has already been consumed and has not
been buffered prior consuming.
If the message does not contain an entity body null is returned.
A non-null message instance returned from this method will be cached for
subsequent retrievals via Response.getEntity(). Unless the supplied entity
type is an input stream, this method automatically
closes the consumed response entity stream if it is not
buffered. In case he entity input stream has been buffered, it will be
reset when the method returns to enable
subsequent invocations of the readEntity(...) methods on this response.
readEntity in class ResponseT - entity instance Java type.type - the type of entity.annotations - annotations that will be passed to the MessageBodyReader.
null if message does not contain an
entity body.
MessageProcessingException - if the content of the message cannot be
mapped to an entity of the requested type.MessageBodyReader
public <T> T readEntity(GenericType<T> entityType,
java.lang.annotation.Annotation[] annotations)
throws MessageProcessingException
ResponseMessageBodyReader that supports mapping the
message entity stream onto the requested type.
Method throws an MessageProcessingException if the content of the
message cannot be mapped to an entity of the requested type and
IllegalStateException in case the entity is not backed by an input
stream or if the entity input stream has already been consumed and has not
been buffered prior consuming.
If the message does not contain an entity body null is returned.
A non-null message instance returned from this method will be cached for
subsequent retrievals via Response.getEntity(). Unless the supplied entity
type is an input stream, this method automatically
closes the consumed response entity stream if it is not
buffered. In case he entity input stream has been buffered, it will be
reset when the method returns to enable
subsequent invocations of the readEntity(...) methods on this response.
readEntity in class ResponseT - entity instance Java type.entityType - the type of entity; may be generic.annotations - annotations that will be passed to the MessageBodyReader.
null if message does not contain an
entity body.
MessageProcessingException - if the content of the message cannot be
mapped to an entity of the requested type.MessageBodyReaderpublic boolean hasEntity()
Responsetrue if the entity is present, returns false otherwise.
hasEntity in class Responsetrue if there is an entity present in the message,
false otherwise.
public boolean bufferEntity()
throws MessageProcessingException
Response
In case the message entity is backed by an unconsumed entity input stream,
all the bytes of the original entity input stream are read and stored locally.
The original entity input stream is consumed and automatically
closed as part of the operation and the method returns true.
In case the response entity instance is not backed by an unconsumed input stream
an invocation of bufferEntity method is ignored and the method returns
false.
This operation is idempotent, i.e. it can be invoked multiple times with
the same effect which also means that calling the bufferEntity()
method on an already buffered (and thus closed) message instance is legal
and has no further effect. Also, the result returned by the bufferEntity()
method is consistent across all invocations of the method on the same
Response instance.
Buffering the message entity data allows for multiple invocations of
readEntity(...) methods on the response instance. Note however, that
once the response instance itself is closed, the implementations
are expected to release the buffered message entity data. Therefore any subsequent
attempts to read a message entity stream on such closed response will result in an
IllegalStateException being thrown.
bufferEntity in class Responsetrue if the message entity input stream was available and
was buffered successfully, returns false if the entity stream
was not available.
MessageProcessingException - if there was an error while buffering the entity
input stream.
public void close()
throws MessageProcessingException
Responsebuffered message entity data).
This operation is idempotent, i.e. it can be invoked multiple times with the
same effect which also means that calling the close() method on an
already closed message instance is legal and has no further effect.
The close() method should be invoked on all instances that
contain an un-consumed entity input stream to ensure the resources associated
with the instance are properly cleaned-up and prevent potential memory leaks.
This is typical for client-side scenarios where application layer code
processes only the response headers and ignores the response entity.
Any attempts to manipulate (read, get, buffer) a message entity on a closed response
will result in an IllegalStateException being thrown.
close in class ResponseMessageProcessingException - if there is an error closing the response.public MultivaluedMap<java.lang.String,java.lang.String> getStringHeaders()
Response
getStringHeaders in class ResponseResponse.getHeaders(),
Response.getHeaderString(java.lang.String)public java.lang.String getHeaderString(java.lang.String name)
ResponseRuntimeDelegate.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 class Responsename - 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.Response.getHeaders(),
Response.getStringHeaders()public MediaType getMediaType()
Response
getMediaType in class Responsenull if there is no response entity.public java.util.Locale getLanguage()
Response
getLanguage in class Responsepublic int getLength()
Response
getLength in class Response-1.public java.util.Map<java.lang.String,NewCookie> getCookies()
Response
getCookies in class Responsepublic EntityTag getEntityTag()
Response
getEntityTag in class Responsenull if not present.public java.util.Date getDate()
Response
getDate in class Responsenull if not present.public java.util.Date getLastModified()
Response
getLastModified in class Responsenull if not present.public java.util.Set<java.lang.String> getAllowedMethods()
Response
getAllowedMethods in class Responsepublic java.net.URI getLocation()
Response
getLocation in class Responsenull if not present.public java.util.Set<Link> getLinks()
Response
getLinks in class ResponseSet if no links are present. Does
not return null.public boolean hasLink(java.lang.String relation)
Response
hasLink in class Responserelation - link relation.
true if the link for the relation is present in the
message headers, false otherwise.public Link getLink(java.lang.String relation)
Response
getLink in class Responserelation - link relation.
null if not present.public Link.Builder getLinkBuilder(java.lang.String relation)
ResponseLink.Builder for the relation.
getLinkBuilder in class Responserelation - link relation.
null if not
present.public MultivaluedMap<java.lang.String,java.lang.Object> getMetadata()
ResponseResponse.getHeaders().
This method is considered deprecated. Users are encouraged to switch their
code to use the getHeaders() method instead. The method may be annotated
as @Deprecated in a future release of JAX-RS API.
getMetadata in class Response
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||