Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.sun.jersey.multipart
Class FormDataMultiPart

    java.lang.Object
      com.sun.jersey.multipart.BodyPart
          com.sun.jersey.multipart.MultiPart
              com.sun.jersey.multipart.FormDataMultiPart

All Implemented Interfaces:
  java.io.Closeable

    public class FormDataMultiPart

extends MultiPart

Subclass of `MultiPart` 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:

- Incoming entities will be of type `FormDataMultiPart`, enabling access to the specialized methods.
- Incoming body parts will be of type `FormDataBodyPart`, enabling access to its specialized methods.
- Convenience method to return the `FormDataBodyPart` for a specified control name.
- Convenience method to return a `Map` of `FormDataBodyPart`s for all fields, keyed by field name.

For a client side application wishing to construct an outgoing `multipart/form-data` message, the following features are provided:

- Media type of the `FormDataMultiPart` instance will automatically set to `multipart/form-data`.
- Builder pattern method to add simple field values as body parts of type `text/plain`.
- Builder pattern method to add named "file" field values with arbitrary media types.

FIXME - Consider supporting the use case of a nested `multipart/mixed` body part to contain multiple uploaded files.

Field Summary

Fields inherited from class com.sun.jersey.multipart.BodyPart
`cd`

Constructor Summary
`FormDataMultiPart()` Instantiate a new `FormDataMultiPart` instance with default characteristics.

Method Summary
`FormDataMultiPart` | `field(java.lang.String name, java.lang.Object entity, MediaType mediaType)` Builder pattern method to add a named field with an arbitrary media type and entity, and return this instance.
`FormDataMultiPart` | `field(java.lang.String name, java.lang.String value)` Builder pattern method to add a named field with a text value, and return this instance.
`FormDataBodyPart` | `getField(java.lang.String name)` Get a form data body part given a control name.
`java.util.Map<java.lang.String,java.util.List<FormDataBodyPart>>` | `getFields()` Get a map of form data body parts where the key is the control name and the value is a list of one or more form data body parts.
`java.util.List<FormDataBodyPart>` | `getFields(java.lang.String name)` Get a list of one or more form data body parts given a control name.
`void` | `setMediaType(MediaType mediaType)` Disable changing the media type to anything other than `multipart/form-data`.

Methods inherited from class com.sun.jersey.multipart.MultiPart
`bodyPart, bodyPart, cleanup, close, entity, getBodyParts, getEntity, setEntity, type`

Methods inherited from class com.sun.jersey.multipart.BodyPart
`contentDisposition, getContentDisposition, getEntityAs, getHeaders, getMediaType, getParameterizedHeaders, getParent, getProviders, setContentDisposition, setParent, setProviders`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### FormDataMultiPart

    public FormDataMultiPart()

  Instantiate a new `FormDataMultiPart` instance with default characteristics.

Method Detail

### field

    public FormDataMultiPart field(java.lang.String name,
                                   java.lang.String value)

  Builder pattern method to add a named field with a text value, and return this instance.

  Parameters:
    `name` - the control name
    `value` - the text value
  Returns:
    this instance.

### field

    public FormDataMultiPart field(java.lang.String name,
                                   java.lang.Object entity,
                                   MediaType mediaType)

  Builder pattern method to add a named field with an arbitrary media type and entity, and return this instance.

  Parameters:
    `name` - the control name.
    `entity` - entity value for the new field
    `mediaType` - media type for the new field
  Returns:
    this instance.

### getField

    public FormDataBodyPart getField(java.lang.String name)

  Get a form data body part given a control name.

  Parameters:
    `name` - the control name.
  Returns:
    the form data body part, otherwise null if no part is present with the given control name. If more that one part is present with the same control name, then the first part that occurs is returned.

### getFields

    public java.util.List<FormDataBodyPart> getFields(java.lang.String name)

  Get a list of one or more form data body parts given a control name.

  Parameters:
    `name` - the control name.
  Returns:
    the list of form data body parts, otherwise null if no parts are present with the given control name.

### getFields

    public java.util.Map<java.lang.String,java.util.List<FormDataBodyPart>> getFields()

  Get a map of form data body parts where the key is the control name and the value is a list of one or more form data body parts.

  Returns:
    return the map of form data body parts.

### setMediaType

    public void setMediaType(MediaType mediaType)

  Disable changing the media type to anything other than `multipart/form-data`.

  Overrides:
    `setMediaType` in class `MultiPart`
  Parameters:
    `mediaType` - The proposed media type
  Throws:
    `java.lang.IllegalArgumentException` - if the proposed media type is not `multipart/form-data`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2013 Oracle Corporation. All Rights Reserved.