public class ContainerResponse
extends java.lang.Object
implements javax.ws.rs.container.ContainerResponseContext
| Modifier and Type | Field and Description |
|---|---|
private boolean |
closed |
private boolean |
mappedFromException |
private OutboundMessageContext |
messageContext |
private ContainerRequest |
requestContext |
private javax.ws.rs.core.Response.StatusType |
status |
| Constructor and Description |
|---|
ContainerResponse(ContainerRequest requestContext,
OutboundJaxrsResponse response)
Create a new Jersey container response context.
|
ContainerResponse(ContainerRequest requestContext,
javax.ws.rs.core.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(javax.ws.rs.core.Configuration configuration)
Enable a buffering of serialized entity.
|
java.util.Set<java.lang.String> |
getAllowedMethods() |
java.util.Map<java.lang.String,javax.ws.rs.core.NewCookie> |
getCookies() |
java.util.Date |
getDate() |
java.lang.Object |
getEntity() |
java.lang.annotation.Annotation[] |
getEntityAnnotations() |
java.lang.Class<?> |
getEntityClass() |
java.io.OutputStream |
getEntityStream() |
javax.ws.rs.core.EntityTag |
getEntityTag() |
java.lang.reflect.Type |
getEntityType() |
javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.Object> |
getHeaders() |
java.lang.String |
getHeaderString(java.lang.String name) |
java.util.Locale |
getLanguage() |
java.util.Date |
getLastModified() |
int |
getLength() |
javax.ws.rs.core.Link |
getLink(java.lang.String relation) |
javax.ws.rs.core.Link.Builder |
getLinkBuilder(java.lang.String relation) |
java.util.Set<javax.ws.rs.core.Link> |
getLinks() |
java.net.URI |
getLocation() |
javax.ws.rs.core.MediaType |
getMediaType() |
ContainerRequest |
getRequestContext()
Get the associated container request context paired with this response context.
|
int |
getStatus() |
javax.ws.rs.core.Response.StatusType |
getStatusInfo() |
javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.String> |
getStringHeaders() |
OutboundMessageContext |
getWrappedMessageContext()
Get the wrapped response message context.
|
boolean |
hasEntity() |
boolean |
hasLink(java.lang.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(java.lang.Object entity)
Set a new message message entity.
|
void |
setEntity(java.lang.Object entity,
java.lang.annotation.Annotation[] annotations)
Set a new message message entity.
|
void |
setEntity(java.lang.Object entity,
java.lang.annotation.Annotation[] annotations,
javax.ws.rs.core.MediaType mediaType) |
void |
setEntity(java.lang.Object entity,
java.lang.reflect.Type type,
java.lang.annotation.Annotation[] annotations)
Set a new message message entity.
|
void |
setEntityAnnotations(java.lang.annotation.Annotation[] annotations)
Set the annotations attached to the entity.
|
void |
setEntityStream(java.io.OutputStream outputStream) |
void |
setEntityType(java.lang.reflect.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(javax.ws.rs.core.MediaType mediaType)
Set the message content media type.
|
void |
setStatus(int code) |
void |
setStatusInfo(javax.ws.rs.core.Response.StatusType status) |
void |
setStreamProvider(OutboundMessageContext.StreamProvider streamProvider)
Set the output stream provider callback.
|
private javax.ws.rs.core.Response.StatusType status
private final ContainerRequest requestContext
private final OutboundMessageContext messageContext
private boolean mappedFromException
private boolean closed
public ContainerResponse(ContainerRequest requestContext, javax.ws.rs.core.Response response)
requestContext - associated container request context.response - response instance initializing the response context.ContainerResponse(ContainerRequest requestContext, OutboundJaxrsResponse 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 javax.ws.rs.container.ContainerResponseContextpublic void setStatus(int code)
setStatus in interface javax.ws.rs.container.ContainerResponseContextpublic void setStatusInfo(javax.ws.rs.core.Response.StatusType status)
setStatusInfo in interface javax.ws.rs.container.ContainerResponseContextpublic javax.ws.rs.core.Response.StatusType getStatusInfo()
getStatusInfo in interface javax.ws.rs.container.ContainerResponseContextpublic ContainerRequest getRequestContext()
public java.util.Map<java.lang.String,javax.ws.rs.core.NewCookie> getCookies()
getCookies in interface javax.ws.rs.container.ContainerResponseContextpublic OutboundMessageContext getWrappedMessageContext()
public java.lang.String getHeaderString(java.lang.String name)
getHeaderString in interface javax.ws.rs.container.ContainerResponseContextpublic javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.Object> getHeaders()
getHeaders in interface javax.ws.rs.container.ContainerResponseContextpublic javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.String> getStringHeaders()
getStringHeaders in interface javax.ws.rs.container.ContainerResponseContextpublic java.util.Date getDate()
getDate in interface javax.ws.rs.container.ContainerResponseContextpublic java.util.Locale getLanguage()
getLanguage in interface javax.ws.rs.container.ContainerResponseContextpublic javax.ws.rs.core.MediaType getMediaType()
getMediaType in interface javax.ws.rs.container.ContainerResponseContextpublic java.util.Set<java.lang.String> getAllowedMethods()
getAllowedMethods in interface javax.ws.rs.container.ContainerResponseContextpublic int getLength()
getLength in interface javax.ws.rs.container.ContainerResponseContextpublic javax.ws.rs.core.EntityTag getEntityTag()
getEntityTag in interface javax.ws.rs.container.ContainerResponseContextpublic java.util.Date getLastModified()
getLastModified in interface javax.ws.rs.container.ContainerResponseContextpublic java.net.URI getLocation()
getLocation in interface javax.ws.rs.container.ContainerResponseContextpublic java.util.Set<javax.ws.rs.core.Link> getLinks()
getLinks in interface javax.ws.rs.container.ContainerResponseContextpublic boolean hasLink(java.lang.String relation)
hasLink in interface javax.ws.rs.container.ContainerResponseContextpublic javax.ws.rs.core.Link getLink(java.lang.String relation)
getLink in interface javax.ws.rs.container.ContainerResponseContextpublic javax.ws.rs.core.Link.Builder getLinkBuilder(java.lang.String relation)
getLinkBuilder in interface javax.ws.rs.container.ContainerResponseContextpublic boolean hasEntity()
hasEntity in interface javax.ws.rs.container.ContainerResponseContextpublic java.lang.Object getEntity()
getEntity in interface javax.ws.rs.container.ContainerResponseContextpublic void setEntity(java.lang.Object entity)
setEntity in interface javax.ws.rs.container.ContainerResponseContextentity - entity object.MessageBodyWriterpublic void setEntity(java.lang.Object entity,
java.lang.annotation.Annotation[] annotations)
entity - entity object.annotations - annotations attached to the entity.MessageBodyWriterpublic void setEntity(java.lang.Object entity,
java.lang.reflect.Type type,
java.lang.annotation.Annotation[] annotations)
entity - entity object.type - declared entity class.annotations - annotations attached to the entity.MessageBodyWriterpublic void setEntity(java.lang.Object entity,
java.lang.annotation.Annotation[] annotations,
javax.ws.rs.core.MediaType mediaType)
setEntity in interface javax.ws.rs.container.ContainerResponseContextpublic void setMediaType(javax.ws.rs.core.MediaType mediaType)
mediaType - message content media type.public java.lang.Class<?> getEntityClass()
getEntityClass in interface javax.ws.rs.container.ContainerResponseContextpublic java.lang.reflect.Type getEntityType()
getEntityType in interface javax.ws.rs.container.ContainerResponseContextpublic void setEntityType(java.lang.reflect.Type type)
type - overriding message entity type.public java.lang.annotation.Annotation[] getEntityAnnotations()
getEntityAnnotations in interface javax.ws.rs.container.ContainerResponseContextpublic void setEntityAnnotations(java.lang.annotation.Annotation[] annotations)
annotations - entity annotations.public java.io.OutputStream getEntityStream()
getEntityStream in interface javax.ws.rs.container.ContainerResponseContextpublic void setEntityStream(java.io.OutputStream outputStream)
setEntityStream in interface javax.ws.rs.container.ContainerResponseContextpublic void setStreamProvider(OutboundMessageContext.StreamProvider streamProvider)
entity stream.streamProvider - non-null output stream provider.public void enableBuffering(javax.ws.rs.core.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 java.io.IOException
entity stream unless already committed.java.io.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.