public class ResponseBuilderImpl extends Response.ResponseBuilder
Modifier and Type | Field and Description |
---|---|
protected Object |
entity |
protected Annotation[] |
entityAnnotations |
protected Headers<Object> |
metadata |
protected int |
status |
Constructor and Description |
---|
ResponseBuilderImpl() |
Modifier and Type | Method and Description |
---|---|
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.
|
static SimpleDateFormat |
getDateFormatRFC822() |
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.
|
newInstance, status, status
protected Object entity
protected Annotation[] entityAnnotations
protected int status
public Response build()
Response.ResponseBuilder
build
in class Response.ResponseBuilder
public Response.ResponseBuilder clone()
Response.ResponseBuilder
Create a copy of the ResponseBuilder preserving its state.
clone
in class Response.ResponseBuilder
public Response.ResponseBuilder status(int status)
Response.ResponseBuilder
status
in class Response.ResponseBuilder
status
- the response status.public Response.ResponseBuilder entity(Object entity)
Response.ResponseBuilder
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.entity
in class Response.ResponseBuilder
entity
- the request entity.Response.ResponseBuilder.entity(java.lang.Object, java.lang.annotation.Annotation[])
,
Response.ResponseBuilder.type(javax.ws.rs.core.MediaType)
,
Response.ResponseBuilder.type(java.lang.String)
public Response.ResponseBuilder entity(Object entity, Annotation[] annotations)
Response.ResponseBuilder
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.entity
in class Response.ResponseBuilder
entity
- the request entity.annotations
- annotations that will be passed to the MessageBodyWriter
.Response.ResponseBuilder.entity(java.lang.Object)
,
Response.ResponseBuilder.type(javax.ws.rs.core.MediaType)
,
Response.ResponseBuilder.type(java.lang.String)
public Response.ResponseBuilder type(MediaType type)
Response.ResponseBuilder
type
in class Response.ResponseBuilder
type
- the media type of the message entity. If null
, any
existing value for type will be removed.public Response.ResponseBuilder type(String type)
Response.ResponseBuilder
type
in class Response.ResponseBuilder
type
- the media type of the message entity. If null
, any
existing value for type will be removed.public Response.ResponseBuilder variant(Variant variant)
Response.ResponseBuilder
variant
in class Response.ResponseBuilder
variant
- metadata of the message entity, a null
value is
equivalent to a variant with all null
properties.Response.ResponseBuilder.encoding(java.lang.String)
,
Response.ResponseBuilder.language(java.util.Locale)
,
Response.ResponseBuilder.type(javax.ws.rs.core.MediaType)
public Response.ResponseBuilder variants(List<Variant> variants)
Response.ResponseBuilder
variants
in class Response.ResponseBuilder
variants
- a list of available representation variants, a null
value will remove an existing value for Vary header.public Response.ResponseBuilder language(String language)
Response.ResponseBuilder
language
in class Response.ResponseBuilder
language
- the language of the message entity, if null
any
existing value for language will be removed.public Response.ResponseBuilder location(URI location)
Response.ResponseBuilder
location
in class Response.ResponseBuilder
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.public Response.ResponseBuilder contentLocation(URI location)
Response.ResponseBuilder
contentLocation
in class Response.ResponseBuilder
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.public Response.ResponseBuilder tag(EntityTag tag)
Response.ResponseBuilder
tag
in class Response.ResponseBuilder
tag
- the entity tag, if null
any existing entity tag
value will be removed.public Response.ResponseBuilder tag(String tag)
Response.ResponseBuilder
tag(new EntityTag(value))
.tag
in class Response.ResponseBuilder
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.public Response.ResponseBuilder lastModified(Date lastModified)
Response.ResponseBuilder
lastModified
in class Response.ResponseBuilder
lastModified
- the last modified date, if null
any existing
last modified value will be removed.public Response.ResponseBuilder cacheControl(CacheControl cacheControl)
Response.ResponseBuilder
cacheControl
in class Response.ResponseBuilder
cacheControl
- the cache control directives, if null
any existing cache control directives will be removed.public Response.ResponseBuilder header(String name, Object value)
Response.ResponseBuilder
header
in class Response.ResponseBuilder
name
- the name of the headervalue
- 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.public Response.ResponseBuilder cookie(NewCookie... cookies)
Response.ResponseBuilder
cookie
in class Response.ResponseBuilder
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.public Response.ResponseBuilder language(Locale language)
Response.ResponseBuilder
language
in class Response.ResponseBuilder
language
- the language of the message entity, if null
any
existing value for type will be removed.public static SimpleDateFormat getDateFormatRFC822()
public Response.ResponseBuilder expires(Date expires)
Response.ResponseBuilder
expires
in class Response.ResponseBuilder
expires
- the expiration date, if null
removes any existing
expires value.public Response.ResponseBuilder allow(String... methods)
Response.ResponseBuilder
allow
in class Response.ResponseBuilder
methods
- the methods to be listed as allowed for the resource,
if null
any existing allowed method list will be removed.public Response.ResponseBuilder allow(Set<String> methods)
Response.ResponseBuilder
allow
in class Response.ResponseBuilder
methods
- the methods to be listed as allowed for the resource,
if null
any existing allowed method list will be removed.public Response.ResponseBuilder encoding(String encoding)
Response.ResponseBuilder
encoding
in class Response.ResponseBuilder
encoding
- the content encoding of the message entity,
if null
any existing value for content encoding will be
removed.public Response.ResponseBuilder variants(Variant... variants)
Response.ResponseBuilder
variants
in class Response.ResponseBuilder
variants
- a list of available representation variants, a null
value will remove an existing value for Vary header.public Response.ResponseBuilder links(Link... links)
Response.ResponseBuilder
links
in class Response.ResponseBuilder
links
- links to be added to the message as headers, a null
value will remove any existing Link headers.public Response.ResponseBuilder link(URI uri, String rel)
Response.ResponseBuilder
link
in class Response.ResponseBuilder
uri
- underlying URI for link header.rel
- value of "rel" parameter.public Response.ResponseBuilder link(String uri, String rel)
Response.ResponseBuilder
link
in class Response.ResponseBuilder
uri
- underlying URI for link header.rel
- value of "rel" parameter.public Response.ResponseBuilder replaceAll(MultivaluedMap<String,Object> headers)
Response.ResponseBuilder
replaceAll
in class Response.ResponseBuilder
headers
- new headers to be set, if null
all existing
headers will be removed.Copyright © 2014. All Rights Reserved.