public class FormDataBodyPart extends BodyPart
BodyPart
with specialized support for media type
multipart/form-data
. See
RFC 2388
for the formal definition of this media type.
For a server side application wishing to process an incoming
multipart/form-data
message, the following features
are provided:
MessageBodyReader
.multipart/form-data
message, the following features
are provided:
contentDisposition, messageBodyWorkers
Constructor and Description |
---|
FormDataBodyPart()
|
FormDataBodyPart(boolean fileNameFix)
Instantiates an unnamed new
FormDataBodyPart with mediaType of text/plain
and setting the flag for applying the fix for erroneous file name value if content disposition header of
messages coming from MS Internet Explorer (see JERSEY-759). |
FormDataBodyPart(FormDataContentDisposition formDataContentDisposition,
Object entity,
MediaType mediaType)
Instantiates a named
FormDataBodyPart with the
specified characteristics. |
FormDataBodyPart(FormDataContentDisposition formDataContentDisposition,
String value)
Instantiates a named
FormDataBodyPart with the
specified characteristics. |
FormDataBodyPart(MediaType mediaType)
Instantiates an unnamed
FormDataBodyPart with the
specified characteristics. |
FormDataBodyPart(Object entity,
MediaType mediaType)
Instantiates an unnamed
FormDataBodyPart with the
specified characteristics. |
FormDataBodyPart(String name,
Object entity,
MediaType mediaType)
Instantiates a named
FormDataBodyPart with the
specified characteristics. |
FormDataBodyPart(String name,
String value)
Instantiates a named
FormDataBodyPart with a
media type of text/plain and String value. |
Modifier and Type | Method and Description |
---|---|
ContentDisposition |
getContentDisposition()
Overrides the behaviour on
BodyPart to ensure that
only instances of FormDataContentDisposition can be obtained. |
FormDataContentDisposition |
getFormDataContentDisposition()
Gets the form data content disposition.
|
String |
getName()
Gets the control name.
|
String |
getValue()
Gets the field value for this body part.
|
<T> T |
getValueAs(Class<T> clazz)
Gets the field value after appropriate conversion to the requested type.
|
boolean |
isSimple() |
void |
setContentDisposition(ContentDisposition contentDisposition)
Overrides the behaviour on
BodyPart to ensure that
only instances of FormDataContentDisposition can be set. |
void |
setFormDataContentDisposition(FormDataContentDisposition formDataContentDisposition)
Sets the form data content disposition.
|
void |
setName(String name)
Sets the control name.
|
void |
setValue(MediaType mediaType,
Object value)
Sets the field media type and value for this body part.
|
void |
setValue(String value)
Sets the field value for this body part.
|
cleanup, contentDisposition, entity, getEntity, getEntityAs, getHeaders, getMediaType, getParameterizedHeaders, getParent, getProviders, setEntity, setMediaType, setMessageBodyWorkers, setParent, setProviders, type
public FormDataBodyPart()
public FormDataBodyPart(boolean fileNameFix)
FormDataBodyPart
with mediaType
of text/plain
and setting the flag for applying the fix for erroneous file name value if content disposition header of
messages coming from MS Internet Explorer (see JERSEY-759).fileNameFix
- If set to true
, header parser will not treat backslash as an escape character when retrieving
the value of filename
parameter of Content-Disposition
header.public FormDataBodyPart(MediaType mediaType)
FormDataBodyPart
with the
specified characteristics.mediaType
- the MediaType
for this body part.public FormDataBodyPart(Object entity, MediaType mediaType)
FormDataBodyPart
with the
specified characteristics.entity
- the entity for this body part.mediaType
- the MediaType
for this body part.public FormDataBodyPart(String name, String value)
FormDataBodyPart
with a
media type of text/plain
and String value.name
- the control name for this body part.value
- the value for this body part.public FormDataBodyPart(String name, Object entity, MediaType mediaType)
FormDataBodyPart
with the
specified characteristics.name
- the control name for this body part.entity
- the entity for this body part.mediaType
- the MediaType
for this body part.public FormDataBodyPart(FormDataContentDisposition formDataContentDisposition, String value)
FormDataBodyPart
with the
specified characteristics.formDataContentDisposition
- the content disposition header for this body part.value
- the value for this body part.public FormDataBodyPart(FormDataContentDisposition formDataContentDisposition, Object entity, MediaType mediaType)
FormDataBodyPart
with the
specified characteristics.formDataContentDisposition
- the content disposition header for this body part.entity
- the entity for this body part.mediaType
- the MediaType
for this body part.public FormDataContentDisposition getFormDataContentDisposition()
public void setFormDataContentDisposition(FormDataContentDisposition formDataContentDisposition)
formDataContentDisposition
- the form data content disposition.public ContentDisposition getContentDisposition()
BodyPart
to ensure that
only instances of FormDataContentDisposition
can be obtained.getContentDisposition
in class BodyPart
IllegalArgumentException
- if the content disposition header cannot be parsed.public void setContentDisposition(ContentDisposition contentDisposition)
BodyPart
to ensure that
only instances of FormDataContentDisposition
can be set.setContentDisposition
in class BodyPart
contentDisposition
- the content disposition which must be an instance of FormDataContentDisposition
.IllegalArgumentException
- if the content disposition is not an instance of FormDataContentDisposition
.public String getName()
public void setName(String name)
name
- the control name.public String getValue()
ProcessingException
- if an IO error arises during reading the value.IllegalStateException
- if called on a body part with a media type other than text/plain
public <T> T getValueAs(Class<T> clazz)
FormDataMultiPart
instance has been received, which causes the providers
property to have been set.T
- the type of the field value.clazz
- Desired class into which the field value should be converted.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 void setValue(String value)
value
- the field value.IllegalStateException
- if called on a body part with a media type other than text/plain
.public void setValue(MediaType mediaType, Object value)
mediaType
- the media type for this field value.value
- the field value as a Java object.public boolean isSimple()
true
if this body part represents a simple, string-based, field value, otherwise false
.Copyright © 2007-2024, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms.