public class ClientRequestContextImpl extends Object implements ClientRequestContext
| Modifier and Type | Field and Description |
|---|---|
protected Response |
abortedWithResponse |
protected ClientInvocation |
invocation |
| Constructor and Description |
|---|
ClientRequestContextImpl(ClientInvocation invocation) |
| 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.
|
protected ClientInvocation invocation
protected Response abortedWithResponse
public ClientRequestContextImpl(ClientInvocation invocation)
public Response getAbortedWithResponse()
public Object getProperty(String name)
ClientRequestContextnull 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.
getProperty in interface ClientRequestContextname - a String specifying the name of the property.Object containing the value of the property, or
null if no property exists matching the given name.ClientRequestContext.getPropertyNames()public Collection<String> getPropertyNames()
ClientRequestContextcollection 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.
getPropertyNames in interface ClientRequestContextcollection of property names.ClientRequestContext.getProperty(java.lang.String)public void setProperty(String name, Object object)
ClientRequestContextA 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.
setProperty in interface ClientRequestContextname - a String specifying the name of the property.object - an Object representing the property to be bound.public void removeProperty(String name)
ClientRequestContextClientRequestContext.getProperty(java.lang.String)
to retrieve the property value will return null.removeProperty in interface ClientRequestContextname - a String specifying the name of the property to be removed.public Class<?> getEntityClass()
ClientRequestContextgetEntityClass in interface ClientRequestContextpublic Type getEntityType()
ClientRequestContextgetEntityType in interface ClientRequestContextpublic void setEntity(Object entity)
ClientRequestContextannotations
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.
setEntity in interface ClientRequestContextentity - entity object.ClientRequestContext.setEntity(Object, java.lang.annotation.Annotation[], javax.ws.rs.core.MediaType),
MessageBodyWriterpublic void setEntity(Object entity, Annotation[] annotations, MediaType mediaType)
ClientRequestContext
It is the callers responsibility to wrap the actual entity with
GenericEntity if preservation of its generic
type is required.
setEntity in interface ClientRequestContextentity - entity object.annotations - annotations attached to the entity instance.mediaType - entity media type.ClientRequestContext.setEntity(Object),
MessageBodyWriterpublic URI getUri()
ClientRequestContextgetUri in interface ClientRequestContextpublic void setUri(URI uri)
ClientRequestContextsetUri in interface ClientRequestContexturi - new request URI.public String getMethod()
ClientRequestContextgetMethod in interface ClientRequestContextHttpMethodpublic void setMethod(String method)
ClientRequestContextsetMethod in interface ClientRequestContextmethod - new request method.HttpMethodpublic MultivaluedMap<String,Object> getHeaders()
ClientRequestContextgetHeaders in interface ClientRequestContextClientRequestContext.getStringHeaders(),
ClientRequestContext.getHeaderString(String)public Date getDate()
ClientRequestContextgetDate in interface ClientRequestContextnull if not present.public Locale getLanguage()
ClientRequestContextgetLanguage in interface ClientRequestContextnull if not specifiedpublic MediaType getMediaType()
ClientRequestContextgetMediaType in interface ClientRequestContextnull if not specified (e.g. there's no
request entity).public List<MediaType> getAcceptableMediaTypes()
ClientRequestContextgetAcceptableMediaTypes in interface ClientRequestContextpublic List<Locale> getAcceptableLanguages()
ClientRequestContextgetAcceptableLanguages in interface ClientRequestContextpublic Map<String,Cookie> getCookies()
ClientRequestContextgetCookies in interface ClientRequestContextCookie.public boolean hasEntity()
ClientRequestContexttrue if the entity is present, returns
false otherwise.hasEntity in interface ClientRequestContexttrue if there is an entity present in the message,
false otherwise.public OutputStream getEntityStream()
ClientRequestContextgetEntityStream in interface ClientRequestContextpublic void setEntityStream(OutputStream entityStream)
ClientRequestContextsetEntityStream in interface ClientRequestContextentityStream - new entity output stream.public Object getEntity()
ClientRequestContextnull if the message does not contain an entity.getEntity in interface ClientRequestContextnull if message does not contain an
entity body.public Annotation[] getEntityAnnotations()
ClientRequestContext
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.
getEntityAnnotations in interface ClientRequestContextpublic Client getClient()
ClientRequestContextgetClient in interface ClientRequestContextpublic Configuration getConfiguration()
ClientRequestContextgetConfiguration in interface ClientRequestContextpublic void abortWith(Response response)
ClientRequestContextabortWith in interface ClientRequestContextresponse - response to be sent back to the client.public MultivaluedMap<String,String> getStringHeaders()
ClientRequestContextheaders 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.
getStringHeaders in interface ClientRequestContextClientRequestContext.getHeaders(),
ClientRequestContext.getHeaderString(String)public String getHeaderString(String name)
ClientRequestContextRuntimeDelegate.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.getHeaderString in interface ClientRequestContextname - the message header.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.ClientRequestContext.getHeaders(),
ClientRequestContext.getStringHeaders()Copyright © 2013. All Rights Reserved.