javax.ws.rs.core
Interface Request.RequestBuilder

All Superinterfaces:
Cloneable
Enclosing interface:
Request

public static interface Request.RequestBuilder
extends Cloneable

An interface used to build Request instances, typically used in JAX-RS filters. An initial instance may be obtained via FilterContext that is passed to the filters.

Methods of this interface provide the ability to set request metadata, such as headers or entity.

Where multiple variants of the same method are provided, the type of the supplied parameter is retained in the metadata of the built Request.

Since:
2.0

Method Summary
 Request.RequestBuilder accept(MediaType... types)
          Add acceptable media types.
 Request.RequestBuilder accept(String... types)
          Add acceptable media types.
 Request.RequestBuilder acceptLanguage(Locale... locales)
          Add acceptable languages.
 Request.RequestBuilder acceptLanguage(String... locales)
          Add acceptable languages.
 Request.RequestBuilder allow(Set<String> methods)
          Set the list of allowed methods for the resource.
 Request.RequestBuilder allow(String... methods)
          Set the list of allowed methods for the resource.
 Request build()
           
 Request.RequestBuilder cacheControl(CacheControl cacheControl)
          Set the cache control data of the message.
 Request.RequestBuilder clone()
          Create a copy of the request builder preserving its state.
 Request.RequestBuilder cookie(Cookie cookie)
          Add a cookie to be set.
 Request.RequestBuilder encoding(String encoding)
          Set the message entity content encoding.
 Request.RequestBuilder entity(Object entity)
          Set the request entity in the builder.
 Request.RequestBuilder entity(Object entity, Annotation[] annotations)
          Set the request entity in the builder.
 Request.RequestBuilder header(String name, Object value)
          Add an arbitrary header.
 Request.RequestBuilder language(Locale language)
          Set the message entity language.
 Request.RequestBuilder language(String language)
          Set the message entity language.
 Request.RequestBuilder method(String httpMethod)
          Modify the HTTP method of the request.
 Request.RequestBuilder redirect(String uri)
           
 Request.RequestBuilder redirect(URI uri)
           
 Request.RequestBuilder redirect(UriBuilder uri)
           
 Request.RequestBuilder replaceAll(RequestHeaders headers)
          Replaces all existing headers with the newly supplied headers.
 Request.RequestBuilder type(MediaType type)
          Set the message entity media type.
 Request.RequestBuilder type(String type)
          Set the message entity media type.
 Request.RequestBuilder variant(Variant variant)
          Set message entity representation metadata.
 

Method Detail

allow

Request.RequestBuilder allow(String... methods)
Set the list of allowed methods for the resource. Any duplicate method names will be truncated to a single entry.

Parameters:
methods - the methods to be listed as allowed for the resource, if null any existing allowed method list will be removed.
Returns:
the updated request builder.

allow

Request.RequestBuilder allow(Set<String> methods)
Set the list of allowed methods for the resource.

Parameters:
methods - the methods to be listed as allowed for the resource, if null any existing allowed method list will be removed.
Returns:
the updated request builder.

cacheControl

Request.RequestBuilder cacheControl(CacheControl cacheControl)
Set the cache control data of the message.

Parameters:
cacheControl - the cache control directives, if null any existing cache control directives will be removed.
Returns:
the updated request builder.

encoding

Request.RequestBuilder encoding(String encoding)
Set the message entity content encoding.

Parameters:
encoding - the content encoding of the message entity, if null any existing value for content encoding will be removed.
Returns:
the updated request builder.

header

Request.RequestBuilder header(String name,
                              Object value)
Add an arbitrary header.

Parameters:
name - the name of the header
value - the value of the header, the header will be serialized using a RuntimeDelegate.HeaderDelegate if one is available via RuntimeDelegate.createHeaderDelegate(java.lang.Class) for the class of value or using its toString method if a header delegate is not available. If value is null then all current headers of the same name will be removed.
Returns:
the updated request builder.

replaceAll

Request.RequestBuilder replaceAll(RequestHeaders headers)
Replaces all existing headers with the newly supplied headers.

Parameters:
headers - new headers to be set, if null all existing headers will be removed.
Returns:
the updated request builder.

language

Request.RequestBuilder language(String language)
Set the message entity language.

Parameters:
language - the language of the message entity, if null any existing value for language will be removed.
Returns:
the updated request builder.

language

Request.RequestBuilder language(Locale language)
Set the message entity language.

Parameters:
language - the language of the message entity, if null any existing value for type will be removed.
Returns:
the updated request builder.

type

Request.RequestBuilder type(MediaType type)
Set the message entity media type.

Parameters:
type - the media type of the message entity. If null, any existing value for type will be removed
Returns:
the updated request builder.

type

Request.RequestBuilder type(String type)
Set the message entity media type.

Parameters:
type - the media type of the message entity. If null, any existing value for type will be removed
Returns:
the updated request builder.

variant

Request.RequestBuilder variant(Variant variant)
Set message entity representation metadata.

Equivalent to setting the values of content type, content language, and content encoding separately using the values of the variant properties.

Parameters:
variant - metadata of the message entity, a null value is equivalent to a variant with all null properties.
Returns:
the updated request builder.
See Also:
encoding(java.lang.String), language(java.util.Locale), type(javax.ws.rs.core.MediaType)

accept

Request.RequestBuilder accept(MediaType... types)
Add acceptable media types.

Parameters:
types - an array of the acceptable media types
Returns:
updated request builder.

accept

Request.RequestBuilder accept(String... types)
Add acceptable media types.

Parameters:
types - an array of the acceptable media types
Returns:
updated request builder.

acceptLanguage

Request.RequestBuilder acceptLanguage(Locale... locales)
Add acceptable languages.

Parameters:
locales - an array of the acceptable languages
Returns:
updated request builder.

acceptLanguage

Request.RequestBuilder acceptLanguage(String... locales)
Add acceptable languages.

Parameters:
locales - an array of the acceptable languages
Returns:
updated request builder.

cookie

Request.RequestBuilder cookie(Cookie cookie)
Add a cookie to be set.

Parameters:
cookie - to be set.
Returns:
updated request builder.

redirect

Request.RequestBuilder redirect(String uri)

redirect

Request.RequestBuilder redirect(URI uri)

redirect

Request.RequestBuilder redirect(UriBuilder uri)

method

Request.RequestBuilder method(String httpMethod)
Modify the HTTP method of the request.

The method name parameter can be any arbitrary, non-empty string, containing but NOT limited to the command verbs of HTTP, WebDAV and other protocols. An implementation MUST NOT expect the method to be part of any particular set of methods. Any provided method name MUST be forwarded to the resource without any limitations.

Parameters:
httpMethod - new method to be set on the request.
Returns:
updated request builder instance.

entity

Request.RequestBuilder entity(Object entity)
Set the request entity in the builder.

Any Java type instance for a request entity, that is supported by the runtime can be passed. It is the callers responsibility to wrap the actual entity with GenericEntity if preservation of its generic type is required. Note that the entity can be also set as an input stream.

A specific entity media type can be set using one of the type(...) methods.

Parameters:
entity - the request entity.
Returns:
updated request builder instance.
See Also:
entity(java.lang.Object, java.lang.annotation.Annotation[]), type(javax.ws.rs.core.MediaType), type(java.lang.String)

entity

Request.RequestBuilder entity(Object entity,
                              Annotation[] annotations)
Set the request entity in the builder.

Any Java type instance for a request entity, that is supported by the runtime can be passed. It is the callers responsibility to wrap the actual entity with GenericEntity if preservation of its generic type is required. Note that the entity can be also set as an input stream.

A specific entity media type can be set using one of the type(...) methods.

Parameters:
entity - the request entity.
annotations - annotations that will be passed to the MessageBodyWriter.
Returns:
updated request builder instance.
See Also:
entity(java.lang.Object), type(javax.ws.rs.core.MediaType), type(java.lang.String)

clone

Request.RequestBuilder clone()
Create a copy of the request builder preserving its state. Note that the returned builder has its own request headers but the header values are shared with the original RequestBuilder instance. Similarly, entity instance is also shared with the original RequestBuilder instance.

Returns:
a copy of the request builder.

build

Request build()


Copyright © 2007-2012 Oracle Corporation. All Rights Reserved. Use is subject to license terms.