Top Description Methods
javax.ws.rs.client

public Interface ClientRequestContext

Imports
java.io.OutputStream, java.lang.annotation.Annotation, java.lang.reflect.Type, java.net.URI, java.util.Collection, .Date, .List, .Locale, .Map, javax.ws.rs.core.Configuration, .Cookie, .MediaType, .MultivaluedMap, .Response, javax.ws.rs.ext.MessageBodyWriter

Client request filter context. A mutable class that provides request-specific information for the filter, such as request URI, message headers, message entity or request-scoped properties. The exposed setters allow modification of the exposed request-specific information.
Author
Marek Potociar
Since
2.0

Method Summary

Modifier and TypeMethod and Description
public void
abortWith(Response
response to be sent back to the client.
response
)

Abort the filter chain with a response.

public List<Locale>

Returns:

a read-only list of acceptable languages sorted according to their q-value, with highest preference first.
getAcceptableLanguages
()

Get a list of languages that are acceptable for the response.

public List<MediaType>

Returns:

a read-only list of requested response media types sorted according to their q-value, with highest preference first.
getAcceptableMediaTypes
()

Get a list of media types that are acceptable for the response.

public Client

Returns:

client instance associated with the request.
getClient
()

Get the client instance associated with the request.

public Configuration

Returns:

immutable request configuration.
getConfiguration
()

Get the immutable configuration of the request.

public Map<String, Cookie>

Returns:

a read-only map of cookie name (String) to Cookie.
getCookies
()

Get any cookies that accompanied the request.

public Date

Returns:

the message date, otherwise null if not present.
getDate
()

Get message date.

public Object

Returns:

the message entity or null if message does not contain an entity body.
getEntity
()

Get the message entity Java instance.

public Annotation[]

Returns:

annotations attached to the entity instance.
getEntityAnnotations
()

Get the annotations attached to the entity instance.

public Class<?>

Returns:

raw entity type.
getEntityClass
()

Get the raw entity type information.

public OutputStream

Returns:

entity output stream.
getEntityStream
()

Get the entity output stream.

public Type

Returns:

generic entity type.
getEntityType
()

Get the generic entity type information.

public MultivaluedMap<String, Object>

Returns:

mutable multivalued map of request headers.
getHeaders
()

Get the mutable request headers multivalued map.

public String

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.
getHeaderString
(String
the message header.
name
)

Get a message header as a single string value.

public Locale

Returns:

the language of the entity or null if not specified
getLanguage
()

Get the language of the entity.

public MediaType

Returns:

the media type or null if not specified (e.g. there's no request entity).
getMediaType
()

Get the media type of the entity.

public String

Returns:

the request method.
getMethod
()

Get the request method.

public Object

Returns:

an Object containing the value of the property, or null if no property exists matching the given name.
getProperty
(String
a String specifying the name of the property.
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.

public Collection<String>

Returns:

an immutable collection of property names.
getPropertyNames
()

Returns an immutable collection containing the property names available within the context of the current request/response exchange context.

public MultivaluedMap<String, String>

Returns:

response headers as a string view of header values.
getStringHeaders
()

Get a string view of header values associated with the message.

public URI

Returns:

request URI.
getUri
()

Get the request URI.

public boolean

Returns:

true if there is an entity present in the message, false otherwise.
hasEntity
()

Check if there is an entity available in the request.

public void
removeProperty(String
a String specifying the name of the property to be removed.
name
)

Removes a property with the given name from the current request/response exchange context.

public void
setEntity(final Object
entity object.
entity
)

Set a new message entity.

public void
setEntity(final Object
entity object.
entity
,
final Annotation[]
annotations attached to the entity instance.
annotations
,
final MediaType
entity media type.
mediaType
)

Set a new message entity, including the attached annotations and the media type.

public void
setEntityStream(OutputStream
new entity output stream.
outputStream
)

Set a new entity output stream.

public void
setMethod(String
new request method.
method
)

Set the request method.

public void
setProperty(String
a String specifying the name of the property.
name
,
Object
an Object representing the property to be bound.
object
)

Binds an object to a given property name in the current request/response exchange context.

public void
setUri(URI
new request URI.
uri
)

Set a new request URI.

Method Detail

abortWithback to summary
public void abortWith(Response response)

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.

Parameters
response:Response

response to be sent back to the client.

getAcceptableLanguagesback to summary
public List<Locale> getAcceptableLanguages()

Get a list of languages that are acceptable for the response.

Returns:List<Locale>

a read-only list of acceptable languages sorted according to their q-value, with highest preference first.

getAcceptableMediaTypesback to summary
public List<MediaType> getAcceptableMediaTypes()

Get a list of media types that are acceptable for the response.

Returns:List<MediaType>

a read-only list of requested response media types sorted according to their q-value, with highest preference first.

getClientback to summary
public Client getClient()

Get the client instance associated with the request.

Returns:Client

client instance associated with the request.

getConfigurationback to summary
public Configuration getConfiguration()

Get the immutable configuration of the request.

Returns:Configuration

immutable request configuration.

getCookiesback to summary
public Map<String, Cookie> getCookies()

Get any cookies that accompanied the request.

Returns:Map<String, Cookie>

a read-only map of cookie name (String) to Cookie.

getDateback to summary
public Date getDate()

Get message date.

Returns:Date

the message date, otherwise null if not present.

getEntityback to summary
public Object getEntity()

Get the message entity Java instance. Returns null if the message does not contain an entity.

Returns:Object

the message entity or null if message does not contain an entity body.

getEntityAnnotationsback to summary
public Annotation[] getEntityAnnotations()

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.

Returns:Annotation[]

annotations attached to the entity instance.

getEntityClassback to summary
public Class<?> getEntityClass()

Get the raw entity type information.

Returns:Class<?>

raw entity type.

getEntityStreamback to summary
public OutputStream getEntityStream()

Get the entity output stream. The JAX-RS runtime is responsible for closing the output stream.

Returns:OutputStream

entity output stream.

getEntityTypeback to summary
public Type getEntityType()

Get the generic entity type information.

Returns:Type

generic entity type.

getHeadersback to summary
public MultivaluedMap<String, Object> getHeaders()

Get the mutable request headers multivalued map.

Returns:MultivaluedMap<String, Object>

mutable multivalued map of request headers.

See Also
getStringHeaders(), getHeaderString(String)
getHeaderStringback to summary
public String getHeaderString(String name)

Get a message header as a single string value. Each single header value is converted to String using a javax.ws.rs.ext.RuntimeDelegate.HeaderDelegate if one is available via javax.ws.rs.ext.RuntimeDelegate#createHeaderDelegate(java.lang.Class) for the header value class or using its toString method if a header delegate is not available.

Parameters
name:String

the message header.

Returns:String

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
getHeaders(), getStringHeaders()
getLanguageback to summary
public Locale getLanguage()

Get the language of the entity.

Returns:Locale

the language of the entity or null if not specified

getMediaTypeback to summary
public MediaType getMediaType()

Get the media type of the entity.

Returns:MediaType

the media type or null if not specified (e.g. there's no request entity).

getMethodback to summary
public String getMethod()

Get the request method.

Returns:String

the request method.

See Also
javax.ws.rs.HttpMethod
getPropertyback to summary
public 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.

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 getPropertyNames(). Custom property names should follow the same convention as package names.

Parameters
name:String

a String specifying the name of the property.

Returns:Object

an Object containing the value of the property, or null if no property exists matching the given name.

See Also
getPropertyNames()
getPropertyNamesback to summary
public Collection<String> getPropertyNames()

Returns an immutable collection containing the property names available within the context of the current request/response exchange context.

Use the getProperty method with a property name to get the value of a property.

Returns:Collection<String>

an immutable collection of property names.

See Also
getProperty
getStringHeadersback to summary
public MultivaluedMap<String, String> getStringHeaders()

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 javax.ws.rs.ext.RuntimeDelegate.HeaderDelegate if one is available via javax.ws.rs.ext.RuntimeDelegate#createHeaderDelegate(java.lang.Class) for the class of the value or using the values toString method if a header delegate is not available.

Returns:MultivaluedMap<String, String>

response headers as a string view of header values.

See Also
getHeaders(), getHeaderString(String)
getUriback to summary
public URI getUri()

Get the request URI.

Returns:URI

request URI.

hasEntityback to summary
public boolean hasEntity()

Check if there is an entity available in the request. The method returns true if the entity is present, returns false otherwise.

Returns:boolean

true if there is an entity present in the message, false otherwise.

removePropertyback to summary
public void removeProperty(String name)

Removes a property with the given name from the current request/response exchange context. After removal, subsequent calls to getProperty to retrieve the property value will return null.

Parameters
name:String

a String specifying the name of the property to be removed.

setEntityback to summary
public void setEntity(final Object entity)

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 javax.ws.rs.core.GenericEntity if preservation of its generic type is required.

Parameters
entity:Object

entity object.

See Also
setEntity(Object, java.lang.annotation.Annotation[], javax.ws.rs.core.MediaType), MessageBodyWriter
setEntityback to summary
public void setEntity(final Object entity, final Annotation[] annotations, final MediaType mediaType)

Set a new message entity, including the attached annotations and the media type.

It is the callers responsibility to wrap the actual entity with javax.ws.rs.core.GenericEntity if preservation of its generic type is required.

Parameters
entity:Object

entity object.

annotations:Annotation[]

annotations attached to the entity instance.

mediaType:MediaType

entity media type.

See Also
setEntity(Object), MessageBodyWriter
setEntityStreamback to summary
public void setEntityStream(OutputStream outputStream)

Set a new entity output stream. The JAX-RS runtime is responsible for closing the output stream.

Parameters
outputStream:OutputStream

new entity output stream.

setMethodback to summary
public void setMethod(String method)

Set the request method.

Parameters
method:String

new request method.

See Also
javax.ws.rs.HttpMethod
setPropertyback to summary
public void setProperty(String name, Object object)

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 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 removeProperty(String) method.

Parameters
name:String

a String specifying the name of the property.

object:Object

an Object representing the property to be bound.

setUriback to summary
public void setUri(URI uri)

Set a new request URI.

Parameters
uri:URI

new request URI.