public abstract class Multipart
extends java.lang.Object
Some messaging systems provide different subtypes of multiparts. For example, MIME specifies a set of subtypes that include "alternative", "mixed", "related", "parallel", "signed", etc.
| Modifier and Type | Field and Description |
|---|---|
protected java.lang.String |
contentType
The content-type of this multipart object.
|
protected Part |
parent
The part containing this multipart, if known.
|
protected java.util.Vector |
parts
Vector of body parts.
|
| Modifier | Constructor and Description |
|---|---|
protected |
Multipart()
Constructor for an empty multipart of type "multipart/mixed".
|
| Modifier and Type | Method and Description |
|---|---|
void |
addBodyPart(BodyPart part)
Adds a body part to this multipart.
|
void |
addBodyPart(BodyPart part,
int index)
Inserts a body part at the specified index.
|
BodyPart |
getBodyPart(int index)
Get the specified body part.
|
java.lang.String |
getContentType()
Returns the content-type of this multipart.
|
int |
getCount()
Returns the number of enclosed body parts.
|
Part |
getParent()
Returns the part containing this multipart, or
null if
not known. |
boolean |
removeBodyPart(BodyPart part)
Removes the specified body part from this multipart.
|
void |
removeBodyPart(int index)
Removes the body part at the specified index.
|
protected void |
setMultipartDataSource(MultipartDataSource mp)
Configures this multipart from the given data source.
|
void |
setParent(Part part)
Sets the parent of this multipart.
|
abstract void |
writeTo(java.io.OutputStream os)
Writes this multipart to the specified byte stream.
|
protected java.util.Vector parts
protected java.lang.String contentType
protected Part parent
protected Multipart()
protected void setMultipartDataSource(MultipartDataSource mp) throws MessagingException
The method adds the body parts in the data source to this multipart, and sets the content-type.
mp - a multipart data sourceMessagingExceptionpublic java.lang.String getContentType()
public int getCount()
throws MessagingException
MessagingExceptionpublic BodyPart getBodyPart(int index) throws MessagingException
index - the index of the desired body partjava.lang.IndexOutOfBoundsException - if the given index is out of rangeMessagingExceptionpublic boolean removeBodyPart(BodyPart part) throws MessagingException
part - the body part to removeMessagingException - if the multipart has not been configuredIllegalWriteException - 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 rangeIllegalWriteException - if the underlying implementation
does not support modification of existing valuesMessagingExceptionpublic void addBodyPart(BodyPart part) throws MessagingException
part - the body part to be appendedIllegalWriteException - if the underlying implementation
does not support modification of existing valuesMessagingExceptionpublic void addBodyPart(BodyPart part, int index) throws MessagingException
part - the body part to be insertedindex - where to insert the partIllegalWriteException - if the underlying implementation
does not support modification of existing valuesMessagingExceptionpublic abstract void writeTo(java.io.OutputStream os)
throws java.io.IOException,
MessagingException
java.io.IOExceptionMessagingExceptionpublic Part getParent()
null if
not known.public void setParent(Part part)