FileDocCategorySizeDatePackage
DeliveryStatus.javaAPI DocGlassfish v2 API6396Mon May 14 15:28:42 BST 2007com.sun.mail.dsn

DeliveryStatus

public class DeliveryStatus extends Object
A message/delivery-status message content, as defined in RFC 3464.

Fields Summary
private static boolean
debug
protected InternetHeaders
messageDSN
The DSN fields for the message.
protected InternetHeaders[]
recipientDSN
The DSN fields for each recipient.
Constructors Summary
public DeliveryStatus()
Construct a delivery status notification with no content.

	messageDSN = new InternetHeaders();
	recipientDSN = new InternetHeaders[0];
    
public DeliveryStatus(InputStream is)
Construct a delivery status notification by parsing the supplied input stream.

	messageDSN = new InternetHeaders(is);
	if (debug)
	    System.out.println("DSN: got messageDSN");
	Vector v = new Vector();
	try {
	    while (is.available() > 0) {
		InternetHeaders h = new InternetHeaders(is);
		if (debug)
		    System.out.println("DSN: got recipientDSN");
		v.addElement(h);
	    }
	} catch (EOFException ex) {
	    if (debug)
		System.out.println("DSN: got EOFException");
	}
	if (debug)
	    System.out.println("DSN: recipientDSN size " + v.size());
	recipientDSN = new InternetHeaders[v.size()];
	v.copyInto(recipientDSN);
    
Methods Summary
public voidaddRecipientDSN(javax.mail.internet.InternetHeaders h)
Add deliver status notification information for another recipient.

	InternetHeaders[] rh = new InternetHeaders[recipientDSN.length + 1];
	System.arraycopy(recipientDSN, 0, rh, 0, recipientDSN.length);
	recipientDSN = rh;
	recipientDSN[recipientDSN.length - 1] = h;
    
public javax.mail.internet.InternetHeadersgetMessageDSN()
Return all the per-message fields in the delivery status notification. The fields are defined as:
per-message-fields =
[ original-envelope-id-field CRLF ]
reporting-mta-field CRLF
[ dsn-gateway-field CRLF ]
[ received-from-mta-field CRLF ]
[ arrival-date-field CRLF ]
*( extension-field CRLF )

	return messageDSN;
    
public javax.mail.internet.InternetHeadersgetRecipientDSN(int n)
Return the delivery status notification information for the specified recipient.

	return recipientDSN[n];
    
public intgetRecipientDSNCount()
Return the number of recipients for which we have per-recipient delivery status notification information.

	return recipientDSN.length;
    
public voidsetMessageDSN(javax.mail.internet.InternetHeaders messageDSN)
Set the per-message fields in the delivery status notification.

	this.messageDSN = messageDSN;
    
public java.lang.StringtoString()

	return "DeliveryStatus: Reporting-MTA=" +
	    messageDSN.getHeader("Reporting-MTA", null) + ", #Recipients=" +
	    recipientDSN.length;
    
private static voidwriteInternetHeaders(javax.mail.internet.InternetHeaders h, com.sun.mail.util.LineOutputStream los)

	Enumeration e = h.getAllHeaderLines();
	try {
	    while (e.hasMoreElements())
		los.writeln((String)e.nextElement());
	} catch (MessagingException mex) {
	    Exception ex = mex.getNextException();
	    if (ex instanceof IOException)
		throw (IOException)ex;
	    else
		throw new IOException("Exception writing headers: " + mex);
	}
    
public voidwriteTo(java.io.OutputStream os)

	// see if we already have a LOS
	LineOutputStream los = null;
	if (os instanceof LineOutputStream) {
	    los = (LineOutputStream) os;
	} else {
	    los = new LineOutputStream(os);
	}

	writeInternetHeaders(messageDSN, los);
	los.writeln();
	for (int i = 0; i < recipientDSN.length; i++) {
	    writeInternetHeaders(recipientDSN[i], los);
	    los.writeln();
	}