org.jboss.resteasy.core.interception

## Class PreMatchContainerRequestContext

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

- All Implemented Interfaces:
    ContainerRequestContext
  Direct Known Subclasses:
    PostMatchContainerRequestContext, ResponseContainerRequestContext

      public class PreMatchContainerRequestContext
      extends Object
      implements ContainerRequestContext

  Version:
    $Revision: 1 $
  Author:
    Bill Burke

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected HttpRequest` | `httpRequest`
    `protected Response` | `response`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `PreMatchContainerRequestContext(HttpRequest request)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `abortWith(Response response)` Abort the filter chain with a response.
    `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.
    `Map<String,Cookie>` | `getCookies()` Get any cookies that accompanied the request.
    `Date` | `getDate()` Get message date.
    `InputStream` | `getEntityStream()` Get the entity input stream.
    `MultivaluedMap<String,String>` | `getHeaders()` Get the mutable request headers multivalued map.
    `String` | `getHeaderString(String name)` Get a message header as a single string value.
    `HttpRequest` | `getHttpRequest()`
    `Locale` | `getLanguage()` Get the language of the entity.
    `int` | `getLength()` Get Content-Length value.
    `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.
    `Request` | `getRequest()` Get the injectable request information.
    `Response` | `getResponseAbortedWith()`
    `SecurityContext` | `getSecurityContext()` Get the injectable security context information for the current request.
    `UriInfo` | `getUriInfo()` Get request URI information.
    `boolean` | `hasEntity()` Check if there is a non-empty entity input stream available in the request message.
    `void` | `removeProperty(String name)` Removes a property with the given name from the current request/response exchange context.
    `void` | `setEntityStream(InputStream entityStream)` Set a new entity input 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` | `setRequestUri(URI requestUri)` Set a new request URI using the current base URI of the application to resolve the application-specific request URI part.
    `void` | `setRequestUri(URI baseUri, URI requestUri)` Set a new request URI using a new base URI to resolve the application-specific request URI part.
    `void` | `setSecurityContext(SecurityContext context)` Set a new injectable security context information for the current request.

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

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

- - ### Field Detail

    - #### httpRequest

          protected final HttpRequest httpRequest

    - #### response

          protected Response response

  - ### Constructor Detail

    - #### PreMatchContainerRequestContext

          public PreMatchContainerRequestContext(HttpRequest request)

  - ### Method Detail

    - #### getHttpRequest

          public HttpRequest getHttpRequest()

    - #### getResponseAbortedWith

          public Response getResponseAbortedWith()

    - #### getProperty

          public Object getProperty(String name)

      Description copied from interface: `ContainerRequestContext`
      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 `ContainerRequestContext.getPropertyNames()`. Custom property names should follow the same convention as package names.

      In a Servlet container, the properties are synchronized with the `ServletRequest` and expose all the attributes available in the `ServletRequest`. Any modifications of the properties are also reflected in the set of properties of the associated `ServletRequest`.

      Specified by:
        `getProperty` in interface `ContainerRequestContext`
      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:
        `ContainerRequestContext.getPropertyNames()`

    - #### getPropertyNames

          public Collection<String> getPropertyNames()

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

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

      In a Servlet container, the properties are synchronized with the `ServletRequest` and expose all the attributes available in the `ServletRequest`. Any modifications of the properties are also reflected in the set of properties of the associated `ServletRequest`.

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

    - #### setProperty

          public void setProperty(String name,
                         Object object)

      Description copied from interface: `ContainerRequestContext`
      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 `ContainerRequestContext.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 `ContainerRequestContext.removeProperty(String)` method.

      In a Servlet container, the properties are synchronized with the `ServletRequest` and expose all the attributes available in the `ServletRequest`. Any modifications of the properties are also reflected in the set of properties of the associated `ServletRequest`.

      Specified by:
        `setProperty` in interface `ContainerRequestContext`
      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: `ContainerRequestContext`
      Removes a property with the given name from the current request/response exchange context. After removal, subsequent calls to `ContainerRequestContext.getProperty(java.lang.String)` to retrieve the property value will return `null`.

      In a Servlet container, the properties are synchronized with the `ServletRequest` and expose all the attributes available in the `ServletRequest`. Any modifications of the properties are also reflected in the set of properties of the associated `ServletRequest`.

      Specified by:
        `removeProperty` in interface `ContainerRequestContext`
      Parameters:
        `name` - a `String` specifying the name of the property to be removed.

    - #### getUriInfo

          public UriInfo getUriInfo()

      Description copied from interface: `ContainerRequestContext`
      Get request URI information. The returned object contains "live" view of the request URI information in a sense that any changes made to the request URI using one of the `setRequestUri(...)` methods will be reflected in the previously returned `UriInfo` instance.
      Specified by:
        `getUriInfo` in interface `ContainerRequestContext`
      Returns:
        request URI information.

    - #### setRequestUri

          public void setRequestUri(URI requestUri)
                             throws IllegalStateException

      Description copied from interface: `ContainerRequestContext`
      Set a new request URI using the current base URI of the application to resolve the application-specific request URI part.

      Note that the method is usable only in pre-matching filters, prior to the resource matching occurs. Trying to invoke the method in a filter bound to a resource method results in an `IllegalStateException` being thrown.

      Specified by:
        `setRequestUri` in interface `ContainerRequestContext`
      Parameters:
        `requestUri` - new URI of the request.
      Throws:
        `IllegalStateException` - in case the method is not invoked from a `pre-matching` request filter.
      See Also:
        `ContainerRequestContext.setRequestUri(java.net.URI, java.net.URI)`

    - #### setRequestUri

          public void setRequestUri(URI baseUri,
                           URI requestUri)
                             throws IllegalStateException

      Description copied from interface: `ContainerRequestContext`
      Set a new request URI using a new base URI to resolve the application-specific request URI part.

      Note that the method is usable only in pre-matching filters, prior to the resource matching occurs. Trying to invoke the method in a filter bound to a resource method results in an `IllegalStateException` being thrown.

      Specified by:
        `setRequestUri` in interface `ContainerRequestContext`
      Parameters:
        `baseUri` - base URI that will be used to resolve the application-specific part of the request URI.
        `requestUri` - new URI of the request.
      Throws:
        `IllegalStateException` - in case the method is not invoked from a `pre-matching` request filter.
      See Also:
        `ContainerRequestContext.setRequestUri(java.net.URI)`

    - #### getMethod

          public String getMethod()

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

    - #### setMethod

          public void setMethod(String method)

      Description copied from interface: `ContainerRequestContext`
      Set the request method.

      Note that the method is usable only in pre-matching filters, prior to the resource matching occurs. Trying to invoke the method in a filter bound to a resource method results in an `IllegalStateException` being thrown.

      Specified by:
        `setMethod` in interface `ContainerRequestContext`
      Parameters:
        `method` - new request method.
      See Also:
        `HttpMethod`

    - #### getHeaders

          public MultivaluedMap<String,String> getHeaders()

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

    - #### getDate

          public Date getDate()

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

    - #### getLanguage

          public Locale getLanguage()

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

    - #### getLength

          public int getLength()

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

    - #### getMediaType

          public MediaType getMediaType()

      Description copied from interface: `ContainerRequestContext`
      Get the media type of the entity.
      Specified by:
        `getMediaType` in interface `ContainerRequestContext`
      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: `ContainerRequestContext`
      Get a list of media types that are acceptable for the response.
      Specified by:
        `getAcceptableMediaTypes` in interface `ContainerRequestContext`
      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: `ContainerRequestContext`
      Get a list of languages that are acceptable for the response.
      Specified by:
        `getAcceptableLanguages` in interface `ContainerRequestContext`
      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: `ContainerRequestContext`
      Get any cookies that accompanied the request.
      Specified by:
        `getCookies` in interface `ContainerRequestContext`
      Returns:
        a read-only map of cookie name (String) to `Cookie`.

    - #### hasEntity

          public boolean hasEntity()

      Description copied from interface: `ContainerRequestContext`
      Check if there is a non-empty entity input stream available in the request message. The method returns `true` if the entity is present, returns `false` otherwise.
      Specified by:
        `hasEntity` in interface `ContainerRequestContext`
      Returns:
        `true` if there is an entity present in the message, `false` otherwise.

    - #### getEntityStream

          public InputStream getEntityStream()

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

    - #### setEntityStream

          public void setEntityStream(InputStream entityStream)

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

    - #### getSecurityContext

          public SecurityContext getSecurityContext()

      Description copied from interface: `ContainerRequestContext`
      Get the injectable security context information for the current request. The `SecurityContext.getUserPrincipal()` must return `null` if the current request has not been authenticated.
      Specified by:
        `getSecurityContext` in interface `ContainerRequestContext`
      Returns:
        injectable request security context information.

    - #### setSecurityContext

          public void setSecurityContext(SecurityContext context)

      Description copied from interface: `ContainerRequestContext`
      Set a new injectable security context information for the current request. The `SecurityContext.getUserPrincipal()` must return `null` if the current request has not been authenticated.
      Specified by:
        `setSecurityContext` in interface `ContainerRequestContext`
      Parameters:
        `context` - new injectable request security context information.

    - #### getRequest

          public Request getRequest()

      Description copied from interface: `ContainerRequestContext`
      Get the injectable request information.
      Specified by:
        `getRequest` in interface `ContainerRequestContext`
      Returns:
        injectable request information.

    - #### abortWith

          public void abortWith(Response response)

      Description copied from interface: `ContainerRequestContext`
      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 `ContainerRequestContext`
      Parameters:
        `response` - response to be sent back to the client.

    - #### getHeaderString

          public String getHeaderString(String name)

      Description copied from interface: `ContainerRequestContext`
      Get a message header as a single string value.
      Specified by:
        `getHeaderString` in interface `ContainerRequestContext`
      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:
        `ContainerRequestContext.getHeaders()`

Copyright © 2014. All Rights Reserved.