javax.mail

Class Multipart

public abstract class Multipart extends Object

A multipart is a container for multiple body parts.

Some messaging systems provide different subtypes of multiparts. For example, MIME specifies a set of subtypes that include "alternative", "mixed", "related", "parallel", "signed", etc.

Version: 1.4

Author: Chris Burdess

Field Summary
protected StringcontentType
The content-type of this multipart object.
protected Partparent
The part containing this multipart, if known.
protected Vectorparts
Vector of body parts.
Constructor Summary
protected Multipart()
Constructor for an empty multipart of type "multipart/mixed".
Method Summary
voidaddBodyPart(BodyPart part)
Adds a body part to this multipart.
voidaddBodyPart(BodyPart part, int index)
Inserts a body part at the specified index.
BodyPartgetBodyPart(int index)
Get the specified body part.
StringgetContentType()
Returns the content-type of this multipart.
intgetCount()
Returns the number of enclosed body parts.
PartgetParent()
Returns the part containing this multipart, or null if not known.
booleanremoveBodyPart(BodyPart part)
Removes the specified body part from this multipart.
voidremoveBodyPart(int index)
Removes the body part at the specified index.
protected voidsetMultipartDataSource(MultipartDataSource mp)
Configures this multipart from the given data source.
voidsetParent(Part part)
Sets the parent of this multipart.
abstract voidwriteTo(OutputStream os)
Writes this multipart to the specified byte stream.

Field Detail

contentType

protected String contentType
The content-type of this multipart object. It defaults to "multipart/mixed".

parent

protected Part parent
The part containing this multipart, if known.

parts

protected Vector parts
Vector of body parts.

Constructor Detail

Multipart

protected Multipart()
Constructor for an empty multipart of type "multipart/mixed".

Method Detail

addBodyPart

public void addBodyPart(BodyPart part)
Adds a body part to this multipart.

Parameters: part the body part to be appended

Throws: IllegalWriteException if the underlying implementation does not support modification of existing values

addBodyPart

public void addBodyPart(BodyPart part, int index)
Inserts a body part at the specified index. The body parts in this container are numbered starting at 0.

Parameters: part the body part to be inserted index where to insert the part

Throws: IllegalWriteException if the underlying implementation does not support modification of existing values

getBodyPart

public BodyPart getBodyPart(int index)
Get the specified body part. The body parts in this container are numbered starting at 0.

Parameters: index the index of the desired body part

Throws: IndexOutOfBoundsException if the given index is out of range

getContentType

public String getContentType()
Returns the content-type of this multipart.

getCount

public int getCount()
Returns the number of enclosed body parts.

getParent

public Part getParent()
Returns the part containing this multipart, or null if not known.

removeBodyPart

public boolean removeBodyPart(BodyPart part)
Removes the specified body part from this multipart.

Parameters: part the body part to remove

Returns: true if a body part was removed, false otherwise

Throws: MessagingException if the multipart has not been configured IllegalWriteException if the underlying implementation does not support modification of existing values

removeBodyPart

public void removeBodyPart(int index)
Removes the body part at the specified index. The body parts in this container are numbered starting at 0.

Parameters: index index of the part to remove

Throws: IndexOutOfBoundsException if the given index is out of range IllegalWriteException if the underlying implementation does not support modification of existing values

setMultipartDataSource

protected void setMultipartDataSource(MultipartDataSource mp)
Configures this multipart from the given data source.

The method adds the body parts in the data source to this multipart, and sets the content-type.

Parameters: mp a multipart data source

setParent

public void setParent(Part part)
Sets the parent of this multipart.

writeTo

public abstract void writeTo(OutputStream os)
Writes this multipart to the specified byte stream.
© Copyright 2003, 2004 The Free Software Foundation, All rights reserved