com.sun.mail.dsn

Class MultipartReport


public class MultipartReport
extends MimeMultipart

A multipart/report message content, as defined in RFC 3462. A multipart/report content is a container for mail reports of any kind, and is most often used to return a delivery status report. This class only supports that most common usage.

A MultipartReport object is a special type of MimeMultipart object with a restricted set of body parts. A MultipartReport object contains:

Many of the normal MimeMultipart operations are restricted to ensure that the MultipartReport object always follows this structure.

Field Summary

protected boolean
constructed

Constructor Summary

MultipartReport()
Construct a multipart/report object with no content.
MultipartReport(DataSource ds)
Constructs a MultipartReport object and its bodyparts from the given DataSource.
MultipartReport(String text, DeliveryStatus status)
Construct a multipart/report object with the specified plain text and delivery status to be returned to the user.
MultipartReport(String text, DeliveryStatus status, InternetHeaders hdr)
Construct a multipart/report object with the specified plain text, delivery status, and headers from the original message to be returned to the user.
MultipartReport(String text, DeliveryStatus status, MimeMessage msg)
Construct a multipart/report object with the specified plain text, delivery status, and original message to be returned to the user.

Method Summary

void
addBodyPart(BodyPart part)
Adds a Part to the multipart.
void
addBodyPart(BodyPart part, int index)
Adds a BodyPart at position index.
DeliveryStatus
getDeliveryStatus()
Get the delivery status associated with this multipart/report.
MimeMessage
getReturnedMessage()
Get the original message that is being returned along with this multipart/report.
String
getText()
Get the plain text to be presented to the user, if there is any.
MimeBodyPart
getTextBodyPart()
Return the body part containing the message to be presented to the user, usually just a text/plain part.
boolean
removeBodyPart(BodyPart part)
Remove the specified part from the multipart message.
void
removeBodyPart(int index)
Remove the part at specified location (starting from 0).
void
setDeliveryStatus(DeliveryStatus status)
Set the delivery status associated with this multipart/report.
void
setReturnedMessage(MimeMessage msg)
Set the original message to be returned as part of the multipart/report.
void
setSubType(String subtype)
Set the subtype.
void
setText(String text)
Set the message to be presented to the user as just a text/plain part containing the specified text.
void
setTextBodyPart(MimeBodyPart mbp)
Set the body part containing the text to be presented to the user.

Field Details

constructed

protected boolean constructed

Constructor Details

MultipartReport

public MultipartReport()
            throws MessagingException
Construct a multipart/report object with no content.

MultipartReport

public MultipartReport(DataSource ds)
            throws MessagingException
Constructs a MultipartReport object and its bodyparts from the given DataSource.

Parameters:
ds - DataSource, can be a MultipartDataSource

MultipartReport

public MultipartReport(String text,
                       DeliveryStatus status)
            throws MessagingException
Construct a multipart/report object with the specified plain text and delivery status to be returned to the user.

MultipartReport

public MultipartReport(String text,
                       DeliveryStatus status,
                       InternetHeaders hdr)
            throws MessagingException
Construct a multipart/report object with the specified plain text, delivery status, and headers from the original message to be returned to the user.

MultipartReport

public MultipartReport(String text,
                       DeliveryStatus status,
                       MimeMessage msg)
            throws MessagingException
Construct a multipart/report object with the specified plain text, delivery status, and original message to be returned to the user.

Method Details

addBodyPart

public void addBodyPart(BodyPart part)
            throws MessagingException
Adds a Part to the multipart. Not allowed on a multipart/report object.
Parameters:
part - The Part to be appended

addBodyPart

public void addBodyPart(BodyPart part,
                        int index)
            throws MessagingException
Adds a BodyPart at position index. Not allowed on a multipart/report object.
Parameters:
part - The BodyPart to be inserted
index - Location where to insert the part

getDeliveryStatus

public DeliveryStatus getDeliveryStatus()
            throws MessagingException
Get the delivery status associated with this multipart/report.

getReturnedMessage

public MimeMessage getReturnedMessage()
            throws MessagingException
Get the original message that is being returned along with this multipart/report. If no original message is included, null is returned. In some cases only the headers of the original message will be returned as an object of type MessageHeaders.

getText

public String getText()
            throws MessagingException

getTextBodyPart

public MimeBodyPart getTextBodyPart()
            throws MessagingException
Return the body part containing the message to be presented to the user, usually just a text/plain part.

removeBodyPart

public boolean removeBodyPart(BodyPart part)
            throws MessagingException
Remove the specified part from the multipart message. Not allowed on a multipart/report object.
Parameters:
part - The part to remove

removeBodyPart

public void removeBodyPart(int index)
            throws MessagingException
Remove the part at specified location (starting from 0). Not allowed on a multipart/report object.
Parameters:
index - Index of the part to remove

setDeliveryStatus

public void setDeliveryStatus(DeliveryStatus status)
            throws MessagingException
Set the delivery status associated with this multipart/report.

setReturnedMessage

public void setReturnedMessage(MimeMessage msg)
            throws MessagingException
Set the original message to be returned as part of the multipart/report. If msg is null, any previously set returned message or headers is removed.

setSubType

public void setSubType(String subtype)
            throws MessagingException
Set the subtype. Throws MessagingException.
Parameters:
subtype - Subtype

setText

public void setText(String text)
            throws MessagingException
Set the message to be presented to the user as just a text/plain part containing the specified text.

setTextBodyPart

public void setTextBodyPart(MimeBodyPart mbp)
            throws MessagingException
Set the body part containing the text to be presented to the user. Usually this a text/plain part, but it might also be a text/html part or a multipart/alternative part containing text/plain and text/html parts. Any type is allowed here but these types are most common.