public class OutboundMessageContext extends MessageHeaderMethods
Modifier and Type | Class and Description |
---|---|
static interface |
OutboundMessageContext.StreamProvider
The callback interface which is used to get the terminal output stream into which the entity should be
written and to inform the implementation about the entity size.
|
runtimeDelegateDecorator
Constructor and Description |
---|
OutboundMessageContext()
Deprecated.
|
OutboundMessageContext(Configuration configuration)
Create new outbound message context.
|
OutboundMessageContext(OutboundMessageContext original)
Create new outbound message context copying the content
of another context.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the context.
|
void |
commitStream()
Commits the
entity stream if it wasn't already committed. |
void |
enableBuffering(Configuration configuration)
Enable a buffering of serialized entity.
|
List<Locale> |
getAcceptableLanguages()
Get a list of languages that are acceptable for the message.
|
List<MediaType> |
getAcceptableMediaTypes()
Get a list of media types that are acceptable for the message.
|
Configuration |
getConfiguration()
The related client/server side
Configuration . |
Object |
getEntity()
Get the message entity Java instance.
|
Annotation[] |
getEntityAnnotations()
Get the annotations attached to the entity.
|
Class<?> |
getEntityClass()
Get the raw message entity type information.
|
OutputStream |
getEntityStream()
Get the entity output stream.
|
Type |
getEntityType()
Get the message entity type information.
|
MultivaluedMap<String,Object> |
getHeaders()
Get the mutable message headers multivalued map.
|
String |
getHeaderString(String name)
Get a message header as a single string value.
|
HeaderValueException.Context |
getHeaderValueExceptionContext()
Return
HeaderValueException.Context type of the message context. |
Set<Link> |
getLinks()
Get the links attached to the message as header.
|
MediaType |
getMediaType()
Get the media type of the entity.
|
MultivaluedMap<String,String> |
getStringHeaders()
Get a multi-valued map representing outbound message headers with their values converted
to strings.
|
boolean |
hasEntity()
Check if there is an entity available in the message.
|
boolean |
isCommitted()
Returns
true if the entity stream has been committed. |
void |
replaceHeaders(MultivaluedMap<String,Object> headers)
Replace all headers.
|
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)
Set a new message message entity.
|
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)
Set a new entity output stream.
|
void |
setEntityType(Type type)
Set the message entity type information.
|
void |
setMediaType(MediaType mediaType)
Set the message content media type.
|
void |
setStreamProvider(OutboundMessageContext.StreamProvider streamProvider)
Set a stream provider callback.
|
containsHeaderString, containsHeaderString, exception, getAllowedMethods, getDate, getEntityTag, getLanguage, getLastModified, getLength, getLengthLong, getLink, getLinkBuilder, getLocation, getRequestCookies, getResponseCookies, hasLink, singleHeader, singleHeader
public OutboundMessageContext(Configuration configuration)
configuration
- the client/server Configuration
. If null
, the default behaviour is expected.public OutboundMessageContext(OutboundMessageContext original)
original
- the original outbound message context.@Deprecated public OutboundMessageContext()
OutboundMessageContext(Configuration)
public void replaceHeaders(MultivaluedMap<String,Object> headers)
headers
- new headers.public MultivaluedMap<String,String> getStringHeaders()
public String getHeaderString(String name)
Each single header value is converted to String using a
RuntimeDelegate.HeaderDelegate
if one is available
via RuntimeDelegate.createHeaderDelegate(java.lang.Class)
for the header value class or using its toString
method if a header
delegate is not available.
getHeaderString
in class MessageHeaderMethods
name
- the message header.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.public HeaderValueException.Context getHeaderValueExceptionContext()
MessageHeaderMethods
HeaderValueException.Context
type of the message context.getHeaderValueExceptionContext
in class MessageHeaderMethods
HeaderValueException.Context
type of the message context.public MultivaluedMap<String,Object> getHeaders()
getHeaders
in class MessageHeaderMethods
public MediaType getMediaType()
null
if not specified (e.g. there's no
message entity).public List<MediaType> getAcceptableMediaTypes()
public List<Locale> getAcceptableLanguages()
public Set<Link> getLinks()
getLinks
in class MessageHeaderMethods
Set
if no links are present. Never
returns null
.public boolean hasEntity()
The method returns true
if the entity is present, returns
false
otherwise.
true
if there is an entity present in the message,
false
otherwise.public Object getEntity()
Returns null
if the message does not contain an entity.
null
if message does not contain an
entity body.public void setEntity(Object entity)
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)
entity
- entity object.annotations
- annotations attached to the entity.mediaType
- entity media type.MessageBodyWriter
public void setMediaType(MediaType mediaType)
mediaType
- message content media type.public Class<?> getEntityClass()
public Type getEntityType()
public void setEntityType(Type type)
This method overrides any computed or previously set entity type information.
type
- overriding message entity type.public Annotation[] getEntityAnnotations()
public void setEntityAnnotations(Annotation[] annotations)
annotations
- entity annotations.public OutputStream getEntityStream()
public void setEntityStream(OutputStream outputStream)
outputStream
- new entity output stream.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 setStreamProvider(OutboundMessageContext.StreamProvider streamProvider)
entity stream
.streamProvider
- non-null
output stream provider.public void commitStream() throws IOException
entity stream
if it wasn't 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 Configuration getConfiguration()
Configuration
. Can be null
.Configuration
the configurationCopyright © 2007-2024, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms.