org.jboss.resteasy.client.jaxrs.internal

## Class ClientRequestContextImpl

- java.lang.Object
- - org.jboss.resteasy.client.jaxrs.internal.ClientRequestContextImpl

- All Implemented Interfaces:
    ClientRequestContext

      public class ClientRequestContextImpl
      extends Object
      implements ClientRequestContext

  Version:
    $Revision: 1 $
  Author:
    Bill Burke

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected Response` | `abortedWithResponse`
    `protected ClientInvocation` | `invocation`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ClientRequestContextImpl(ClientInvocation invocation)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `abortWith(Response response)` Abort the filter chain with a response.
    `Response` | `getAbortedWithResponse()`
    `List<Locale>` | `getAcceptableLanguages()` Get a list of languages that are acceptable for the response.
    `List<MediaType>` | `getAcceptableMediaTypes()` Get a list of media types that are acceptable for the response.
    `Client` | `getClient()` Get the client instance associated with the request.
    `Configuration` | `getConfiguration()` Get the immutable configuration of the request.
    `Map<String,Cookie>` | `getCookies()` Get any cookies that accompanied the request.
    `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.
    `Type` | `getEntityType()` Get the generic entity type information.
    `MultivaluedMap<String,Object>` | `getHeaders()` Get the mutable request headers multivalued map.
    `String` | `getHeaderString(String name)` Get a message header as a single string value.
    `Locale` | `getLanguage()` Get the language of the entity.
    `MediaType` | `getMediaType()` Get the media type of the entity.
    `String` | `getMethod()` Get the request method.
    `Object` | `getProperty(String name)` Returns the property with the given name registered in the current request/response exchange context, or `null` if there is no property by that name.
    `Collection<String>` | `getPropertyNames()` Returns an immutable `collection` containing the property names available within the context of the current request/response exchange context.
    `MultivaluedMap<String,String>` | `getStringHeaders()` Get a string view of header values associated with the message.
    `URI` | `getUri()` Get the request URI.
    `boolean` | `hasEntity()` Check if there is an entity available in the request.
    `void` | `removeProperty(String name)` Removes a property with the given name from the current request/response exchange context.
    `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` | `setMethod(String method)` Set the request method.
    `void` | `setProperty(String name, Object object)` Binds an object to a given property name in the current request/response exchange context.
    `void` | `setUri(URI uri)` Set a new request URI.

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

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

- - ### Field Detail

    - #### invocation

          protected ClientInvocation invocation

    - #### abortedWithResponse

          protected Response abortedWithResponse

  - ### Constructor Detail

    - #### ClientRequestContextImpl

          public ClientRequestContextImpl(ClientInvocation invocation)

  - ### Method Detail

    - #### getAbortedWithResponse

          public Response getAbortedWithResponse()

    - #### getProperty

          public Object getProperty(String name)

      Description copied from interface: `ClientRequestContext`
      Returns the property with the given name registered in the current request/response exchange context, or `null` if there is no property by that name.

      A property allows a JAX-RS filters and interceptors to exchange additional custom information not already provided by this interface.

      A list of supported properties can be retrieved using `ClientRequestContext.getPropertyNames()`. Custom property names should follow the same convention as package names.

      Specified by:
        `getProperty` in interface `ClientRequestContext`
      Parameters:
        `name` - a `String` specifying the name of the property.
      Returns:
        an `Object` containing the value of the property, or `null` if no property exists matching the given name.
      See Also:
        `ClientRequestContext.getPropertyNames()`

    - #### getPropertyNames

          public Collection<String> getPropertyNames()

      Description copied from interface: `ClientRequestContext`
      Returns an immutable `collection` containing the property names available within the context of the current request/response exchange context.

      Use the `ClientRequestContext.getProperty(java.lang.String)` method with a property name to get the value of a property.

      Specified by:
        `getPropertyNames` in interface `ClientRequestContext`
      Returns:
        an immutable `collection` of property names.
      See Also:
        `ClientRequestContext.getProperty(java.lang.String)`

    - #### setProperty

          public void setProperty(String name,
                         Object object)

      Description copied from interface: `ClientRequestContext`
      Binds an object to a given property name in the current request/response exchange context. If the name specified is already used for a property, this method will replace the value of the property with the new value.

      A property allows a JAX-RS filters and interceptors to exchange additional custom information not already provided by this interface.

      A list of supported properties can be retrieved using `ClientRequestContext.getPropertyNames()`. Custom property names should follow the same convention as package names.

      If a `null` value is passed, the effect is the same as calling the `ClientRequestContext.removeProperty(String)` method.

      Specified by:
        `setProperty` in interface `ClientRequestContext`
      Parameters:
        `name` - a `String` specifying the name of the property.
        `object` - an `Object` representing the property to be bound.

    - #### removeProperty

          public void removeProperty(String name)

      Description copied from interface: `ClientRequestContext`
      Removes a property with the given name from the current request/response exchange context. After removal, subsequent calls to `ClientRequestContext.getProperty(java.lang.String)` to retrieve the property value will return `null`.
      Specified by:
        `removeProperty` in interface `ClientRequestContext`
      Parameters:
        `name` - a `String` specifying the name of the property to be removed.

    - #### getEntityClass

          public Class<?> getEntityClass()

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

    - #### getEntityType

          public Type getEntityType()

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

    - #### setEntity

          public void setEntity(Object entity)

      Description copied from interface: `ClientRequestContext`
      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 `ClientRequestContext`
      Parameters:
        `entity` - entity object.
      See Also:
        `ClientRequestContext.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: `ClientRequestContext`
      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 `ClientRequestContext`
      Parameters:
        `entity` - entity object.
        `annotations` - annotations attached to the entity instance.
        `mediaType` - entity media type.
      See Also:
        `ClientRequestContext.setEntity(Object)`, `MessageBodyWriter`

    - #### getUri

          public URI getUri()

      Description copied from interface: `ClientRequestContext`
      Get the request URI.
      Specified by:
        `getUri` in interface `ClientRequestContext`
      Returns:
        request URI.

    - #### setUri

          public void setUri(URI uri)

      Description copied from interface: `ClientRequestContext`
      Set a new request URI.
      Specified by:
        `setUri` in interface `ClientRequestContext`
      Parameters:
        `uri` - new request URI.

    - #### getMethod

          public String getMethod()

      Description copied from interface: `ClientRequestContext`
      Get the request method.
      Specified by:
        `getMethod` in interface `ClientRequestContext`
      Returns:
        the request method.
      See Also:
        `HttpMethod`

    - #### setMethod

          public void setMethod(String method)

      Description copied from interface: `ClientRequestContext`
      Set the request method.
      Specified by:
        `setMethod` in interface `ClientRequestContext`
      Parameters:
        `method` - new request method.
      See Also:
        `HttpMethod`

    - #### getHeaders

          public MultivaluedMap<String,Object> getHeaders()

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

    - #### getDate

          public Date getDate()

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

    - #### getLanguage

          public Locale getLanguage()

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

    - #### getMediaType

          public MediaType getMediaType()

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

    - #### getAcceptableMediaTypes

          public List<MediaType> getAcceptableMediaTypes()

      Description copied from interface: `ClientRequestContext`
      Get a list of media types that are acceptable for the response.
      Specified by:
        `getAcceptableMediaTypes` in interface `ClientRequestContext`
      Returns:
        a read-only list of requested response media types sorted according to their q-value, with highest preference first.

    - #### getAcceptableLanguages

          public List<Locale> getAcceptableLanguages()

      Description copied from interface: `ClientRequestContext`
      Get a list of languages that are acceptable for the response.
      Specified by:
        `getAcceptableLanguages` in interface `ClientRequestContext`
      Returns:
        a read-only list of acceptable languages sorted according to their q-value, with highest preference first.

    - #### getCookies

          public Map<String,Cookie> getCookies()

      Description copied from interface: `ClientRequestContext`
      Get any cookies that accompanied the request.
      Specified by:
        `getCookies` in interface `ClientRequestContext`
      Returns:
        a read-only map of cookie name (String) to `Cookie`.

    - #### hasEntity

          public boolean hasEntity()

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

    - #### getEntityStream

          public OutputStream getEntityStream()

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

    - #### setEntityStream

          public void setEntityStream(OutputStream entityStream)

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

    - #### getEntity

          public Object getEntity()

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

    - #### getEntityAnnotations

          public Annotation[] getEntityAnnotations()

      Description copied from interface: `ClientRequestContext`
      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 `Entity.Entity(Object, javax.ws.rs.core.MediaType, java.lang.annotation.Annotation[])` method). The entity instance annotations array does not include annotations declared on the entity implementation class or its ancestors.

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

    - #### getClient

          public Client getClient()

      Description copied from interface: `ClientRequestContext`
      Get the client instance associated with the request.
      Specified by:
        `getClient` in interface `ClientRequestContext`
      Returns:
        client instance associated with the request.

    - #### getConfiguration

          public Configuration getConfiguration()

      Description copied from interface: `ClientRequestContext`
      Get the immutable configuration of the request.
      Specified by:
        `getConfiguration` in interface `ClientRequestContext`
      Returns:
        immutable request configuration.

    - #### abortWith

          public void abortWith(Response response)

      Description copied from interface: `ClientRequestContext`
      Abort the filter chain with a response. This method breaks the filter chain processing and returns the provided response back to the client. The provided response goes through the chain of applicable response filters.
      Specified by:
        `abortWith` in interface `ClientRequestContext`
      Parameters:
        `response` - response to be sent back to the client.

    - #### getStringHeaders

          public MultivaluedMap<String,String> getStringHeaders()

      Description copied from interface: `ClientRequestContext`
      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 `ClientRequestContext`
      Returns:
        response headers as a string view of header values.
      See Also:
        `ClientRequestContext.getHeaders()`, `ClientRequestContext.getHeaderString(String)`

    - #### getHeaderString

          public String getHeaderString(String name)

      Description copied from interface: `ClientRequestContext`
      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 `ClientRequestContext`
      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:
        `ClientRequestContext.getHeaders()`, `ClientRequestContext.getStringHeaders()`

Copyright © 2014. All Rights Reserved.