Class InboundMessageContext
java.lang.Object
org.glassfish.jersey.message.internal.MessageHeaderMethods
org.glassfish.jersey.message.internal.InboundMessageContext
- All Implemented Interfaces:
org.glassfish.jersey.innate.io.SafelyClosable
- Direct Known Subclasses:
ClientResponse,ContainerRequest
public abstract class InboundMessageContext
extends MessageHeaderMethods
implements org.glassfish.jersey.innate.io.SafelyClosable
Base inbound message context implementation.
- Author:
- Marek Potociar
-
Field Summary
Fields inherited from class org.glassfish.jersey.message.internal.MessageHeaderMethods
runtimeDelegateDecorator -
Constructor Summary
ConstructorsConstructorDescriptionDeprecated.InboundMessageContext(boolean translateNce) Deprecated.InboundMessageContext(Configuration configuration) Create new inbound message context.InboundMessageContext(Configuration configuration, boolean translateNce) Create new inbound message context.InboundMessageContext(Configuration configuration, MultivaluedMap<String, String> httpHeaders, boolean translateNce) Create new inbound message context. -
Method Summary
Modifier and TypeMethodDescriptionbooleanBuffer the entity stream (if not empty).voidclose()Closes the underlying content stream.The related client/server sideConfiguration.Get the entity input stream.Get the mutable message headers multivalued map.getHeaderString(String name) Get a message header as a single string value.ReturnHeaderValueException.Contexttype of the message context.Get If-Match header.Get If-None-Match header.getLinks()Get the links attached to the message as header.Get the media type of the entity.Get a list of languages that are acceptable for the message.Get a list of media types that are acceptable for a request.Get the list of language tag from the "Accept-Charset" of an HTTP request.Get the list of language tag from the "Accept-Charset" of an HTTP request.protected abstract Iterable<ReaderInterceptor>Get reader interceptors bound to this context.Get context message body workers.booleanCheck if there is a non-empty entity input stream is available in the message.Add a new header value.headers(MultivaluedMap<String, String> newHeaders) Add new headers.Add new header values.Add new header values.Add new headers.<T> TreadEntity(Class<T> rawType, Annotation[] annotations, PropertiesDelegate propertiesDelegate) Read entity from a context entity input stream.<T> TreadEntity(Class<T> rawType, Type type, Annotation[] annotations, PropertiesDelegate propertiesDelegate) Read entity from a context entity input stream.<T> TreadEntity(Class<T> rawType, Type type, PropertiesDelegate propertiesDelegate) Read entity from a context entity input stream.<T> TreadEntity(Class<T> rawType, PropertiesDelegate propertiesDelegate) Read entity from a context entity input stream.Remove a header.voidsetEntityStream(InputStream input) Set a new entity input stream.voidsetWorkers(MessageBodyWorkers workers) Set context message body workers.voidwrapEntityInputStream(org.glassfish.jersey.innate.io.StreamListenerCouple stream) Provides the wholeEntityInputStreamto the requestMethods inherited from class org.glassfish.jersey.message.internal.MessageHeaderMethods
containsHeaderString, containsHeaderString, exception, getAllowedMethods, getDate, getEntityTag, getLanguage, getLastModified, getLength, getLengthLong, getLink, getLinkBuilder, getLocation, getRequestCookies, getResponseCookies, hasLink, singleHeader, singleHeader
-
Constructor Details
-
InboundMessageContext
Create new inbound message context.- Parameters:
configuration- the related client/server sideConfiguration
-
InboundMessageContext
Create new inbound message context.- Parameters:
configuration- the related client/server sideConfiguration. Ifnull, the default behaviour is expected.translateNce- iftrue, theNoContentExceptionthrown by a selected message body reader will be translated into aBadRequestExceptionas required by JAX-RS specification on the server side.
-
InboundMessageContext
public InboundMessageContext(Configuration configuration, MultivaluedMap<String, String> httpHeaders, boolean translateNce) Create new inbound message context.- Parameters:
configuration- the related client/server sideConfiguration. Ifnull, the default behaviour is expected.httpHeaders- the http headers map.translateNce- iftrue, thejavax.ws.rs.core.NoContentExceptionthrown by a selected message body reader will be translated into ajavax.ws.rs.BadRequestExceptionas required by JAX-RS specification on the server side.
-
InboundMessageContext
Deprecated.Create new inbound message context.- See Also:
-
InboundMessageContext
Deprecated.Create new inbound message context.- Parameters:
translateNce- iftrue, theNoContentExceptionthrown by a selected message body reader will be translated into aBadRequestExceptionas required by JAX-RS specification on the server side. *- See Also:
-
-
Method Details
-
header
Add a new header value.- Parameters:
name- header name.value- header value.- Returns:
- updated context.
-
headers
Add new header values.- Parameters:
name- header name.values- header values.- Returns:
- updated context.
-
headers
Add new header values.- Parameters:
name- header name.values- header values.- Returns:
- updated context.
-
headers
Add new headers.- Parameters:
newHeaders- new headers.- Returns:
- updated context.
-
headers
Add new headers.- Parameters:
newHeaders- new headers.- Returns:
- updated context.
-
remove
Remove a header.- Parameters:
name- header name.- Returns:
- updated context.
-
getHeaderString
Get a message header as a single string value. Each single header value is converted to String using aRuntimeDelegate.HeaderDelegateif one is available viaRuntimeDelegate.createHeaderDelegate(java.lang.Class)for the header value class or using itstoStringmethod if a header delegate is not available.- Specified by:
getHeaderStringin classMessageHeaderMethods- Parameters:
name- the message header.- Returns:
- the message header value. If the message header is not present then
nullis 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
Description copied from class:MessageHeaderMethodsReturnHeaderValueException.Contexttype of the message context.- Specified by:
getHeaderValueExceptionContextin classMessageHeaderMethods- Returns:
HeaderValueException.Contexttype of the message context.
-
getHeaders
Get the mutable message headers multivalued map.- Specified by:
getHeadersin classMessageHeaderMethods- Returns:
- mutable multivalued map of message headers.
-
getIfMatch
Get If-Match header.- Returns:
- the If-Match header value, otherwise
nullif not present.
-
getIfNoneMatch
Get If-None-Match header.- Returns:
- the If-None-Match header value, otherwise
nullif not present.
-
getMediaType
Get the media type of the entity.- Returns:
- the media type or
nullif not specified (e.g. there's no message entity).
-
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
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
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
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
Get the links attached to the message as header.- Specified by:
getLinksin classMessageHeaderMethods- Returns:
- links, may return empty
Setif no links are present. Never returnsnull.
-
getWorkers
Get context message body workers.- Returns:
- context message body workers.
-
setWorkers
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 returnstrueif the entity is present, returnsfalseotherwise.- Returns:
trueif there is an entity present in the message,falseotherwise.
-
getEntityStream
Get the entity input stream.- Returns:
- entity input stream.
-
setEntityStream
Set a new entity input stream.- Parameters:
input- new entity input stream.
-
wrapEntityInputStream
public void wrapEntityInputStream(org.glassfish.jersey.innate.io.StreamListenerCouple stream) Provides the wholeEntityInputStreamto the request- Parameters:
stream- the whole input stream entity
-
readEntity
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
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
Buffer the entity stream (if not empty).- Returns:
trueif the entity input stream was successfully buffered.- Throws:
ProcessingException- in case of an IO error.
-
close
public void close()Closes the underlying content stream.- Specified by:
closein interfaceorg.glassfish.jersey.innate.io.SafelyClosable
-
getReaderInterceptors
Get reader interceptors bound to this context.Interceptors will be used when one of the
readEntitymethods is invoked.- Returns:
- reader interceptors bound to this context.
-
getConfiguration
The related client/server sideConfiguration. Can benull.- Returns:
Configurationthe configuration
-