public abstract class Multipart
extends java.lang.Object
Multipart also acts as the base class for the content object returned by most Multipart DataContentHandlers. For example, invoking getContent() on a DataHandler whose source is a "multipart/signed" data source may return an appropriate subclass of Multipart.
Some messaging systems provide different subtypes of Multiparts. For example, MIME specifies a set of subtypes that include "alternative", "mixed", "related", "parallel", "signed", etc.
Multipart is an abstract class. Subclasses provide actual implementations.
| Modifier and Type | Field and Description | 
|---|---|
| protected java.lang.String | contentTypeThis field specifies the content-type of this multipart
 object. | 
| protected Part | parentThe  Partcontaining thisMultipart,
 if known. | 
| protected java.util.Vector<BodyPart> | partsVector of BodyPart objects. | 
| Modifier | Constructor and Description | 
|---|---|
| protected  | Multipart()Default constructor. | 
| Modifier and Type | Method and Description | 
|---|---|
| void | addBodyPart(BodyPart part)Adds a Part to the multipart. | 
| void | addBodyPart(BodyPart part,
           int index)Adds a BodyPart at position  index. | 
| BodyPart | getBodyPart(int index)Get the specified Part. | 
| java.lang.String | getContentType()Return the content-type of this Multipart. | 
| int | getCount()Return the number of enclosed BodyPart objects. | 
| Part | getParent()Return the  Partthat contains thisMultipartobject, ornullif not known. | 
| boolean | removeBodyPart(BodyPart part)Remove the specified part from the multipart message. | 
| void | removeBodyPart(int index)Remove the part at specified location (starting from 0). | 
| protected void | setMultipartDataSource(MultipartDataSource mp)Setup this Multipart object from the given MultipartDataSource. | 
| void | setParent(Part parent)Set the parent of this  Multipartto be the specifiedPart. | 
| abstract void | writeTo(java.io.OutputStream os)Output an appropriately encoded bytestream to the given
 OutputStream. | 
protected java.util.Vector<BodyPart> parts
protected java.lang.String contentType
protected Part parent
Part containing this Multipart,
 if known.protected Multipart()
protected void setMultipartDataSource(MultipartDataSource mp) throws MessagingException
The method adds the MultipartDataSource's BodyPart objects into this Multipart. This Multipart's contentType is set to that of the MultipartDataSource.
This method is typically used in those cases where one has a multipart data source that has already been pre-parsed into the individual body parts (for example, an IMAP datasource), but needs to create an appropriate Multipart subclass that represents a specific multipart subtype.
mp - Multipart datasourceMessagingException - for failurespublic java.lang.String getContentType()
 This implementation just returns the value of the
 contentType field.
contentTypepublic int getCount()
             throws MessagingException
MessagingException - for failurespartspublic BodyPart getBodyPart(int index) throws MessagingException
index - the index of the desired Partjava.lang.IndexOutOfBoundsException - if the given index
                        is out of range.MessagingException - for other failurespublic boolean removeBodyPart(BodyPart part) throws MessagingException
part - The part to removeMessagingException - if no such Part existsIllegalWriteException - if the underlying
                        implementation does not support modification
                        of existing valuespublic void removeBodyPart(int index)
                    throws MessagingException
index - Index of the part to removejava.lang.IndexOutOfBoundsException - if the given index
                        is out of range.IllegalWriteException - if the underlying
                        implementation does not support modification
                        of existing valuesMessagingException - for other failurespublic void addBodyPart(BodyPart part) throws MessagingException
part - The Part to be appendedIllegalWriteException - if the underlying
                        implementation does not support modification
                        of existing valuesMessagingException - for other failurespublic void addBodyPart(BodyPart part, int index) throws MessagingException
index.
 If index is not the last one in the list,
 the subsequent parts are shifted up. If index
 is larger than the number of parts present, the
 BodyPart is appended to the end.part - The BodyPart to be insertedindex - Location where to insert the partIllegalWriteException - if the underlying
                        implementation does not support modification
                        of existing valuesMessagingException - for other failurespublic abstract void writeTo(java.io.OutputStream os)
                      throws java.io.IOException,
                             MessagingException
os - the stream to write tojava.io.IOException - if an IO related exception occursMessagingException - for other failurespublic Part getParent()
Part that contains this Multipart
 object, or null if not known.public void setParent(Part parent)
Multipart to be the specified
 Part.  Normally called by the Message
 or BodyPart setContent(Multipart) method.
 parent may be null if the
 Multipart is being removed from its containing
 Part.parent - the parent Part