public class BodyPart extends Object
Modifier and Type | Field and Description |
---|---|
protected ContentDisposition |
contentDisposition |
MessageBodyWorkers |
messageBodyWorkers |
Constructor and Description |
---|
BodyPart()
Instantiates a new
BodyPart with a mediaType of
text/plain . |
BodyPart(javax.ws.rs.core.MediaType mediaType)
Instantiates a new
BodyPart with the specified characteristics. |
BodyPart(Object entity,
javax.ws.rs.core.MediaType mediaType)
Instantiates 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 contentDisposition)
Builder pattern method to return this
BodyPart after
additional configuration. |
BodyPart |
entity(Object entity)
Builder pattern method to return this
BodyPart after additional configuration. |
ContentDisposition |
getContentDisposition()
Gets the content disposition.
|
Object |
getEntity()
Returns the entity object to be unmarshalled from a request, or to be
marshalled on a response.
|
<T> T |
getEntityAs(Class<T> clazz)
Returns the entity after appropriate conversion to the requested type.
|
javax.ws.rs.core.MultivaluedMap<String,String> |
getHeaders()
Returns a mutable map of HTTP header value(s) for this
BodyPart , keyed by the header name. |
javax.ws.rs.core.MediaType |
getMediaType()
Returns the
MediaType for this BodyPart . |
javax.ws.rs.core.MultivaluedMap<String,ParameterizedHeader> |
getParameterizedHeaders()
Returns an immutable map of parameterized HTTP header value(s) for this
BodyPart ,
keyed by header name. |
MultiPart |
getParent()
Returns the parent
MultiPart (if any) for this BodyPart . |
javax.ws.rs.ext.Providers |
getProviders()
Returns the configured
Providers for this BodyPart . |
void |
setContentDisposition(ContentDisposition contentDisposition)
Sets 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)
Sets the
MediaType for this BodyPart . |
void |
setMessageBodyWorkers(MessageBodyWorkers messageBodyWorkers)
Set message body workers used to transform an entity stream into particular Java type.
|
void |
setParent(MultiPart parent)
Sets the parent
MultiPart (if any) for this BodyPart . |
void |
setProviders(javax.ws.rs.ext.Providers providers)
Sets 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 contentDisposition
public MessageBodyWorkers messageBodyWorkers
public BodyPart()
BodyPart
with a mediaType
of
text/plain
.public BodyPart(javax.ws.rs.core.MediaType mediaType)
BodyPart
with the specified characteristics.mediaType
- MediaType
for this body part.public BodyPart(Object entity, javax.ws.rs.core.MediaType mediaType)
BodyPart
with the specified characteristics.entity
- entity for this body part.mediaType
- MediaType
for this body part.public Object getEntity()
IllegalStateException
- if this method is called on a MultiPart
instance; access the underlying
BodyPart
s insteadpublic void setEntity(Object entity)
entity
- the new entity object.IllegalStateException
- if this method is called on a MultiPart
instance; access the underlying
BodyPart
s insteadpublic javax.ws.rs.core.MultivaluedMap<String,String> getHeaders()
BodyPart
, keyed by the header name. Key comparisons in
the returned map must be case-insensitive.
Note: MIME specifications says only headers that match Content-*
should be included on a BodyPart
.public javax.ws.rs.core.MultivaluedMap<String,ParameterizedHeader> getParameterizedHeaders() throws ParseException
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
- if an un-expected/in-correct value is found during parsing the headers.public ContentDisposition getContentDisposition()
IllegalArgumentException
- if the content disposition header cannot be parsed.public void setContentDisposition(ContentDisposition contentDisposition)
contentDisposition
- the content disposition.public javax.ws.rs.core.MediaType getMediaType()
MediaType
for this BodyPart
. If not
set, the default MediaType
MUST be text/plain
.public void setMediaType(javax.ws.rs.core.MediaType mediaType)
MediaType
for this BodyPart
.mediaType
- the new MediaType
.IllegalArgumentException
- if the mediaType
is null
.public MultiPart getParent()
MultiPart
(if any) for this BodyPart
.null
if not set.public void setParent(MultiPart parent)
MultiPart
(if any) for this BodyPart
.parent
- the new parent.public javax.ws.rs.ext.Providers getProviders()
Providers
for this BodyPart
.public void setProviders(javax.ws.rs.ext.Providers providers)
Providers
for this BodyPart
.providers
- the new Providers
.public void cleanup()
BodyPart
.public BodyPart entity(Object entity)
BodyPart
after additional configuration.entity
- entity to set for this BodyPart
.public <T> T getEntityAs(Class<T> clazz)
MultiPart
instance has been received, which causes the providers
property to have been set.clazz
- desired class into which the entity should be converted.javax.ws.rs.ProcessingException
- if an IO error arises during reading an entity.IllegalArgumentException
- if no MessageBodyReader
can be found to perform the requested conversion.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 entity.public BodyPart type(javax.ws.rs.core.MediaType type)
BodyPart
after additional configuration.type
- media type to set for this BodyPart
.public BodyPart contentDisposition(ContentDisposition contentDisposition)
BodyPart
after
additional configuration.contentDisposition
- content disposition to set for this BodyPart
.public void setMessageBodyWorkers(MessageBodyWorkers messageBodyWorkers)
messageBodyWorkers
- message body workers.Copyright © 2007-2021, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms.