javax.ws.rs.container
Interface ContainerResponseContext


public interface ContainerResponseContext

Container response filter context. A mutable class that provides response-specific information for the filter, such as message headers, message entity or request-scoped properties. The exposed setters allow modification of the exposed response-specific information.

Since:
2.0
Author:
Marek Potociar (marek.potociar at oracle.com)

Method Summary
 java.util.Set<java.lang.String> getAllowedMethods()
          Get the allowed HTTP methods from the Allow HTTP header.
 java.util.Map<java.lang.String,NewCookie> getCookies()
          Get any new cookies set on the response message.
 java.util.Date getDate()
          Get message date.
 GenericType<?> getDeclaredEntityType()
          Get the declared generic message entity type information.
 java.lang.Object getEntity()
          Get the message entity Java instance.
 java.lang.annotation.Annotation[] getEntityAnnotations()
          Get the annotations attached to the entity.
 java.io.OutputStream getEntityStream()
          Get the entity output stream.
 EntityTag getEntityTag()
          Get the entity tag.
 MultivaluedMap<java.lang.String,java.lang.Object> getHeaders()
          Get the mutable response headers multivalued map.
 java.util.Locale getLanguage()
          Get the language of the 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 entity.
 int getStatusCode()
          Get the status code associated with the response.
 boolean hasEntity()
          Check if there is an entity available in the response.
 boolean hasLink(java.lang.String relation)
          Check if link for relation exists.
<T> void
setEntity(java.lang.Class<T> type, java.lang.annotation.Annotation[] annotations, MediaType mediaType, T entity)
          Set a new response message entity.
<T> void
setEntity(GenericType<T> type, java.lang.annotation.Annotation[] annotations, MediaType mediaType, T entity)
          Set a new response message entity.
 void setEntityStream(java.io.OutputStream input)
          Set a new entity output stream.
 void setStatusCode(int code)
          Set a new response status code.
 

Method Detail

getStatusCode

int getStatusCode()
Get the status code associated with the response.

Returns:
the response status code or -1 if the status was not set.

setStatusCode

void setStatusCode(int code)
Set a new response status code.

Parameters:
code - new status code.

getHeaders

MultivaluedMap<java.lang.String,java.lang.Object> getHeaders()
Get the mutable response headers multivalued map.

Returns:
mutable multivalued map of response headers.

getAllowedMethods

java.util.Set<java.lang.String> getAllowedMethods()
Get the allowed HTTP methods from the Allow HTTP header.

Returns:
the allowed HTTP methods, all methods will returned as upper case strings.

getDate

java.util.Date getDate()
Get message date.

Returns:
the message date, otherwise null if not present.

getLanguage

java.util.Locale getLanguage()
Get the language of the entity.

Returns:
the language of the entity or null if not specified

getLength

int getLength()
Get Content-Length value.

Returns:
Content-Length as integer if present and valid number. In other cases returns -1.

getMediaType

MediaType getMediaType()
Get the media type of the entity.

Returns:
the media type or null if not specified (e.g. there's no response entity).

getCookies

java.util.Map<java.lang.String,NewCookie> getCookies()
Get any new cookies set on the response message.

Returns:
a read-only map of cookie name (String) to a new cookie.

getEntityTag

EntityTag getEntityTag()
Get the entity tag.

Returns:
the entity tag, otherwise null if not present.

getLastModified

java.util.Date getLastModified()
Get the last modified date.

Returns:
the last modified date, otherwise null if not present.

getLocation

java.net.URI getLocation()
Get the location.

Returns:
the location URI, otherwise null if not present.

getLinks

java.util.Set<Link> getLinks()
Get the links attached to the message as header.

Returns:
links, may return empty Set if no links are present. Never returns null.

hasLink

boolean hasLink(java.lang.String relation)
Check if link for relation exists.

Parameters:
relation - link relation.
Returns:
true if the for the relation link exists, false otherwise.

getLink

Link getLink(java.lang.String relation)
Get the link for the relation.

Parameters:
relation - link relation.
Returns:
the link for the relation, otherwise null if not present.

getLinkBuilder

Link.Builder getLinkBuilder(java.lang.String relation)
Convenience method that returns a Link.Builder for the relation.

Parameters:
relation - link relation.
Returns:
the link builder for the relation, otherwise null if not present.

hasEntity

boolean hasEntity()
Check if there is an entity available in the response. The method returns true if the entity is present, returns false otherwise.

Returns:
true if there is an entity present in the message, false otherwise.

getEntity

java.lang.Object getEntity()
Get the message entity Java instance. Returns null if the message does not contain an entity.

Returns:
the message entity or null if message does not contain an entity body.

setEntity

<T> void setEntity(java.lang.Class<T> type,
                   java.lang.annotation.Annotation[] annotations,
                   MediaType mediaType,
                   T entity)
Set a new response message entity.

Type Parameters:
T - entity Java type.
Parameters:
type - declared entity class.
annotations - annotations attached to the entity.
mediaType - entity media type.
entity - entity object.
See Also:
MessageBodyWriter

setEntity

<T> void setEntity(GenericType<T> type,
                   java.lang.annotation.Annotation[] annotations,
                   MediaType mediaType,
                   T entity)
Set a new response message entity.

Type Parameters:
T - entity Java type.
Parameters:
type - declared generic entity type.
annotations - annotations attached to the entity.
mediaType - entity media type.
entity - entity object.
See Also:
MessageBodyWriter

getDeclaredEntityType

GenericType<?> getDeclaredEntityType()
Get the declared generic message entity type information.

Returns:
declared generic message entity type.

getEntityAnnotations

java.lang.annotation.Annotation[] getEntityAnnotations()
Get the annotations attached to the entity.

Returns:
entity annotations.

getEntityStream

java.io.OutputStream getEntityStream()
Get the entity output stream.

Returns:
entity output stream.

setEntityStream

void setEntityStream(java.io.OutputStream input)
Set a new entity output stream.

Parameters:
input - new entity output stream.


Copyright © 2007-2012 Oracle Corporation. All Rights Reserved. Use is subject to license terms.