|
Préférences
Moteurs de recherche
|
|||||||||||||||||||||||||||||||||||||||||||||||
JavaTM Platform, Enterprise Edition, v 5.0
javax.mail.internet
|
Field Summary | |
---|---|
protected DataSource |
ds
The DataSource supplying our InputStream. |
protected boolean |
parsed
Have we parsed the data from our InputStream yet? |
Fields inherited from class javax.mail.Multipart |
---|
contentType, parent, parts |
Constructor Summary | |
---|---|
MimeMultipart()
Default constructor. |
|
MimeMultipart(DataSource ds)
Constructs a MimeMultipart object and its bodyparts from the given DataSource. |
|
MimeMultipart(String subtype)
Construct a MimeMultipart object of the given subtype. |
Method Summary | |
---|---|
protected InternetHeaders |
createInternetHeaders(InputStream is)
Create and return an InternetHeaders object that loads the headers from the given InputStream. |
protected MimeBodyPart |
createMimeBodyPart(InputStream is)
Create and return a MimeBodyPart object to represent a body part parsed from the InputStream. |
protected MimeBodyPart |
createMimeBodyPart(InternetHeaders headers,
byte[] content)
Create and return a MimeBodyPart object to represent a body part parsed from the InputStream. |
BodyPart |
getBodyPart(int index)
Get the specified BodyPart. |
BodyPart |
getBodyPart(String CID)
Get the MimeBodyPart referred to by the given ContentID (CID). |
int |
getCount()
Return the number of enclosed BodyPart objects. |
String |
getPreamble()
Get the preamble text, if any, that appears before the first body part of this multipart. |
boolean |
isComplete()
Return true if the final boundary line for this multipart was seen. |
protected void |
parse()
Parse the InputStream from our DataSource, constructing the appropriate MimeBodyParts. |
void |
setPreamble(String preamble)
Set the preamble text to be included before the first body part. |
void |
setSubType(String subtype)
Set the subtype. |
protected void |
updateHeaders()
Update headers. |
void |
writeTo(OutputStream os)
Iterates through all the parts and outputs each Mime part separated by a boundary. |
Methods inherited from class javax.mail.Multipart |
---|
addBodyPart, addBodyPart, getContentType, getParent, removeBodyPart, removeBodyPart, setMultipartDataSource, setParent |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected DataSource ds
protected boolean parsed
Constructor Detail |
---|
public MimeMultipart()
contentType
field. MimeBodyParts may be added later.
public MimeMultipart(String subtype)
contentType
field. MimeBodyParts may be added later.
public MimeMultipart(DataSource ds) throws MessagingException
This constructor handles as a special case the situation where the given DataSource is a MultipartDataSource object. In this case, this method just invokes the superclass (i.e., Multipart) constructor that takes a MultipartDataSource object.
Otherwise, the DataSource is assumed to provide a MIME multipart
byte stream. The parsed
flag is set to false. When
the data for the body parts are needed, the parser extracts the
"boundary" parameter from the content type of this DataSource,
skips the 'preamble' and reads bytes till the terminating
boundary and creates MimeBodyParts for each part of the stream.
ds
- DataSource, can be a MultipartDataSource
MessagingException
Method Detail |
---|
public void setSubType(String subtype) throws MessagingException
subtype
- Subtype
MessagingException
public int getCount() throws MessagingException
MessagingException
Multipart.parts
public BodyPart getBodyPart(int index) throws MessagingException
getBodyPart
in class Multipart
index
- the index of the desired BodyPart
MessagingException
- if no such BodyPart existspublic BodyPart getBodyPart(String CID) throws MessagingException
CID
- the ContentID of the desired part
MessagingException
public boolean isComplete() throws MessagingException
MessagingException
public String getPreamble() throws MessagingException
MessagingException
public void setPreamble(String preamble) throws MessagingException
preamble
- the preamble text
MessagingException
protected void updateHeaders() throws MessagingException
updateHeaders
method on each of its
children BodyParts. Note that the boundary parameter is already set up when a new and empty MimeMultipart object is created.
This method is called when the saveChanges
method is invoked on the Message object containing this
Multipart. This is typically done as part of the Message
send process, however note that a client is free to call
it any number of times. So if the header updating process is
expensive for a specific MimeMultipart subclass, then it
might itself want to track whether its internal state actually
did change, and do the header updating only if necessary.
MessagingException
public void writeTo(OutputStream os) throws IOException, MessagingException
IOException
- if an IO related exception occurs
MessagingException
protected void parse() throws MessagingException
parsed
flag is
set to true, and if true on entry nothing is done. This
method is called by all other methods that need data for
the body parts, to make sure the data has been parsed.
MessagingException
protected InternetHeaders createInternetHeaders(InputStream is) throws MessagingException
is
- the InputStream to read the headers from
MessagingException
protected MimeBodyPart createMimeBodyPart(InternetHeaders headers, byte[] content) throws MessagingException
headers
- the headers for the body partcontent
- the content of the body part
MessagingException
protected MimeBodyPart createMimeBodyPart(InputStream is) throws MessagingException
is
- InputStream containing the body part
MessagingException