public class ContainerResponse extends Object implements ContainerResponseContext
Constructor and Description |
---|
ContainerResponse(ContainerRequest requestContext,
Response response)
Create a new Jersey container response context.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the response.
|
void |
commitStream()
Commit the
entity stream unless already committed. |
void |
enableBuffering(Configuration configuration)
Enable a buffering of serialized entity.
|
Set<String> |
getAllowedMethods() |
Map<String,NewCookie> |
getCookies() |
Date |
getDate() |
Object |
getEntity() |
Annotation[] |
getEntityAnnotations() |
Class<?> |
getEntityClass() |
OutputStream |
getEntityStream() |
EntityTag |
getEntityTag() |
Type |
getEntityType() |
MultivaluedMap<String,Object> |
getHeaders() |
String |
getHeaderString(String name) |
Locale |
getLanguage() |
Date |
getLastModified() |
int |
getLength() |
Link |
getLink(String relation) |
Link.Builder |
getLinkBuilder(String relation) |
Set<Link> |
getLinks() |
URI |
getLocation() |
MediaType |
getMediaType() |
ContainerRequest |
getRequestContext()
Get the associated container request context paired with this response context.
|
int |
getStatus() |
Response.StatusType |
getStatusInfo() |
MultivaluedMap<String,String> |
getStringHeaders() |
OutboundMessageContext |
getWrappedMessageContext()
Get the wrapped response message context.
|
boolean |
hasEntity() |
boolean |
hasLink(String relation) |
boolean |
isChunked()
Returns
true if the response entity is a ChunkedOutput instance. |
boolean |
isCommitted()
Returns
true if the entity stream has been committed. |
boolean |
isMappedFromException()
Returns true if the response is result of the exception (for example created during
exception mapping ). |
void |
setEntity(Object entity)
Set a new message message entity.
|
void |
setEntity(Object entity,
Annotation[] annotations)
Set a new message message entity.
|
void |
setEntity(Object entity,
Annotation[] annotations,
MediaType mediaType) |
void |
setEntity(Object entity,
Type type,
Annotation[] annotations)
Set a new message message entity.
|
void |
setEntityAnnotations(Annotation[] annotations)
Set the annotations attached to the entity.
|
void |
setEntityStream(OutputStream outputStream) |
void |
setEntityType(Type type)
Set the message entity type information.
|
void |
setMappedFromException(boolean mappedFromException)
Sets the flag indicating whether the response was created based on the exception.
|
void |
setMediaType(MediaType mediaType)
Set the message content media type.
|
void |
setStatus(int code) |
void |
setStatusInfo(Response.StatusType status) |
void |
setStreamProvider(OutboundMessageContext.StreamProvider streamProvider)
Set the output stream provider callback.
|
public ContainerResponse(ContainerRequest requestContext, Response response)
requestContext
- associated container request context.response
- response instance initializing the response context.public boolean isMappedFromException()
exception mapping
).public void setMappedFromException(boolean mappedFromException)
mappedFromException
- True if this exception if result of the exception (for example result of
exception mapping
).public int getStatus()
getStatus
in interface ContainerResponseContext
public void setStatus(int code)
setStatus
in interface ContainerResponseContext
public void setStatusInfo(Response.StatusType status)
setStatusInfo
in interface ContainerResponseContext
public Response.StatusType getStatusInfo()
getStatusInfo
in interface ContainerResponseContext
public ContainerRequest getRequestContext()
public Map<String,NewCookie> getCookies()
getCookies
in interface ContainerResponseContext
public OutboundMessageContext getWrappedMessageContext()
public String getHeaderString(String name)
getHeaderString
in interface ContainerResponseContext
public MultivaluedMap<String,Object> getHeaders()
getHeaders
in interface ContainerResponseContext
public MultivaluedMap<String,String> getStringHeaders()
getStringHeaders
in interface ContainerResponseContext
public Date getDate()
getDate
in interface ContainerResponseContext
public Locale getLanguage()
getLanguage
in interface ContainerResponseContext
public MediaType getMediaType()
getMediaType
in interface ContainerResponseContext
public Set<String> getAllowedMethods()
getAllowedMethods
in interface ContainerResponseContext
public int getLength()
getLength
in interface ContainerResponseContext
public EntityTag getEntityTag()
getEntityTag
in interface ContainerResponseContext
public Date getLastModified()
getLastModified
in interface ContainerResponseContext
public URI getLocation()
getLocation
in interface ContainerResponseContext
public Set<Link> getLinks()
getLinks
in interface ContainerResponseContext
public boolean hasLink(String relation)
hasLink
in interface ContainerResponseContext
public Link getLink(String relation)
getLink
in interface ContainerResponseContext
public Link.Builder getLinkBuilder(String relation)
getLinkBuilder
in interface ContainerResponseContext
public boolean hasEntity()
hasEntity
in interface ContainerResponseContext
public Object getEntity()
getEntity
in interface ContainerResponseContext
public void setEntity(Object entity)
setEntity
in interface ContainerResponseContext
entity
- entity object.MessageBodyWriter
public void setEntity(Object entity, Annotation[] annotations)
entity
- entity object.annotations
- annotations attached to the entity.MessageBodyWriter
public void setEntity(Object entity, Type type, Annotation[] annotations)
entity
- entity object.type
- declared entity class.annotations
- annotations attached to the entity.MessageBodyWriter
public void setEntity(Object entity, Annotation[] annotations, MediaType mediaType)
setEntity
in interface ContainerResponseContext
public void setMediaType(MediaType mediaType)
mediaType
- message content media type.public Class<?> getEntityClass()
getEntityClass
in interface ContainerResponseContext
public Type getEntityType()
getEntityType
in interface ContainerResponseContext
public void setEntityType(Type type)
type
- overriding message entity type.public Annotation[] getEntityAnnotations()
getEntityAnnotations
in interface ContainerResponseContext
public void setEntityAnnotations(Annotation[] annotations)
annotations
- entity annotations.public OutputStream getEntityStream()
getEntityStream
in interface ContainerResponseContext
public void setEntityStream(OutputStream outputStream)
setEntityStream
in interface ContainerResponseContext
public void setStreamProvider(OutboundMessageContext.StreamProvider streamProvider)
entity stream
.streamProvider
- non-null
output stream provider.public void enableBuffering(Configuration configuration)
CommonProperties.OUTBOUND_CONTENT_LENGTH_BUFFER
.
The buffering functionality is by default disabled and could be enabled by calling this method. In this case
this method must be called before first bytes are written to the entity stream
.configuration
- runtime configuration.public void commitStream() throws IOException
entity stream
unless already committed.IOException
- in case of the IO error.public boolean isCommitted()
true
if the entity stream has been committed.true
if the entity stream has been committed. Otherwise returns false
.public void close()
public boolean isChunked()
true
if the response entity is a ChunkedOutput
instance.true
if the entity is a ChunkedOutput
instance, false
otherwise.Copyright © 2007-2024, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms.