javax.mail.internet

Class MimeMultipart

Known Direct Subclasses:
IMAPMultipart

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.4
Author:
Chris Burdess

Field Summary

protected DataSource
ds
The data source supplying the multipart data.
protected boolean
parsed
Indicates whether the data from the input stream has been parsed yet.

Fields inherited from class javax.mail.Multipart

contentType, parent, parts

Constructor Summary

MimeMultipart()
Constructor for an empty MIME multipart of type "multipart/mixed".
MimeMultipart(DataSource ds)
Constructor with a given data source.
MimeMultipart(String subtype)
Constructor for an empty MIME multipart of the given subtype.

Method Summary

protected InternetHeaders
createInternetHeaders(InputStream is)
Creates headers from the specified input stream.
protected MimeBodyPart
createMimeBodyPart(InputStream is)
Creates a MIME body part from the specified input stream.
protected MimeBodyPart
createMimeBodyPart(InternetHeaders headers, byte[] content)
Creates a MIME body part object from the given headers and byte content.
BodyPart
getBodyPart(String CID)
Returns the body part identified by the given Content-ID (CID).
BodyPart
getBodyPart(int index)
Returns the specified body part.
int
getCount()
Returns the number of component body parts.
String
getPreamble()
Returns the preamble text (if any) before the first boundary line in this multipart's body.
boolean
isComplete()
Indicates whether the final boundary line for this multipart has been parsed.
protected void
parse()
Parses the body parts from this multipart's data source.
void
setPreamble(String preamble)
Sets the preamble text to be emitted before the first boundary line.
void
setSubType(String subtype)
Sets the subtype.
protected void
updateHeaders()
Updates the headers of this part to be consistent with its content.
void
writeTo(OutputStream os)
Writes this multipart to the specified output stream.

Methods inherited from class javax.mail.Multipart

addBodyPart, addBodyPart, getBodyPart, getContentType, getCount, getParent, removeBodyPart, removeBodyPart, setMultipartDataSource, setParent, writeTo

Field Details

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 Details

MimeMultipart

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

MimeMultipart

public MimeMultipart(DataSource ds)
            throws MessagingException
Constructor with a given data source.
Parameters:
ds - the data source, which can be a MultipartDataSource

MimeMultipart

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

Method Details

createInternetHeaders

protected InternetHeaders createInternetHeaders(InputStream is)
            throws MessagingException
Creates headers from the specified input stream.
Parameters:
is - the input stream to read the headers from

createMimeBodyPart

protected MimeBodyPart createMimeBodyPart(InputStream is)
            throws MessagingException
Creates a MIME body part from the specified input stream.
Parameters:
is - the input stream to parse the part from

createMimeBodyPart

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

getBodyPart

public BodyPart getBodyPart(String CID)
            throws MessagingException
Returns the body part identified by the given Content-ID (CID).
Parameters:
CID - the Content-ID of the desired part

getBodyPart

public BodyPart getBodyPart(int index)
            throws MessagingException
Returns the specified body part. Body parts are numbered starting at 0.
Overrides:
getBodyPart in interface Multipart
Parameters:
index - the body part index
Throws:
MessagingException - if no such part exists

getCount

public int getCount()
            throws MessagingException
Returns the number of component body parts.
Overrides:
getCount in interface Multipart

getPreamble

public String getPreamble()
            throws MessagingException
Returns the preamble text (if any) before the first boundary line in this multipart's body.
Since:
JavaMail 1.4

isComplete

public boolean isComplete()
            throws MessagingException
Indicates whether the final boundary line for this multipart has been parsed.
Since:
JavaMail 1.4

parse

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

setPreamble

public void setPreamble(String preamble)
            throws MessagingException
Sets the preamble text to be emitted before the first boundary line.
Parameters:
preamble - the preamble text
Since:
JavaMail 1.4

setSubType

public void setSubType(String subtype)
            throws MessagingException
Sets the subtype.

updateHeaders

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

writeTo

public void writeTo(OutputStream os)
            throws IOException,
                   MessagingException
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.
Overrides:
writeTo in interface Multipart

© Copyright 2003, 2004 The Free Software Foundation, All rights reserved