javax.mail.internet

Class MimeMultipart

public class MimeMultipart extends Multipart

A MIME multipart container.

The default multipart subtype is "mixed". However, an application can construct a MIME multipart object of any subtype using the MimeMultipart(String) constructor.

Version: 1.3

Author: Chris Burdess

Field Summary
protected DataSourceds
The data source supplying the multipart data.
protected booleanparsed
Indicates whether the data from the input stream has been parsed yet.
Constructor Summary
MimeMultipart()
Constructor for an empty MIME multipart of type "multipart/mixed".
MimeMultipart(String subtype)
Constructor for an empty MIME multipart of the given subtype.
MimeMultipart(DataSource ds)
Constructor with a given data source.
Method Summary
protected InternetHeaderscreateInternetHeaders(InputStream is)
Creates headers from the specified input stream.
protected MimeBodyPartcreateMimeBodyPart(InternetHeaders headers, byte[] content)
Creates a MIME body part object from the given headers and byte content.
protected MimeBodyPartcreateMimeBodyPart(InputStream is)
Creates a MIME body part from the specified input stream.
BodyPartgetBodyPart(int index)
Returns the specified body part.
BodyPartgetBodyPart(String CID)
Returns the body part identified by the given Content-ID (CID).
intgetCount()
Returns the number of component body parts.
protected voidparse()
Parses the body parts from this multipart's data source.
voidsetSubType(String subtype)
Sets the subtype.
protected voidupdateHeaders()
Updates the headers of this part to be consistent with its content.
voidwriteTo(OutputStream os)
Writes this multipart to the specified output stream.

Field Detail

ds

protected DataSource ds
The data source supplying the multipart data.

parsed

protected boolean parsed
Indicates whether the data from the input stream has been parsed yet.

Constructor Detail

MimeMultipart

public MimeMultipart()
Constructor for an empty MIME multipart of type "multipart/mixed".

MimeMultipart

public MimeMultipart(String subtype)
Constructor for an empty MIME multipart of the given subtype.

MimeMultipart

public MimeMultipart(DataSource ds)
Constructor with a given data source.

Parameters: ds the data source, which can be a MultipartDataSource

Method Detail

createInternetHeaders

protected InternetHeaders createInternetHeaders(InputStream is)
Creates headers from the specified input stream.

Parameters: is the input stream to read the headers from

createMimeBodyPart

protected MimeBodyPart createMimeBodyPart(InternetHeaders headers, byte[] content)
Creates a MIME body part object from the given headers and byte content.

Parameters: headers the part headers content the part content

createMimeBodyPart

protected MimeBodyPart createMimeBodyPart(InputStream is)
Creates a MIME body part from the specified input stream.

Parameters: is the input stream to parse the part from

getBodyPart

public BodyPart getBodyPart(int index)
Returns the specified body part. Body parts are numbered starting at 0.

Parameters: index the body part index

Throws: MessagingException if no such part exists

getBodyPart

public BodyPart getBodyPart(String CID)
Returns the body part identified by the given Content-ID (CID).

Parameters: CID the Content-ID of the desired part

getCount

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

parse

protected void parse()
Parses the body parts from this multipart's data source.

setSubType

public void setSubType(String subtype)
Sets the subtype.

updateHeaders

protected void updateHeaders()
Updates the headers of this part to be consistent with its content.

writeTo

public void writeTo(OutputStream os)
Writes this multipart to the specified output stream. This method iterates through all the component parts, outputting each part separated by the Content-Type boundary parameter.
© Copyright 2003, 2004 The Free Software Foundation, All rights reserved