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 String | contentType
This field specifies the content-type of this multipart object. |
| protected Part | parent
The |
| protected Vector | parts
Vector of BodyPart objects. |
| Access | Constructor and Description |
|---|---|
| protected |
| Modifier and Type | Method and Description |
|---|---|
| public synchronized void | |
| public synchronized void | addBodyPart(BodyPart
The BodyPart to be inserted part, int Location where to insert the part index)Adds a BodyPart at position |
| public synchronized BodyPart | |
| public synchronized String | |
| public synchronized int | |
| public synchronized Part | Returns: the parent PartReturn the |
| public synchronized boolean | Returns: true if part removed, false otherwiseThe part to remove part)Remove the specified part from the multipart message. |
| public synchronized void | removeBodyPart(int
Index of the part to remove index)Remove the part at specified location (starting from 0). |
| protected synchronized void | setMultipartDataSource(MultipartDataSource
Multipart datasource mp)Setup this Multipart object from the given MultipartDataSource. |
| public synchronized void | |
| public abstract void | writeTo(OutputStream
the stream to write to os)Output an appropriately encoded bytestream to the given OutputStream. |
| contentType | back to summary |
|---|---|
| protected String contentType This field specifies the content-type of this multipart object. It defaults to "multipart/mixed". | |
| parent | back to summary |
|---|---|
| protected Part parent The
| |
| parts | back to summary |
|---|---|
| protected Vector<BodyPart> parts Vector of BodyPart objects. | |
| Multipart | back to summary |
|---|---|
| protected Multipart() Default constructor. An empty Multipart object is created. | |
| addBodyPart | back to summary |
|---|---|
| public synchronized void addBodyPart(BodyPart part) throws MessagingException Adds a Part to the multipart. The BodyPart is appended to the list of existing Parts.
| |
| addBodyPart | back to summary |
|---|---|
| public synchronized void addBodyPart(BodyPart part, int index) throws MessagingException Adds a BodyPart at position
| |
| getBodyPart | back to summary |
|---|---|
| public synchronized BodyPart getBodyPart(int index) throws MessagingException Get the specified Part. Parts are numbered starting at 0.
| |
| getContentType | back to summary |
|---|---|
| public synchronized String getContentType() Return the content-type of this Multipart.
This implementation just returns the value of the
| |
| getCount | back to summary |
|---|---|
| public synchronized int getCount() throws MessagingException Return the number of enclosed BodyPart objects.
| |
| getParent | back to summary |
|---|---|
| public synchronized Part getParent() Return the
| |
| removeBodyPart | back to summary |
|---|---|
| public synchronized boolean removeBodyPart(BodyPart part) throws MessagingException Remove the specified part from the multipart message. Shifts all the parts after the removed part down one.
| |
| removeBodyPart | back to summary |
|---|---|
| public synchronized void removeBodyPart(int index) throws MessagingException Remove the part at specified location (starting from 0). Shifts all the parts after the removed part down one.
| |
| setMultipartDataSource | back to summary |
|---|---|
| protected synchronized void setMultipartDataSource(MultipartDataSource mp) throws MessagingException Setup this Multipart object from the given MultipartDataSource. 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.
| |
| setParent | back to summary |
|---|---|
| public synchronized void setParent(Part parent) Set the parent of this
| |
| writeTo | back to summary |
|---|---|
| public abstract void writeTo(OutputStream os) throws IOException, MessagingException Output an appropriately encoded bytestream to the given OutputStream. The implementation subclass decides the appropriate encoding algorithm to be used. The bytestream is typically used for sending.
| |