java.lang.Object | +--javax.mail.Multipart
Multipart is a container that holds multiple body parts. Multipart provides methods to retrieve and set its subparts.
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.
contentType This field specifies the content-type of this multipart object. | |
parent The Part containing thisMultipart , if known. | |
parts Vector of BodyPart objects. |
Multipart() Default constructor. |
addBodyPart(BodyPart part) Adds a Part to the multipart. | |
addBodyPart(BodyPart part, int index) Adds a BodyPart at position index . | |
getBodyPart(int index) Get the specified Part. | |
getContentType() Return the content-type of this Multipart. | |
getCount() Return the number of enclosed BodyPart objects. | |
getParent() Return the Part that contains thisMultipart object, ornull if not known. | |
removeBodyPart(BodyPart part) Remove the specified part from the multipart message. | |
removeBodyPart(int index) Remove the part at specified location (starting from 0). | |
setMultipartDataSource(MultipartDataSource mp) Setup this Multipart object from the given MultipartDataSource. | |
setParent(Part parent) Set the parent of this Multipart to be the specifiedPart . | |
writeTo(java.io.OutputStream os) Output an appropriately encoded bytestream to the given OutputStream. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
protected java.util.Vectorparts
protected java.lang.StringcontentType
protectedPartparent
Part
containing thisMultipart
, if known.protectedMultipart()
protected voidsetMultipartDataSource(MultipartDataSource mp) throwsMessagingException
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 datasourcepublic java.lang.StringgetContentType()
This implementation just returns the value of thecontentType
field.
contentType
public intgetCount() throwsMessagingException
parts
publicBodyPartgetBodyPart(int index) throwsMessagingException
index
- the index of the desired Partjava.lang.IndexOutOfBoundsException
- if the given indexis out of range.MessagingException
- public booleanremoveBodyPart(BodyPart part) throwsMessagingException
part
- The part to removeMessagingException
- if no such Part existsIllegalWriteException
- if the underlyingimplementation does not support modificationof existing valuespublic voidremoveBodyPart(int index) throwsMessagingException
index
- Index of the part to removeMessagingException
- java.lang.IndexOutOfBoundsException
- if the given indexis out of range.IllegalWriteException
- if the underlyingimplementation does not support modificationof existing valuespublic voidaddBodyPart(BodyPart part) throwsMessagingException
part
- The Part to be appendedMessagingException
- IllegalWriteException
- if the underlyingimplementation does not support modificationof existing valuespublic voidaddBodyPart(BodyPart part, int index) throwsMessagingException
index
. Ifindex
is not the last one in the list, the subsequent parts are shifted up. Ifindex
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 partMessagingException
- IllegalWriteException
- if the underlyingimplementation does not support modificationof existing valuespublic abstract voidwriteTo(java.io.OutputStream os) throws java.io.IOException,MessagingException
java.io.IOException
- if an IO related exception occursMessagingException
- publicPartgetParent()
Part
that contains thisMultipart
object, ornull
if not known.public voidsetParent(Part parent)
Multipart
to be the specifiedPart
. Normally called by theMessage
orBodyPart
setContent(Multipart)
method.parent
may benull
if theMultipart
is being removed from its containingPart
.