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(javax.ws.rs.core.MediaType mediaType)
Instantiate a new
BodyPart with the specified characteristics. |
BodyPart(java.lang.Object entity,
javax.ws.rs.core.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.
|
javax.ws.rs.core.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. |
javax.ws.rs.core.MediaType |
getMediaType()
Return the
MediaType for this BodyPart. |
javax.ws.rs.core.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()
|
javax.ws.rs.ext.Providers |
getProviders()
Return the configured
Providers for this BodyPart. |
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(javax.ws.rs.core.MediaType mediaType)
Set the
MediaType for this BodyPart. |
void |
setParent(MultiPart parent)
|
void |
setProviders(javax.ws.rs.ext.Providers providers)
Set the configured
Providers for this BodyPart. |
BodyPart |
type(javax.ws.rs.core.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(javax.ws.rs.core.MediaType mediaType)
Instantiate a new BodyPart with the specified characteristics.
mediaType - The MediaType for this body partpublic BodyPart(java.lang.Object entity,
javax.ws.rs.core.MediaType mediaType)
Instantiate a new BodyPart with the specified characteristics.
entity - The entity for this body partmediaType - 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 javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.String> getHeaders()
public javax.ws.rs.core.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 javax.ws.rs.core.MediaType getMediaType()
Return the MediaType for this BodyPart. If never
set, the default MediaType MUST be text/plain.
public void setMediaType(javax.ws.rs.core.MediaType mediaType)
Set the MediaType for this BodyPart.
mediaType - The new MediaTypejava.lang.IllegalArgumentException - if the mediaType is null.public MultiPart getParent()
public void setParent(MultiPart parent)
parent - The new parentpublic javax.ws.rs.ext.Providers getProviders()
Return the configured Providers for this BodyPart.
public void setProviders(javax.ws.rs.ext.Providers providers)
Set the configured Providers for this BodyPart.
providers - The new Providerspublic 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(javax.ws.rs.core.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.