javax.mail

Class Multipart

public abstract class Multipart extends Object

A container for multiple BodyParts.
Field Summary
protected StringcontentType
The content type of this multipart object; defaults to "multipart/mixed"
protected Partparent
The Part that contains this multipart.
protected Vectorparts
Vector of sub-parts.
Constructor Summary
protected Multipart()
Method Summary
voidaddBodyPart(BodyPart part)
Add a part to the end of the list.
voidaddBodyPart(BodyPart part, int pos)
Insert a part into the list at a designated point; all subsequent parts move down
BodyPartgetBodyPart(int index)
Get the specified part; numbering starts at zero.
StringgetContentType()
Return the content type.
intgetCount()
Return the number of enclosed parts
PartgetParent()
Return the Part containing this Multipart object or null if unknown.
booleanremoveBodyPart(BodyPart part)
Remove the supplied part from the list.
voidremoveBodyPart(int index)
Remove the specified part; all others move down one
protected voidsetMultipartDataSource(MultipartDataSource mds)
Initialize this multipart object from the supplied data source.
voidsetParent(Part part)
Set the parent of this Multipart object
abstract voidwriteTo(OutputStream out)
Encode and write this multipart to the supplied OutputStream; the encoding used is determined by the implementation.

Field Detail

contentType

protected String contentType
The content type of this multipart object; defaults to "multipart/mixed"

parent

protected Part parent
The Part that contains this multipart.

parts

protected Vector parts
Vector of sub-parts.

Constructor Detail

Multipart

protected Multipart()

Method Detail

addBodyPart

public void addBodyPart(BodyPart part)
Add a part to the end of the list.

Parameters: part the part to add

Throws: MessagingException

addBodyPart

public void addBodyPart(BodyPart part, int pos)
Insert a part into the list at a designated point; all subsequent parts move down

Parameters: part the part to add pos the index of the new part

Throws: MessagingException

getBodyPart

public BodyPart getBodyPart(int index)
Get the specified part; numbering starts at zero.

Parameters: index the part to get

Returns: the part

Throws: MessagingException

getContentType

public String getContentType()
Return the content type.

Returns: the content type

getCount

public int getCount()
Return the number of enclosed parts

Returns: the number of parts

Throws: MessagingException

getParent

public Part getParent()
Return the Part containing this Multipart object or null if unknown.

Returns: this Multipart's parent

removeBodyPart

public boolean removeBodyPart(BodyPart part)
Remove the supplied part from the list.

Parameters: part the part to remove

Returns: true if the part was removed

Throws: MessagingException

removeBodyPart

public void removeBodyPart(int index)
Remove the specified part; all others move down one

Parameters: index the part to remove

Throws: MessagingException

setMultipartDataSource

protected void setMultipartDataSource(MultipartDataSource mds)
Initialize this multipart object from the supplied data source. This adds any BodyParts into this object and initializes the content type.

Parameters: mds the data source

Throws: MessagingException

setParent

public void setParent(Part part)
Set the parent of this Multipart object

Parameters: part this object's parent

writeTo

public abstract void writeTo(OutputStream out)
Encode and write this multipart to the supplied OutputStream; the encoding used is determined by the implementation.

Parameters: out the stream to write to

Throws: IOException MessagingException