public class BodyPart
extends java.lang.Object
A mutable model representing a body part nested inside a MIME MultiPart entity.
| Modifier and Type | Field and Description |
|---|---|
protected ContentDisposition |
cd |
| Constructor and Description |
|---|
BodyPart()
|
BodyPart(MediaType mediaType)
Instantiate a new
BodyPart with the specified characteristics. |
BodyPart(java.lang.Object entity,
MediaType mediaType)
Instantiate a new
BodyPart with the specified characteristics. |
| Modifier and Type | Method and Description |
|---|---|
void |
cleanup()
Perform any necessary cleanup at the end of processing this
BodyPart. |
BodyPart |
contentDisposition(ContentDisposition cd) |
BodyPart |
entity(java.lang.Object entity)
Builder pattern method to return this
BodyPart after
additional configuration. |
ContentDisposition |
getContentDisposition()
Get the content disposition.
|
java.lang.Object |
getEntity()
Return the entity object to be unmarshalled from a request, or to be
marshalled on a response.
|
<T> T |
getEntityAs(java.lang.Class<T> clazz)
Return the entity after appropriate conversion to the requested
type.
|
MultivaluedMap<java.lang.String,java.lang.String> |
getHeaders()
Return a mutable map of HTTP header value(s) for this
BodyPart,
keyed by the header name. |
MediaType |
getMediaType()
|
MultivaluedMap<java.lang.String,ParameterizedHeader> |
getParameterizedHeaders()
Return an immutable map of parameterized HTTP header value(s) for this
BodyPart, keyed by header name. |
MultiPart |
getParent()
|
Providers |
getProviders()
|
void |
setContentDisposition(ContentDisposition cd)
Set the content disposition.
|
void |
setEntity(java.lang.Object entity)
Set the entity object to be unmarshalled from a request, or to be
marshalled on a response.
|
void |
setMediaType(MediaType mediaType)
|
void |
setParent(MultiPart parent)
|
void |
setProviders(Providers providers)
|
BodyPart |
type(MediaType type)
Builder pattern method to return this
BodyPart after
additional configuration. |
protected ContentDisposition cd
public BodyPart()
Instantiate a new BodyPart with a mediaType of
text/plain.
public BodyPart(MediaType mediaType)
Instantiate a new BodyPart with the specified characteristics.
mediaType - The MediaType for this body partpublic java.lang.Object getEntity()
Return the entity object to be unmarshalled from a request, or to be marshalled on a response.
public void setEntity(java.lang.Object entity)
Set the entity object to be unmarshalled from a request, or to be marshalled on a response.
public MultivaluedMap<java.lang.String,java.lang.String> getHeaders()
public MultivaluedMap<java.lang.String,ParameterizedHeader> getParameterizedHeaders() throws java.text.ParseException
Return an immutable map of parameterized HTTP header value(s) for this
BodyPart, keyed by header name. Key comparisons in the
returned map must be case-insensitive. If you wish to modify the
headers map for this BodyPart, modify the map returned by
getHeaders() instead.
java.text.ParseExceptionpublic ContentDisposition getContentDisposition()
The "Content-Disposition" header, if present, will be parsed.
java.lang.IllegalArgumentException - if the content disposition header
cannot be parsed.public void setContentDisposition(ContentDisposition cd)
cd - the content disposition.public MediaType getMediaType()
public void setMediaType(MediaType mediaType)
mediaType - The new MediaTypejava.lang.IllegalArgumentException - if the mediaType is null.public MultiPart getParent()
public void setParent(MultiPart parent)
parent - The new parentpublic Providers getProviders()
public void cleanup()
Perform any necessary cleanup at the end of processing this
BodyPart.
public BodyPart entity(java.lang.Object entity)
Builder pattern method to return this BodyPart after
additional configuration.
entity - Entity to set for this BodyPartpublic <T> T getEntityAs(java.lang.Class<T> clazz)
Return the entity after appropriate conversion to the requested
type. This is useful only when the containing MultiPart
instance has been received, which causes the providers property
to have been set.
clazz - Desired class into which the entity should be convertedjava.lang.IllegalArgumentException - if no MessageBodyReader can
be found to perform the requested conversionjava.lang.IllegalStateException - if this method is called when the
providers property has not been set or when the
entity instance is not the unconverted content of the body part entitypublic BodyPart type(MediaType type)
Builder pattern method to return this BodyPart after
additional configuration.
type - Media type to set for this BodyPartpublic BodyPart contentDisposition(ContentDisposition cd)
Copyright © 2016 Oracle Corporation. All Rights Reserved.