Package javax.mail.internet
Class MimeMultipart
- java.lang.Object
-
- javax.mail.Multipart
-
- javax.mail.internet.MimeMultipart
-
- Direct Known 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
Fields Modifier and Type Field Description protected javax.activation.DataSourcedsThe data source supplying the multipart data.protected booleanparsedIndicates whether the data from the input stream has been parsed yet.-
Fields inherited from class javax.mail.Multipart
contentType, parent, parts
-
-
Constructor Summary
Constructors Constructor Description MimeMultipart()Constructor for an empty MIME multipart of type "multipart/mixed".MimeMultipart(java.lang.String subtype)Constructor for an empty MIME multipart of the given subtype.MimeMultipart(javax.activation.DataSource ds)Constructor with a given data source.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected InternetHeaderscreateInternetHeaders(java.io.InputStream is)Creates headers from the specified input stream.protected MimeBodyPartcreateMimeBodyPart(java.io.InputStream is)Creates a MIME body part from the specified input stream.protected MimeBodyPartcreateMimeBodyPart(InternetHeaders headers, byte[] content)Creates a MIME body part object from the given headers and byte content.BodyPartgetBodyPart(int index)Returns the specified body part.BodyPartgetBodyPart(java.lang.String CID)Returns the body part identified by the given Content-ID (CID).intgetCount()Returns the number of component body parts.java.lang.StringgetPreamble()Returns the preamble text (if any) before the first boundary line in this multipart's body.booleanisComplete()Indicates whether the final boundary line for this multipart has been parsed.protected voidparse()Parses the body parts from this multipart's data source.voidsetPreamble(java.lang.String preamble)Sets the preamble text to be emitted before the first boundary line.voidsetSubType(java.lang.String subtype)Sets the subtype.protected voidupdateHeaders()Updates the headers of this part to be consistent with its content.voidwriteTo(java.io.OutputStream os)Writes this multipart to the specified output stream.-
Methods inherited from class javax.mail.Multipart
addBodyPart, addBodyPart, getContentType, getParent, removeBodyPart, removeBodyPart, setMultipartDataSource, setParent
-
-
-
-
Constructor Detail
-
MimeMultipart
public MimeMultipart()
Constructor for an empty MIME multipart of type "multipart/mixed".
-
MimeMultipart
public MimeMultipart(java.lang.String subtype)
Constructor for an empty MIME multipart of the given subtype.
-
MimeMultipart
public MimeMultipart(javax.activation.DataSource ds) throws MessagingExceptionConstructor with a given data source.- Parameters:
ds- the data source, which can be a MultipartDataSource- Throws:
MessagingException
-
-
Method Detail
-
setSubType
public void setSubType(java.lang.String subtype) throws MessagingExceptionSets the subtype.- Throws:
MessagingException
-
getCount
public int getCount() throws MessagingExceptionReturns the number of component body parts.- Overrides:
getCountin classMultipart- Throws:
MessagingException
-
getBodyPart
public BodyPart getBodyPart(int index) throws MessagingException
Returns the specified body part. Body parts are numbered starting at 0.- Overrides:
getBodyPartin classMultipart- Parameters:
index- the body part index- Throws:
MessagingException- if no such part exists
-
getBodyPart
public BodyPart getBodyPart(java.lang.String CID) throws MessagingException
Returns the body part identified by the given Content-ID (CID).- Parameters:
CID- the Content-ID of the desired part- Throws:
MessagingException
-
updateHeaders
protected void updateHeaders() throws MessagingExceptionUpdates the headers of this part to be consistent with its content.- Throws:
MessagingException
-
writeTo
public void writeTo(java.io.OutputStream os) throws java.io.IOException, MessagingExceptionWrites 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.- Specified by:
writeToin classMultipart- Throws:
java.io.IOExceptionMessagingException
-
parse
protected void parse() throws MessagingExceptionParses the body parts from this multipart's data source.- Throws:
MessagingException
-
isComplete
public boolean isComplete() throws MessagingExceptionIndicates whether the final boundary line for this multipart has been parsed.- Throws:
MessagingException- Since:
- JavaMail 1.4
-
getPreamble
public java.lang.String getPreamble() throws MessagingExceptionReturns the preamble text (if any) before the first boundary line in this multipart's body.- Throws:
MessagingException- Since:
- JavaMail 1.4
-
setPreamble
public void setPreamble(java.lang.String preamble) throws MessagingExceptionSets the preamble text to be emitted before the first boundary line.- Parameters:
preamble- the preamble text- Throws:
MessagingException- Since:
- JavaMail 1.4
-
createInternetHeaders
protected InternetHeaders createInternetHeaders(java.io.InputStream is) throws MessagingException
Creates headers from the specified input stream.- Parameters:
is- the input stream to read the headers from- Throws:
MessagingException
-
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 headerscontent- the part content- Throws:
MessagingException
-
createMimeBodyPart
protected MimeBodyPart createMimeBodyPart(java.io.InputStream is) throws MessagingException
Creates a MIME body part from the specified input stream.- Parameters:
is- the input stream to parse the part from- Throws:
MessagingException
-
-