org.glassfish.jersey.media.multipart
Class MultiPart

java.lang.Object
  extended by org.glassfish.jersey.media.multipart.BodyPart
      extended by org.glassfish.jersey.media.multipart.MultiPart
All Implemented Interfaces:
Closeable
Direct Known Subclasses:
FormDataMultiPart

public class MultiPart
extends BodyPart
implements Closeable

A mutable model representing a MIME MultiPart entity. This class extends BodyPart because MultiPart entities can be nested inside other MultiPart entities to an arbitrary depth.

Author:
Craig McClanahan, Paul Sandoz (paul.sandoz at oracle.com), Michal Gajdos (michal.gajdos at oracle.com)

Field Summary
 
Fields inherited from class org.glassfish.jersey.media.multipart.BodyPart
contentDisposition, messageBodyWorkers
 
Constructor Summary
MultiPart()
          Instantiates a new MultiPart with a mediaType of multipart/mixed.
MultiPart(javax.ws.rs.core.MediaType mediaType)
          Instantiates a new MultiPart with the specified characteristics.
 
Method Summary
 MultiPart bodyPart(BodyPart bodyPart)
          Builder pattern method to add the specified BodyPart to this MultiPart.
 MultiPart bodyPart(Object entity, javax.ws.rs.core.MediaType mediaType)
          Builder pattern method to add a newly configured BodyPart to this MultiPart.
 void cleanup()
          Performs any necessary cleanup at the end of processing this MultiPart.
 void close()
           
 BodyPart entity(Object entity)
          Override the entity set operation on a MultiPart to throw IllegalArgumentException.
 List<BodyPart> getBodyParts()
          Return a mutable list of BodyParts nested in this MultiPart.
 Object getEntity()
          Disables access to the entity for a MultiPart.
 void setEntity(Object entity)
          Disables access to the entity for a MultiPart.
 void setMediaType(javax.ws.rs.core.MediaType mediaType)
          Sets the MediaType for this MultiPart.
 MultiPart type(javax.ws.rs.core.MediaType type)
          Builder pattern method to return this MultiPart after additional configuration.
 
Methods inherited from class org.glassfish.jersey.media.multipart.BodyPart
contentDisposition, getContentDisposition, getEntityAs, getHeaders, getMediaType, getParameterizedHeaders, getParent, getProviders, setContentDisposition, setMessageBodyWorkers, setParent, setProviders
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MultiPart

public MultiPart()
Instantiates a new MultiPart with a mediaType of multipart/mixed.


MultiPart

public MultiPart(javax.ws.rs.core.MediaType mediaType)
Instantiates a new MultiPart with the specified characteristics.

Parameters:
mediaType - the MediaType for this multipart.
Method Detail

getBodyParts

public List<BodyPart> getBodyParts()
Return a mutable list of BodyParts nested in this MultiPart.


getEntity

public Object getEntity()
Disables access to the entity for a MultiPart. Use the list returned by getBodyParts() to access the relevant BodyPart instead.

Overrides:
getEntity in class BodyPart
Throws:
IllegalStateException - thrown unconditionally.

setEntity

public void setEntity(Object entity)
Disables access to the entity for a MultiPart. Use the list returned by getBodyParts() to access the relevant BodyPart instead.

Overrides:
setEntity in class BodyPart
Parameters:
entity -

setMediaType

public void setMediaType(javax.ws.rs.core.MediaType mediaType)
Sets the MediaType for this MultiPart. If never set, the default MediaType MUST be multipart/mixed.

Overrides:
setMediaType in class BodyPart
Parameters:
mediaType - the new MediaType.
Throws:
IllegalArgumentException - if the type property is not set to multipart.

bodyPart

public MultiPart bodyPart(BodyPart bodyPart)
Builder pattern method to add the specified BodyPart to this MultiPart.

Parameters:
bodyPart - BodyPart to be added.

bodyPart

public MultiPart bodyPart(Object entity,
                          javax.ws.rs.core.MediaType mediaType)
Builder pattern method to add a newly configured BodyPart to this MultiPart.

Parameters:
entity - entity object for this body part.
mediaType - content type for this body part.

entity

public BodyPart entity(Object entity)
Override the entity set operation on a MultiPart to throw IllegalArgumentException.

Overrides:
entity in class BodyPart
Parameters:
entity - entity to set for this BodyPart.

type

public MultiPart type(javax.ws.rs.core.MediaType type)
Builder pattern method to return this MultiPart after additional configuration.

Overrides:
type in class BodyPart
Parameters:
type - media type to set for this MultiPart.

cleanup

public void cleanup()
Performs any necessary cleanup at the end of processing this MultiPart.

Overrides:
cleanup in class BodyPart

close

public void close()
           throws IOException
Specified by:
close in interface Closeable
Throws:
IOException


Copyright © 2007-2014, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms.