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 ContainerResponseContextpublic void setStatus(int code)
setStatus in interface ContainerResponseContextpublic void setStatusInfo(Response.StatusType status)
setStatusInfo in interface ContainerResponseContextpublic Response.StatusType getStatusInfo()
getStatusInfo in interface ContainerResponseContextpublic ContainerRequest getRequestContext()
public Map<String,NewCookie> getCookies()
getCookies in interface ContainerResponseContextpublic OutboundMessageContext getWrappedMessageContext()
public String getHeaderString(String name)
getHeaderString in interface ContainerResponseContextpublic MultivaluedMap<String,Object> getHeaders()
getHeaders in interface ContainerResponseContextpublic MultivaluedMap<String,String> getStringHeaders()
getStringHeaders in interface ContainerResponseContextpublic Date getDate()
getDate in interface ContainerResponseContextpublic Locale getLanguage()
getLanguage in interface ContainerResponseContextpublic MediaType getMediaType()
getMediaType in interface ContainerResponseContextpublic Set<String> getAllowedMethods()
getAllowedMethods in interface ContainerResponseContextpublic int getLength()
getLength in interface ContainerResponseContextpublic EntityTag getEntityTag()
getEntityTag in interface ContainerResponseContextpublic Date getLastModified()
getLastModified in interface ContainerResponseContextpublic URI getLocation()
getLocation in interface ContainerResponseContextpublic Set<Link> getLinks()
getLinks in interface ContainerResponseContextpublic boolean hasLink(String relation)
hasLink in interface ContainerResponseContextpublic Link getLink(String relation)
getLink in interface ContainerResponseContextpublic Link.Builder getLinkBuilder(String relation)
getLinkBuilder in interface ContainerResponseContextpublic boolean hasEntity()
hasEntity in interface ContainerResponseContextpublic Object getEntity()
getEntity in interface ContainerResponseContextpublic void setEntity(Object entity)
setEntity in interface ContainerResponseContextentity - entity object.MessageBodyWriterpublic void setEntity(Object entity, Annotation[] annotations)
entity - entity object.annotations - annotations attached to the entity.MessageBodyWriterpublic void setEntity(Object entity, Type type, Annotation[] annotations)
entity - entity object.type - declared entity class.annotations - annotations attached to the entity.MessageBodyWriterpublic void setEntity(Object entity, Annotation[] annotations, MediaType mediaType)
setEntity in interface ContainerResponseContextpublic void setMediaType(MediaType mediaType)
mediaType - message content media type.public Class<?> getEntityClass()
getEntityClass in interface ContainerResponseContextpublic Type getEntityType()
getEntityType in interface ContainerResponseContextpublic void setEntityType(Type type)
type - overriding message entity type.public Annotation[] getEntityAnnotations()
getEntityAnnotations in interface ContainerResponseContextpublic void setEntityAnnotations(Annotation[] annotations)
annotations - entity annotations.public OutputStream getEntityStream()
getEntityStream in interface ContainerResponseContextpublic void setEntityStream(OutputStream outputStream)
setEntityStream in interface ContainerResponseContextpublic 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.