com.sun.jersey.multipart
Class FormDataMultiPart

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

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:

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

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


Constructor Summary
FormDataMultiPart()
          Instantiate a new FormDataMultiPart instance with default characteristics.
 
Method Summary
 FormDataMultiPart field(java.lang.String name, java.lang.Object entity, javax.ws.rs.core.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)
          Return the FormDataBodyPart for the specified field name, if any; otherwise, return null.
 java.util.Map<java.lang.String,FormDataBodyPart> getFields()
          Return an immutable Map of the FormDataBodyParts for all fields, keyed by field name.
 void setMediaType(javax.ws.rs.core.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, entity, getBodyParts, getEntity, setEntity, type
 
Methods inherited from class com.sun.jersey.multipart.BodyPart
getEntityAs, getHeaders, getMediaType, getParameterizedHeaders, getParent, getProviders, 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.


field

public FormDataMultiPart field(java.lang.String name,
                               java.lang.Object entity,
                               javax.ws.rs.core.MediaType mediaType)

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

Parameters:
name - Field name of the new field
entity - Entity value for the new field
mediaType - Media type for the new field

getField

public FormDataBodyPart getField(java.lang.String name)

Return the FormDataBodyPart for the specified field name, if any; otherwise, return null.


getFields

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

Return an immutable Map of the FormDataBodyParts for all fields, keyed by field name.


setMediaType

public void setMediaType(javax.ws.rs.core.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


Copyright © 2009 Sun Microsystems, Inc. All Rights Reserved.