public abstract class Response
extends java.lang.Object
UriBuilder
provides
convenient methods to create such values as does
URI.create().Response.ResponseBuilder
Modifier and Type | Class and Description |
---|---|
static class |
Response.ResponseBuilder
A class used to build Response instances that contain metadata instead
of or in addition to an entity.
|
static class |
Response.Status
Commonly used status codes defined by HTTP, see
HTTP/1.1 documentation
for the complete list.
|
static interface |
Response.StatusType
Base interface for statuses used in responses.
|
Modifier | Constructor and Description |
---|---|
protected |
Response()
Protected constructor, use one of the static methods to obtain a
Response.ResponseBuilder instance and obtain a Response from that. |
Modifier and Type | Method and Description |
---|---|
static Response.ResponseBuilder |
created(java.net.URI location)
Create a new ResponseBuilder for a created resource, set the location
header using the supplied value.
|
static Response.ResponseBuilder |
fromResponse(Response response)
Create a new ResponseBuilder by performing a shallow copy of an
existing Response.
|
abstract java.lang.Object |
getEntity()
Return the response entity.
|
abstract MultivaluedMap<java.lang.String,java.lang.Object> |
getMetadata()
Get metadata associated with the response as a map.
|
abstract int |
getStatus()
Get the status code associated with the response.
|
static Response.ResponseBuilder |
noContent()
Create a new ResponseBuilder for an empty response.
|
static Response.ResponseBuilder |
notAcceptable(java.util.List<Variant> variants)
Create a new ResponseBuilder for a not acceptable response.
|
static Response.ResponseBuilder |
notModified()
Create a new ResponseBuilder with a not-modified status.
|
static Response.ResponseBuilder |
notModified(EntityTag tag)
Create a new ResponseBuilder with a not-modified status.
|
static Response.ResponseBuilder |
notModified(java.lang.String tag)
Create a new ResponseBuilder with a not-modified status
and a strong entity tag.
|
static Response.ResponseBuilder |
ok()
Create a new ResponseBuilder with an OK status.
|
static Response.ResponseBuilder |
ok(java.lang.Object entity)
Create a new ResponseBuilder that contains a representation.
|
static Response.ResponseBuilder |
ok(java.lang.Object entity,
MediaType type)
Create a new ResponseBuilder that contains a representation.
|
static Response.ResponseBuilder |
ok(java.lang.Object entity,
java.lang.String type)
Create a new ResponseBuilder that contains a representation.
|
static Response.ResponseBuilder |
ok(java.lang.Object entity,
Variant variant)
Create a new ResponseBuilder that contains a representation.
|
static Response.ResponseBuilder |
seeOther(java.net.URI location)
Create a new ResponseBuilder for a redirection.
|
static Response.ResponseBuilder |
serverError()
Create a new ResponseBuilder with an server error status.
|
static Response.ResponseBuilder |
status(int status)
Create a new ResponseBuilder with the supplied status.
|
static Response.ResponseBuilder |
status(Response.Status status)
Create a new ResponseBuilder with the supplied status.
|
static Response.ResponseBuilder |
status(Response.StatusType status)
Create a new ResponseBuilder with the supplied status.
|
static Response.ResponseBuilder |
temporaryRedirect(java.net.URI location)
Create a new ResponseBuilder for a temporary redirection.
|
protected Response()
Response.ResponseBuilder
instance and obtain a Response from that.public abstract java.lang.Object getEntity()
GenericEntity
, the value of GenericEntity.getRawType()
.MessageBodyWriter
public abstract int getStatus()
public abstract MultivaluedMap<java.lang.String,java.lang.Object> getMetadata()
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.public static Response.ResponseBuilder fromResponse(Response response)
response
- a Response from which the status code, entity and metadata
will be copiedpublic static Response.ResponseBuilder status(Response.StatusType status)
status
- the response statusjava.lang.IllegalArgumentException
- if status is nullpublic static Response.ResponseBuilder status(Response.Status status)
status
- the response statusjava.lang.IllegalArgumentException
- if status is nullpublic static Response.ResponseBuilder status(int status)
status
- the response statusjava.lang.IllegalArgumentException
- if status is less than 100 or greater
than 599.public static Response.ResponseBuilder ok()
public static Response.ResponseBuilder ok(java.lang.Object entity)
GenericEntity
if preservation of its generic type is required.entity
- the representation entity datapublic static Response.ResponseBuilder ok(java.lang.Object entity, MediaType type)
GenericEntity
if preservation of its generic type is required.entity
- the representation entity datatype
- the media type of the entitypublic static Response.ResponseBuilder ok(java.lang.Object entity, java.lang.String type)
GenericEntity
if preservation of its generic type is required.entity
- the representation entity datatype
- the media type of the entitypublic static Response.ResponseBuilder ok(java.lang.Object entity, Variant variant)
GenericEntity
if preservation of its generic type is required.entity
- the representation entity datavariant
- representation metadatapublic static Response.ResponseBuilder serverError()
public static Response.ResponseBuilder created(java.net.URI location)
location
- the URI of the new resource. If a relative URI is
supplied it will be converted into an absolute URI by resolving it
relative to the request URI (see UriInfo.getRequestUri()
).java.lang.IllegalArgumentException
- if location is nullpublic static Response.ResponseBuilder noContent()
public static Response.ResponseBuilder notModified()
public static Response.ResponseBuilder notModified(EntityTag tag)
tag
- a tag for the unmodified entityjava.lang.IllegalArgumentException
- if tag is nullpublic static Response.ResponseBuilder notModified(java.lang.String tag)
notModified(new EntityTag(value))
.tag
- the string content of a strong entity tag. The JAX-RS
runtime will quote the supplied value when creating the header.java.lang.IllegalArgumentException
- if tag is nullpublic static Response.ResponseBuilder seeOther(java.net.URI location)
location
- the redirection URI. 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()
).java.lang.IllegalArgumentException
- if location is nullpublic static Response.ResponseBuilder temporaryRedirect(java.net.URI location)
location
- the redirection URI. 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()
).java.lang.IllegalArgumentException
- if location is nullpublic static Response.ResponseBuilder notAcceptable(java.util.List<Variant> variants)
variants
- list of variants that were available, a null value is
equivalent to an empty list.Copyright © 2016 Oracle Corporation. All Rights Reserved.