Class InboundMessageContext

java.lang.Object
org.glassfish.jersey.message.internal.MessageHeaderMethods
org.glassfish.jersey.message.internal.InboundMessageContext
Direct Known Subclasses:
ClientResponse, ContainerRequest

public abstract class InboundMessageContext extends MessageHeaderMethods
Base inbound message context implementation.
Author:
Marek Potociar
  • Constructor Details

    • InboundMessageContext

      public InboundMessageContext(Configuration configuration)
      Create new inbound message context.
      Parameters:
      configuration - the related client/server side Configuration
    • InboundMessageContext

      public InboundMessageContext(Configuration configuration, boolean translateNce)
      Create new inbound message context.
      Parameters:
      configuration - the related client/server side Configuration. If null, the default behaviour is expected.
      translateNce - if true, the NoContentException thrown by a selected message body reader will be translated into a BadRequestException as required by JAX-RS specification on the server side.
    • InboundMessageContext

      @Deprecated public InboundMessageContext()
      Deprecated.
      Create new inbound message context.
      See Also:
    • InboundMessageContext

      @Deprecated public InboundMessageContext(boolean translateNce)
      Deprecated.
      Create new inbound message context.
      Parameters:
      translateNce - if true, the NoContentException thrown by a selected message body reader will be translated into a BadRequestException as required by JAX-RS specification on the server side. *
      See Also:
  • Method Details

    • header

      public InboundMessageContext header(String name, Object value)
      Add a new header value.
      Parameters:
      name - header name.
      value - header value.
      Returns:
      updated context.
    • headers

      public InboundMessageContext headers(String name, Object... values)
      Add new header values.
      Parameters:
      name - header name.
      values - header values.
      Returns:
      updated context.
    • headers

      public InboundMessageContext headers(String name, Iterable<?> values)
      Add new header values.
      Parameters:
      name - header name.
      values - header values.
      Returns:
      updated context.
    • headers

      public InboundMessageContext headers(MultivaluedMap<String,String> newHeaders)
      Add new headers.
      Parameters:
      newHeaders - new headers.
      Returns:
      updated context.
    • headers

      public InboundMessageContext headers(Map<String,List<String>> newHeaders)
      Add new headers.
      Parameters:
      newHeaders - new headers.
      Returns:
      updated context.
    • remove

      public InboundMessageContext remove(String name)
      Remove a header.
      Parameters:
      name - header name.
      Returns:
      updated context.
    • getHeaderString

      public String getHeaderString(String name)
      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 class MessageHeaderMethods
      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.
    • getHeaderValueExceptionContext

      public HeaderValueException.Context getHeaderValueExceptionContext()
      Description copied from class: MessageHeaderMethods
      Return HeaderValueException.Context type of the message context.
      Specified by:
      getHeaderValueExceptionContext in class MessageHeaderMethods
      Returns:
      HeaderValueException.Context type of the message context.
    • getHeaders

      public MultivaluedMap<String,String> getHeaders()
      Get the mutable message headers multivalued map.
      Specified by:
      getHeaders in class MessageHeaderMethods
      Returns:
      mutable multivalued map of message headers.
    • getIfMatch

      public Set<MatchingEntityTag> getIfMatch()
      Get If-Match header.
      Returns:
      the If-Match header value, otherwise null if not present.
    • getIfNoneMatch

      public Set<MatchingEntityTag> getIfNoneMatch()
      Get If-None-Match header.
      Returns:
      the If-None-Match header value, otherwise null if not present.
    • getMediaType

      public MediaType getMediaType()
      Get the media type of the entity.
      Returns:
      the media type or null if not specified (e.g. there's no message entity).
    • getQualifiedAcceptableMediaTypes

      public List<AcceptableMediaType> getQualifiedAcceptableMediaTypes()
      Get a list of media types that are acceptable for a request.
      Returns:
      a read-only list of requested response media types sorted according to their q-value, with highest preference first.
    • getQualifiedAcceptableLanguages

      public List<AcceptableLanguageTag> getQualifiedAcceptableLanguages()
      Get a list of languages that are acceptable for the message.
      Returns:
      a read-only list of acceptable languages sorted according to their q-value, with highest preference first.
    • getQualifiedAcceptCharset

      public List<AcceptableToken> getQualifiedAcceptCharset()
      Get the list of language tag from the "Accept-Charset" of an HTTP request.
      Returns:
      The list of AcceptableToken. This list is ordered with the highest quality acceptable charset occurring first.
    • getQualifiedAcceptEncoding

      public List<AcceptableToken> getQualifiedAcceptEncoding()
      Get the list of language tag from the "Accept-Charset" of an HTTP request.
      Returns:
      The list of AcceptableToken. This list is ordered with the highest quality acceptable charset occurring first.
    • getLinks

      public Set<Link> getLinks()
      Get the links attached to the message as header.
      Specified by:
      getLinks in class MessageHeaderMethods
      Returns:
      links, may return empty Set if no links are present. Never returns null.
    • getWorkers

      public MessageBodyWorkers getWorkers()
      Get context message body workers.
      Returns:
      context message body workers.
    • setWorkers

      public void setWorkers(MessageBodyWorkers workers)
      Set context message body workers.
      Parameters:
      workers - context message body workers.
    • hasEntity

      public boolean hasEntity()
      Check if there is a non-empty entity input stream is available in the message.

      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.
    • getEntityStream

      public InputStream getEntityStream()
      Get the entity input stream.
      Returns:
      entity input stream.
    • setEntityStream

      public void setEntityStream(InputStream input)
      Set a new entity input stream.
      Parameters:
      input - new entity input stream.
    • readEntity

      public <T> T readEntity(Class<T> rawType, PropertiesDelegate propertiesDelegate)
      Read entity from a context entity input stream.
      Type Parameters:
      T - entity Java object type.
      Parameters:
      rawType - raw Java entity type.
      propertiesDelegate - request-scoped properties delegate.
      Returns:
      entity read from a context entity input stream.
    • readEntity

      public <T> T readEntity(Class<T> rawType, Annotation[] annotations, PropertiesDelegate propertiesDelegate)
      Read entity from a context entity input stream.
      Type Parameters:
      T - entity Java object type.
      Parameters:
      rawType - raw Java entity type.
      annotations - entity annotations.
      propertiesDelegate - request-scoped properties delegate.
      Returns:
      entity read from a context entity input stream.
    • readEntity

      public <T> T readEntity(Class<T> rawType, Type type, PropertiesDelegate propertiesDelegate)
      Read entity from a context entity input stream.
      Type Parameters:
      T - entity Java object type.
      Parameters:
      rawType - raw Java entity type.
      type - generic Java entity type.
      propertiesDelegate - request-scoped properties delegate.
      Returns:
      entity read from a context entity input stream.
    • readEntity

      public <T> T readEntity(Class<T> rawType, Type type, Annotation[] annotations, PropertiesDelegate propertiesDelegate)
      Read entity from a context entity input stream.
      Type Parameters:
      T - entity Java object type.
      Parameters:
      rawType - raw Java entity type.
      type - generic Java entity type.
      annotations - entity annotations.
      propertiesDelegate - request-scoped properties delegate.
      Returns:
      entity read from a context entity input stream.
    • bufferEntity

      public boolean bufferEntity() throws ProcessingException
      Buffer the entity stream (if not empty).
      Returns:
      true if the entity input stream was successfully buffered.
      Throws:
      ProcessingException - in case of an IO error.
    • close

      public void close()
      Closes the underlying content stream.
    • getReaderInterceptors

      protected abstract Iterable<ReaderInterceptor> getReaderInterceptors()
      Get reader interceptors bound to this context.

      Interceptors will be used when one of the readEntity methods is invoked.

      Returns:
      reader interceptors bound to this context.
    • getConfiguration

      public Configuration getConfiguration()
      The related client/server side Configuration. Can be null.
      Returns:
      Configuration the configuration