org.jboss.resteasy.core.interception

## Class ContainerResponseContextImpl

- java.lang.Object
- - org.jboss.resteasy.core.interception.ContainerResponseContextImpl

- All Implemented Interfaces:
    ContainerResponseContext

      public class ContainerResponseContextImpl
      extends Object
      implements ContainerResponseContext

  Version:
    $Revision: 1 $
  Author:
    Bill Burke

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected HttpResponse` | `httpResponse`
    `protected BuiltResponse` | `jaxrsResponse`
    `protected HttpRequest` | `request`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ContainerResponseContextImpl(HttpRequest request, HttpResponse httpResponse, BuiltResponse serverResponse)`

  - ### Method Summary

    Methods
    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.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### request

          protected final HttpRequest request

    - #### httpResponse

          protected final HttpResponse httpResponse

    - #### jaxrsResponse

          protected final BuiltResponse jaxrsResponse

  - ### Constructor Detail

    - #### ContainerResponseContextImpl

          public ContainerResponseContextImpl(HttpRequest request,
                                      HttpResponse httpResponse,
                                      BuiltResponse serverResponse)

  - ### Method Detail

    - #### getJaxrsResponse

          public BuiltResponse getJaxrsResponse()

    - #### getHttpResponse

          public HttpResponse getHttpResponse()

    - #### getStatus

          public int getStatus()

      Description copied from interface: `ContainerResponseContext`
      Get the status code associated with the response.
      Specified by:
        `getStatus` in interface `ContainerResponseContext`
      Returns:
        the response status code or -1 if the status was not set.

    - #### setStatus

          public void setStatus(int code)

      Description copied from interface: `ContainerResponseContext`
      Set a new response status code.
      Specified by:
        `setStatus` in interface `ContainerResponseContext`
      Parameters:
        `code` - new status code.

    - #### getStatusInfo

          public Response.StatusType getStatusInfo()

      Description copied from interface: `ContainerResponseContext`
      Get the complete status information associated with the response.
      Specified by:
        `getStatusInfo` in interface `ContainerResponseContext`
      Returns:
        the response status information or `null` if the status was not set.

    - #### setStatusInfo

          public void setStatusInfo(Response.StatusType statusInfo)

      Description copied from interface: `ContainerResponseContext`
      Set the complete status information (status code and reason phrase) associated with the response.
      Specified by:
        `setStatusInfo` in interface `ContainerResponseContext`
      Parameters:
        `statusInfo` - the response status information.

    - #### getEntityClass

          public Class<?> getEntityClass()

      Description copied from interface: `ContainerResponseContext`
      Get the raw entity type information.
      Specified by:
        `getEntityClass` in interface `ContainerResponseContext`
      Returns:
        raw entity type.

    - #### getEntityType

          public Type getEntityType()

      Description copied from interface: `ContainerResponseContext`
      Get the generic entity type information.
      Specified by:
        `getEntityType` in interface `ContainerResponseContext`
      Returns:
        declared generic entity type.

    - #### setEntity

          public void setEntity(Object entity)

      Description copied from interface: `ContainerResponseContext`
      Set a new message entity. The existing entity `annotations` 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.

      Specified by:
        `setEntity` in interface `ContainerResponseContext`
      Parameters:
        `entity` - entity object.
      See Also:
        `ContainerResponseContext.setEntity(Object, java.lang.annotation.Annotation[], javax.ws.rs.core.MediaType)`, `MessageBodyWriter`

    - #### setEntity

          public void setEntity(Object entity,
                       Annotation[] annotations,
                       MediaType mediaType)

      Description copied from interface: `ContainerResponseContext`
      Set a new message entity, including the attached annotations and the media type.

      It is the callers responsibility to wrap the actual entity with `GenericEntity` if preservation of its generic type is required.

      Specified by:
        `setEntity` in interface `ContainerResponseContext`
      Parameters:
        `entity` - entity object.
        `annotations` - annotations attached to the entity instance.
        `mediaType` - entity media type.
      See Also:
        `ContainerResponseContext.setEntity(Object)`, `MessageBodyWriter`

    - #### getHeaders

          public MultivaluedMap<String,Object> getHeaders()

      Description copied from interface: `ContainerResponseContext`
      Get the mutable response headers multivalued map.
      Specified by:
        `getHeaders` in interface `ContainerResponseContext`
      Returns:
        mutable multivalued map of response headers.
      See Also:
        `ContainerResponseContext.getStringHeaders()`, `ContainerResponseContext.getHeaderString(String)`

    - #### getAllowedMethods

          public Set<String> getAllowedMethods()

      Description copied from interface: `ContainerResponseContext`
      Get the allowed HTTP methods from the Allow HTTP header.
      Specified by:
        `getAllowedMethods` in interface `ContainerResponseContext`
      Returns:
        the allowed HTTP methods, all methods will returned as upper case strings.

    - #### getDate

          public Date getDate()

      Description copied from interface: `ContainerResponseContext`
      Get message date.
      Specified by:
        `getDate` in interface `ContainerResponseContext`
      Returns:
        the message date, otherwise `null` if not present.

    - #### getLanguage

          public Locale getLanguage()

      Description copied from interface: `ContainerResponseContext`
      Get the language of the entity.
      Specified by:
        `getLanguage` in interface `ContainerResponseContext`
      Returns:
        the language of the entity or `null` if not specified

    - #### getLength

          public int getLength()

      Description copied from interface: `ContainerResponseContext`
      Get Content-Length value.
      Specified by:
        `getLength` in interface `ContainerResponseContext`
      Returns:
        Content-Length as integer if present and valid number. In other cases returns -1.

    - #### getMediaType

          public MediaType getMediaType()

      Description copied from interface: `ContainerResponseContext`
      Get the media type of the entity.
      Specified by:
        `getMediaType` in interface `ContainerResponseContext`
      Returns:
        the media type or `null` if not specified (e.g. there's no response entity).

    - #### getCookies

          public Map<String,NewCookie> getCookies()

      Description copied from interface: `ContainerResponseContext`
      Get any new cookies set on the response message.
      Specified by:
        `getCookies` in interface `ContainerResponseContext`
      Returns:
        a read-only map of cookie name (String) to a `new cookie`.

    - #### getEntityTag

          public EntityTag getEntityTag()

      Description copied from interface: `ContainerResponseContext`
      Get the entity tag.
      Specified by:
        `getEntityTag` in interface `ContainerResponseContext`
      Returns:
        the entity tag, otherwise `null` if not present.

    - #### getLastModified

          public Date getLastModified()

      Description copied from interface: `ContainerResponseContext`
      Get the last modified date.
      Specified by:
        `getLastModified` in interface `ContainerResponseContext`
      Returns:
        the last modified date, otherwise `null` if not present.

    - #### getLocation

          public URI getLocation()

      Description copied from interface: `ContainerResponseContext`
      Get the location.
      Specified by:
        `getLocation` in interface `ContainerResponseContext`
      Returns:
        the location URI, otherwise `null` if not present.

    - #### getLinks

          public Set<Link> getLinks()

      Description copied from interface: `ContainerResponseContext`
      Get the links attached to the message as header.
      Specified by:
        `getLinks` in interface `ContainerResponseContext`
      Returns:
        links, may return empty `Set` if no links are present. Never returns `null`.

    - #### hasLink

          public boolean hasLink(String relation)

      Description copied from interface: `ContainerResponseContext`
      Check if link for relation exists.
      Specified by:
        `hasLink` in interface `ContainerResponseContext`
      Parameters:
        `relation` - link relation.
      Returns:
        `true` if the for the relation link exists, `false` otherwise.

    - #### getLink

          public Link getLink(String relation)

      Description copied from interface: `ContainerResponseContext`
      Get the link for the relation.
      Specified by:
        `getLink` in interface `ContainerResponseContext`
      Parameters:
        `relation` - link relation.
      Returns:
        the link for the relation, otherwise `null` if not present.

    - #### getLinkBuilder

          public Link.Builder getLinkBuilder(String relation)

      Description copied from interface: `ContainerResponseContext`
      Convenience method that returns a `Link.Builder` for the relation.
      Specified by:
        `getLinkBuilder` in interface `ContainerResponseContext`
      Parameters:
        `relation` - link relation.
      Returns:
        the link builder for the relation, otherwise `null` if not present.

    - #### hasEntity

          public boolean hasEntity()

      Description copied from interface: `ContainerResponseContext`
      Check if there is an entity available in the response. The method returns `true` if the entity is present, returns `false` otherwise.
      Specified by:
        `hasEntity` in interface `ContainerResponseContext`
      Returns:
        `true` if there is an entity present in the message, `false` otherwise.

    - #### getEntity

          public Object getEntity()

      Description copied from interface: `ContainerResponseContext`
      Get the message entity Java instance. Returns `null` if the message does not contain an entity.
      Specified by:
        `getEntity` in interface `ContainerResponseContext`
      Returns:
        the message entity or `null` if message does not contain an entity body.

    - #### getEntityStream

          public OutputStream getEntityStream()

      Description copied from interface: `ContainerResponseContext`
      Get the entity output stream. The JAX-RS runtime is responsible for closing the output stream.
      Specified by:
        `getEntityStream` in interface `ContainerResponseContext`
      Returns:
        entity output stream.

    - #### setEntityStream

          public void setEntityStream(OutputStream entityStream)

      Description copied from interface: `ContainerResponseContext`
      Set a new entity output stream. The JAX-RS runtime is responsible for closing the output stream.
      Specified by:
        `setEntityStream` in interface `ContainerResponseContext`
      Parameters:
        `entityStream` - new entity output stream.

    - #### getEntityAnnotations

          public Annotation[] getEntityAnnotations()

      Description copied from interface: `ContainerResponseContext`
      Get the annotations attached to the entity instance.

      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.

      Specified by:
        `getEntityAnnotations` in interface `ContainerResponseContext`
      Returns:
        annotations attached to the entity instance.

    - #### getStringHeaders

          public MultivaluedMap<String,String> getStringHeaders()

      Description copied from interface: `ContainerResponseContext`
      Get a string view of header values associated with the message. Changes in the underlying `headers 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.

      Specified by:
        `getStringHeaders` in interface `ContainerResponseContext`
      Returns:
        response headers as a string view of header values.
      See Also:
        `ContainerResponseContext.getHeaders()`, `ContainerResponseContext.getHeaderString(String)`

    - #### getHeaderString

          public String getHeaderString(String name)

      Description copied from interface: `ContainerResponseContext`
      Get a message header as a single string value. Each single header value is converted to String using a `RuntimeDelegate.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.
      Specified by:
        `getHeaderString` in interface `ContainerResponseContext`
      Parameters:
        `name` - the message header.
      Returns:
        the message header value. If the message header is not present then `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.
      See Also:
        `ContainerResponseContext.getHeaders()`, `ContainerResponseContext.getStringHeaders()`

Copyright © 2014. All Rights Reserved.