org.jboss.resteasy.specimpl
Class ResponseBuilderImpl

java.lang.Object
  extended by javax.ws.rs.core.Response.ResponseBuilder
      extended by org.jboss.resteasy.specimpl.ResponseBuilderImpl

public class ResponseBuilderImpl
extends Response.ResponseBuilder

Version:
$Revision: 1 $
Author:
Bill Burke

Field Summary
protected  Object entity
           
protected  Annotation[] entityAnnotations
           
protected  Headers<Object> metadata
           
protected  int status
           
 
Constructor Summary
ResponseBuilderImpl()
           
 
Method Summary
 Response.ResponseBuilder allow(Set<String> methods)
          Set the list of allowed methods for the resource.
 Response.ResponseBuilder allow(String... methods)
          Set the list of allowed methods for the resource.
 Response build()
          Create a Response instance from the current ResponseBuilder.
 Response.ResponseBuilder cacheControl(CacheControl cacheControl)
          Set the cache control data of the message.
 Response.ResponseBuilder clone()
          
 Response.ResponseBuilder contentLocation(URI location)
          Set the content location.
 Response.ResponseBuilder cookie(NewCookie... cookies)
          Add cookies to the response message.
static String createVaryHeader(List<Variant> variants)
           
 Response.ResponseBuilder encoding(String encoding)
          Set the message entity content encoding.
 Response.ResponseBuilder entity(Object entity)
          Set the response entity in the builder.
 Response.ResponseBuilder entity(Object entity, Annotation[] annotations)
          Set the response entity in the builder.
 Response.ResponseBuilder expires(Date expires)
          Set the response expiration date.
 Response.ResponseBuilder header(String name, Object value)
          Add an arbitrary header.
 Response.ResponseBuilder language(Locale language)
          Set the message entity language.
 Response.ResponseBuilder language(String language)
          Set the message entity language.
 Response.ResponseBuilder lastModified(Date lastModified)
          Set the response entity last modification date.
 Response.ResponseBuilder link(String uri, String rel)
          Add a link header.
 Response.ResponseBuilder link(URI uri, String rel)
          Add a link header.
 Response.ResponseBuilder links(Link... links)
          Add one or more link headers.
 Response.ResponseBuilder location(URI location)
          Set the location.
 Response.ResponseBuilder replaceAll(MultivaluedMap<String,Object> headers)
          Replaces all existing headers with the newly supplied headers.
 Response.ResponseBuilder status(int status)
          Set the status on the ResponseBuilder.
 Response.ResponseBuilder tag(EntityTag tag)
          Set a response entity tag.
 Response.ResponseBuilder tag(String tag)
          Set a strong response entity tag.
 Response.ResponseBuilder type(MediaType type)
          Set the message entity media type.
 Response.ResponseBuilder type(String type)
          Set the message entity media type.
 Response.ResponseBuilder variant(Variant variant)
          Set message entity representation metadata.
 Response.ResponseBuilder variants(List<Variant> variants)
          Add a Vary header that lists the available variants.
 Response.ResponseBuilder variants(Variant... variants)
          Add a Vary header that lists the available variants.
 
Methods inherited from class javax.ws.rs.core.Response.ResponseBuilder
newInstance, status, status
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

entity

protected Object entity

entityAnnotations

protected Annotation[] entityAnnotations

status

protected int status

metadata

protected Headers<Object> metadata
Constructor Detail

ResponseBuilderImpl

public ResponseBuilderImpl()
Method Detail

build

public Response build()
Description copied from class: Response.ResponseBuilder
Create a Response instance from the current ResponseBuilder. The builder is reset to a blank state equivalent to calling the ok method.

Specified by:
build in class Response.ResponseBuilder
Returns:
a Response instance.

clone

public Response.ResponseBuilder clone()
Description copied from class: Response.ResponseBuilder

Create a copy of the ResponseBuilder preserving its state.

Specified by:
clone in class Response.ResponseBuilder
Returns:
a copy of the ResponseBuilder.

status

public Response.ResponseBuilder status(int status)
Description copied from class: Response.ResponseBuilder
Set the status on the ResponseBuilder.

Specified by:
status in class Response.ResponseBuilder
Parameters:
status - the response status.
Returns:
the updated response builder.

entity

public Response.ResponseBuilder entity(Object entity)
Description copied from class: Response.ResponseBuilder
Set the response entity in the builder.

Any Java type instance for a response 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.

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

entity

public Response.ResponseBuilder entity(Object entity,
                                       Annotation[] annotations)
Description copied from class: Response.ResponseBuilder
Set the response entity in the builder.

Any Java type instance for a response 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.

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

type

public Response.ResponseBuilder type(MediaType type)
Description copied from class: Response.ResponseBuilder
Set the message entity media type.

Specified by:
type in class Response.ResponseBuilder
Parameters:
type - the media type of the message entity. If null, any existing value for type will be removed.
Returns:
the updated response builder.

type

public Response.ResponseBuilder type(String type)
Description copied from class: Response.ResponseBuilder
Set the message entity media type.

Specified by:
type in class Response.ResponseBuilder
Parameters:
type - the media type of the message entity. If null, any existing value for type will be removed.
Returns:
the updated response builder.

variant

public Response.ResponseBuilder variant(Variant variant)
Description copied from class: Response.ResponseBuilder
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.

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

variants

public Response.ResponseBuilder variants(List<Variant> variants)
Description copied from class: Response.ResponseBuilder
Add a Vary header that lists the available variants.

Specified by:
variants in class Response.ResponseBuilder
Parameters:
variants - a list of available representation variants, a null value will remove an existing value for Vary header.
Returns:
the updated response builder.

createVaryHeader

public static String createVaryHeader(List<Variant> variants)

language

public Response.ResponseBuilder language(String language)
Description copied from class: Response.ResponseBuilder
Set the message entity language.

Specified by:
language in class Response.ResponseBuilder
Parameters:
language - the language of the message entity, if null any existing value for language will be removed.
Returns:
the updated response builder.

location

public Response.ResponseBuilder location(URI location)
Description copied from class: Response.ResponseBuilder
Set the location.

Specified by:
location in class Response.ResponseBuilder
Parameters:
location - the location. If a relative URI is supplied it will be converted into an absolute URI by resolving it relative to the base URI of the application (see UriInfo.getBaseUri()). If null any existing value for location will be removed.
Returns:
the updated response builder.

contentLocation

public Response.ResponseBuilder contentLocation(URI location)
Description copied from class: Response.ResponseBuilder
Set the content location.

Specified by:
contentLocation in class Response.ResponseBuilder
Parameters:
location - the content location. Relative or absolute URIs may be used for the value of content location. If null any existing value for content location will be removed.
Returns:
the updated response builder.

tag

public Response.ResponseBuilder tag(EntityTag tag)
Description copied from class: Response.ResponseBuilder
Set a response entity tag.

Specified by:
tag in class Response.ResponseBuilder
Parameters:
tag - the entity tag, if null any existing entity tag value will be removed.
Returns:
the updated response builder.

tag

public Response.ResponseBuilder tag(String tag)
Description copied from class: Response.ResponseBuilder
Set a strong response entity tag.

This is a shortcut for tag(new EntityTag(value)).

Specified by:
tag in class Response.ResponseBuilder
Parameters:
tag - the string content of a strong entity tag. The JAX-RS runtime will quote the supplied value when creating the header. If null any existing entity tag value will be removed.
Returns:
the updated response builder.

lastModified

public Response.ResponseBuilder lastModified(Date lastModified)
Description copied from class: Response.ResponseBuilder
Set the response entity last modification date.

Specified by:
lastModified in class Response.ResponseBuilder
Parameters:
lastModified - the last modified date, if null any existing last modified value will be removed.
Returns:
the updated response builder.

cacheControl

public Response.ResponseBuilder cacheControl(CacheControl cacheControl)
Description copied from class: Response.ResponseBuilder
Set the cache control data of the message.

Specified by:
cacheControl in class Response.ResponseBuilder
Parameters:
cacheControl - the cache control directives, if null any existing cache control directives will be removed.
Returns:
the updated response builder.

header

public Response.ResponseBuilder header(String name,
                                       Object value)
Description copied from class: Response.ResponseBuilder
Add an arbitrary header.

Specified by:
header in class Response.ResponseBuilder
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 response builder.

cookie

public Response.ResponseBuilder cookie(NewCookie... cookies)
Description copied from class: Response.ResponseBuilder
Add cookies to the response message.

Specified by:
cookie in class Response.ResponseBuilder
Parameters:
cookies - new cookies that will accompany the response. A null value will remove all cookies, including those added via the Response.ResponseBuilder.header(java.lang.String, java.lang.Object) method.
Returns:
the updated response builder.

language

public Response.ResponseBuilder language(Locale language)
Description copied from class: Response.ResponseBuilder
Set the message entity language.

Specified by:
language in class Response.ResponseBuilder
Parameters:
language - the language of the message entity, if null any existing value for type will be removed.
Returns:
the updated response builder.

expires

public Response.ResponseBuilder expires(Date expires)
Description copied from class: Response.ResponseBuilder
Set the response expiration date.

Specified by:
expires in class Response.ResponseBuilder
Parameters:
expires - the expiration date, if null removes any existing expires value.
Returns:
the updated response builder.

allow

public Response.ResponseBuilder allow(String... methods)
Description copied from class: Response.ResponseBuilder
Set the list of allowed methods for the resource. Any duplicate method names will be truncated to a single entry.

Specified by:
allow in class Response.ResponseBuilder
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 response builder.

allow

public Response.ResponseBuilder allow(Set<String> methods)
Description copied from class: Response.ResponseBuilder
Set the list of allowed methods for the resource.

Specified by:
allow in class Response.ResponseBuilder
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 response builder.

encoding

public Response.ResponseBuilder encoding(String encoding)
Description copied from class: Response.ResponseBuilder
Set the message entity content encoding.

Specified by:
encoding in class Response.ResponseBuilder
Parameters:
encoding - the content encoding of the message entity, if null any existing value for content encoding will be removed.
Returns:
the updated response builder.

variants

public Response.ResponseBuilder variants(Variant... variants)
Description copied from class: Response.ResponseBuilder
Add a Vary header that lists the available variants.

Specified by:
variants in class Response.ResponseBuilder
Parameters:
variants - a list of available representation variants, a null value will remove an existing value for Vary header.
Returns:
the updated response builder.

links

public Response.ResponseBuilder links(Link... links)
Description copied from class: Response.ResponseBuilder
Add one or more link headers.

Specified by:
links in class Response.ResponseBuilder
Parameters:
links - links to be added to the message as headers, a null value will remove any existing Link headers.
Returns:
the updated response builder.

link

public Response.ResponseBuilder link(URI uri,
                                     String rel)
Description copied from class: Response.ResponseBuilder
Add a link header.

Specified by:
link in class Response.ResponseBuilder
Parameters:
uri - underlying URI for link header.
rel - value of "rel" parameter.
Returns:
the updated response builder.

link

public Response.ResponseBuilder link(String uri,
                                     String rel)
Description copied from class: Response.ResponseBuilder
Add a link header.

Specified by:
link in class Response.ResponseBuilder
Parameters:
uri - underlying URI for link header.
rel - value of "rel" parameter.
Returns:
the updated response builder.

replaceAll

public Response.ResponseBuilder replaceAll(MultivaluedMap<String,Object> headers)
Description copied from class: Response.ResponseBuilder
Replaces all existing headers with the newly supplied headers.

Specified by:
replaceAll in class Response.ResponseBuilder
Parameters:
headers - new headers to be set, if null all existing headers will be removed.
Returns:
the updated response builder.


Copyright © 2012. All Rights Reserved.