public class BodyPart extends 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(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(Object entity)
Builder pattern method to return this
BodyPart after
additional configuration. |
ContentDisposition |
getContentDisposition()
Get the content disposition.
|
Object |
getEntity()
Return the entity object to be unmarshalled from a request, or to be
marshalled on a response.
|
<T> T |
getEntityAs(Class<T> clazz)
Return the entity after appropriate conversion to the requested
type.
|
javax.ws.rs.core.MultivaluedMap<String,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<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(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 Object getEntity()
Return the entity object to be unmarshalled from a request, or to be marshalled on a response.
IllegalStateException
- if this method is called on a
MultiPart
instance; access the underlying BodyPart
s insteadpublic void setEntity(Object entity)
Set the entity object to be unmarshalled from a request, or to be marshalled on a response.
entity
- The new entity objectIllegalStateException
- if this method is called on a
MultiPart
instance; access the underlying BodyPart
s insteadpublic javax.ws.rs.core.MultivaluedMap<String,ParameterizedHeader> getParameterizedHeaders() throws 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.
ParseException
public ContentDisposition getContentDisposition()
The "Content-Disposition" header, if present, will be parsed.
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 MediaType
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 Providers
public void cleanup()
Perform any necessary cleanup at the end of processing this
BodyPart
.
public BodyPart entity(Object entity)
Builder pattern method to return this BodyPart
after
additional configuration.
entity
- Entity to set for this BodyPart
public <T> T getEntityAs(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 convertedIllegalArgumentException
- if no MessageBodyReader
can
be found to perform the requested conversionIllegalStateException
- 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 BodyPart
public BodyPart contentDisposition(ContentDisposition cd)
Copyright © 2013 Oracle Corporation. All rights reserved.