Top Description Inners Constructors Methods
javax.ws.rs.core

public abstract Class Response

extends Object
implements AutoCloseable
Class Inheritance
All Implemented Interfaces
java.lang.AutoCloseable
Imports
java.io.InputStream, java.lang.annotation.Annotation, java.net.URI, java.util.Date, .List, .Locale, .Map, .Set, javax.ws.rs.ProcessingException, javax.ws.rs.ext.MessageBodyReader, .MessageBodyWriter, .RuntimeDelegate

Defines the contract between a returned instance and the runtime when an application needs to provide meta-data to the runtime.

An application class should not extend this class directly. Response class is reserved for an extension by a JAX-RS implementation providers. An application should use one of the static methods to create a Response instance using a ResponseBuilder.

Several methods have parameters of type URI, UriBuilder provides convenient methods to create such values as does URI#create(java.lang.String).

Authors
Paul Sandoz, Marc Hadley, Marek Potociar
Since
1.0
See Also
Response.ResponseBuilder

Nested and Inner Type Summary

Modifier and TypeClass and Description
public abstract static class
Response.ResponseBuilder

A class used to build Response instances that contain metadata instead of or in addition to an entity.

public static enum
public static interface
Response.StatusType

Base interface for statuses used in responses.

Constructor Summary

AccessConstructor and Description
protected
Response()

Protected constructor, use one of the static methods to obtain a ResponseBuilder instance and obtain a Response from that.

Method Summary

Modifier and TypeMethod and Description
public static Response.ResponseBuilder

Returns:

a new response builder.
accepted
()

Create a new ResponseBuilder with an ACCEPTED status.

public static Response.ResponseBuilder

Returns:

a new response builder.
accepted
(Object
the representation entity data.
entity
)

Create a new ResponseBuilder with an ACCEPTED status that contains a representation.

public abstract boolean

Returns:

true if the message entity input stream was available and was buffered successfully, returns false if the entity stream was not available.
bufferEntity
()

Buffer the message entity data.

public abstract void
close()

Redeclares java.lang.AutoCloseable.close.

Close the underlying message entity input stream (if available and open) as well as releases any other resources associated with the response (e.g. buffered message entity data).
public static Response.ResponseBuilder

Returns:

a new response builder.
created
(URI
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).
location
)

Create a new ResponseBuilder for a created resource, set the location header using the supplied value.

public static Response.ResponseBuilder

Returns:

a new response builder.
fromResponse
(Response
a Response from which the status code, entity and response headers will be copied.
response
)

Create a new ResponseBuilder by performing a shallow copy of an existing Response.

public abstract Set<String>

Returns:

the allowed HTTP methods, all methods will returned as upper case strings.
getAllowedMethods
()

Get the allowed HTTP methods from the Allow HTTP header.

public abstract Map<String, NewCookie>

Returns:

a read-only map of cookie name (String) to Cookie.
getCookies
()

Get any new cookies set on the response message.

public abstract Date

Returns:

the message date, otherwise null if not present.
getDate
()

Get message date.

public abstract Object

Returns:

the message entity or null if message does not contain an entity body (i.e. when hasEntity() returns false).
getEntity
()

Get the message entity Java instance.

public abstract EntityTag

Returns:

the entity tag, otherwise null if not present.
getEntityTag
()

Get the entity tag.

public MultivaluedMap<String, Object>

Returns:

response headers as an object view of header values.
getHeaders
()

Get view of the response headers and their object values.

public abstract String

Returns:

the message header value. If the message header is not present then 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.
getHeaderString
(String
the message header.
name
)

Get a message header as a single string value.

public abstract Locale

Returns:

the language of the entity or null if not specified.
getLanguage
()

Get the language of the message entity.

public abstract Date

Returns:

the last modified date, otherwise null if not present.
getLastModified
()

Get the last modified date.

public abstract int

Returns:

Content-Length as integer if present and valid number. In other cases returns -1.
getLength
()

Get Content-Length value.

public abstract Link.Builder

Returns:

the link builder for the relation, otherwise null if not present.
getLinkBuilder
(String
link relation.
relation
)

Convenience method that returns a Link.Builder for the relation.

public abstract URI

Returns:

the location URI, otherwise null if not present.
getLocation
()

Get the location.

public abstract MediaType

Returns:

the media type or null if there is no response entity.
getMediaType
()

Get the media type of the message entity.

public abstract MultivaluedMap<String, Object>

Returns:

response headers as a multivalued map.
getMetadata
()

See getHeaders().

public abstract int

Returns:

the response status code.
getStatus
()

Get the status code associated with the response.

public abstract Response.StatusType

Returns:

the response status information. The returned value is never null.
getStatusInfo
()

Get the complete status information associated with the response.

public abstract MultivaluedMap<String, String>

Returns:

response headers as a string view of header values.
getStringHeaders
()

Get view of the response headers and their string values.

public abstract boolean

Returns:

true if there is an entity present in the message, false otherwise.
hasEntity
()

Check if there is an entity available in the response.

public static Response.ResponseBuilder

Returns:

a new response builder.
noContent
()

Create a new ResponseBuilder for an empty response.

public static Response.ResponseBuilder

Returns:

a new response builder.
notAcceptable
(List<Variant>
list of variants that were available, a null value is equivalent to an empty list.
variants
)

Create a new ResponseBuilder for a not acceptable response.

public static Response.ResponseBuilder

Returns:

a new response builder.
notModified
()

Create a new ResponseBuilder with a not-modified status.

public static Response.ResponseBuilder

Returns:

a new response builder.
notModified
(EntityTag
a tag for the unmodified entity.
tag
)

Create a new ResponseBuilder with a not-modified status.

public static Response.ResponseBuilder

Returns:

a new response builder.
notModified
(String
the string content of a strong entity tag. The JAX-RS runtime will quote the supplied value when creating the header.
tag
)

Create a new ResponseBuilder with a not-modified status and a strong entity tag.

public static Response.ResponseBuilder

Returns:

a new response builder.
ok
()

Create a new ResponseBuilder with an OK status.

public static Response.ResponseBuilder

Returns:

a new response builder.
ok
(Object
the representation entity data.
entity
)

Create a new ResponseBuilder that contains a representation.

public static Response.ResponseBuilder

Returns:

a new response builder.
ok
(Object
the representation entity data.
entity
,
MediaType
the media type of the entity.
type
)

Create a new ResponseBuilder that contains a representation.

public static Response.ResponseBuilder

Returns:

a new response builder.
ok
(Object
the representation entity data.
entity
,
String
the media type of the entity.
type
)

Create a new ResponseBuilder that contains a representation.

public static Response.ResponseBuilder

Returns:

a new response builder.
ok
(Object
the representation entity data.
entity
,
Variant
representation metadata.
variant
)

Create a new ResponseBuilder that contains a representation.

public abstract <
entity instance Java type.
T
>
T

Returns:

the message entity; for a zero-length response entities returns a corresponding Java object that represents zero-length data. In case no zero-length representation is defined for the Java type, a ProcessingException wrapping the underlying NoContentException is thrown.
readEntity
(Class<T>
the type of entity.
entityType
)

Read the message entity input stream as an instance of specified Java type using a javax.ws.rs.ext.MessageBodyReader that supports mapping the message entity stream onto the requested type.

public abstract <
entity instance Java type.
T
>
T

Returns:

the message entity; for a zero-length response entities returns a corresponding Java object that represents zero-length data. In case no zero-length representation is defined for the Java type, a ProcessingException wrapping the underlying NoContentException is thrown.
readEntity
(GenericType<T>
the type of entity; may be generic.
entityType
)

Read the message entity input stream as an instance of specified Java type using a javax.ws.rs.ext.MessageBodyReader that supports mapping the message entity stream onto the requested type.

public abstract <
entity instance Java type.
T
>
T

Returns:

the message entity; for a zero-length response entities returns a corresponding Java object that represents zero-length data. In case no zero-length representation is defined for the Java type, a ProcessingException wrapping the underlying NoContentException is thrown.
readEntity
(Class<T>
the type of entity.
entityType
,
Annotation[]
annotations that will be passed to the MessageBodyReader.
annotations
)

Read the message entity input stream as an instance of specified Java type using a javax.ws.rs.ext.MessageBodyReader that supports mapping the message entity stream onto the requested type.

public abstract <
entity instance Java type.
T
>
T

Returns:

the message entity; for a zero-length response entities returns a corresponding Java object that represents zero-length data. In case no zero-length representation is defined for the Java type, a ProcessingException wrapping the underlying NoContentException is thrown.
readEntity
(GenericType<T>
the type of entity; may be generic.
entityType
,
Annotation[]
annotations that will be passed to the MessageBodyReader.
annotations
)

Read the message entity input stream as an instance of specified Java type using a javax.ws.rs.ext.MessageBodyReader that supports mapping the message entity stream onto the requested type.

public static Response.ResponseBuilder

Returns:

a new response builder.
seeOther
(URI
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).
location
)

Create a new ResponseBuilder for a redirection.

public static Response.ResponseBuilder

Returns:

a new response builder.
serverError
()

Create a new ResponseBuilder with an server error status.

public static Response.ResponseBuilder

Returns:

a new response builder.
status
(Response.StatusType
the response status.
status
)

Create a new ResponseBuilder with the supplied status.

public static Response.ResponseBuilder

Returns:

a new response builder.
status
(Response.Status
the response status.
status
)

Create a new ResponseBuilder with the supplied status.

public static Response.ResponseBuilder

Returns:

a new response builder.
status
(int
the response status.
status
)

Create a new ResponseBuilder with the supplied status.

public static Response.ResponseBuilder

Returns:

the updated response builder.
status
(int
the response status.
status
,
String
the reason phrase.
reasonPhrase
)

Create a new ResponseBuilder with the supplied status and reason phrase.

public static Response.ResponseBuilder

Returns:

a new response builder.
temporaryRedirect
(URI
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).
location
)

Create a new ResponseBuilder for a temporary redirection.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait