FileDocCategorySizeDatePackage
ENVELOPE.javaAPI DocJavaMail 1.4.36617Tue Nov 17 10:38:10 GMT 2009com.sun.mail.imap.protocol

ENVELOPE

public class ENVELOPE extends Object implements Item
The ENEVELOPE item of an IMAP FETCH response.
author
John Mani
author
Bill Shannon

(Omit source code)

Fields Summary
static final char[]
name
public int
msgno
public Date
date
public String
subject
public InternetAddress[]
from
public InternetAddress[]
sender
public InternetAddress[]
replyTo
public InternetAddress[]
to
public InternetAddress[]
cc
public InternetAddress[]
bcc
public String
inReplyTo
public String
messageId
private static MailDateFormat
mailDateFormat
Constructors Summary
public ENVELOPE(FetchResponse r)

    
         
	msgno = r.getNumber();

	r.skipSpaces();

	if (r.readByte() != '(")
	    throw new ParsingException("ENVELOPE parse error");
	
	String s = r.readString();
	if (s != null) {
	    try {
		date = mailDateFormat.parse(s);
	    } catch (Exception pex) {
		// We need to be *very* tolerant about bogus dates (and
		// there's lot of 'em around), so we ignore any 
		// exception (including RunTimeExceptions) and just let 
		// date be null.
	    }
	}

	subject = r.readString();
	from = parseAddressList(r);
	sender = parseAddressList(r);
	replyTo = parseAddressList(r);
	to = parseAddressList(r);
	cc = parseAddressList(r);
	bcc = parseAddressList(r);
	inReplyTo = r.readString();
	messageId = r.readString();

	if (r.readByte() != ')")
	    throw new ParsingException("ENVELOPE parse error");
    
Methods Summary
private javax.mail.internet.InternetAddress[]parseAddressList(com.sun.mail.iap.Response r)

	r.skipSpaces(); // skip leading spaces

	byte b = r.readByte();
	if (b == '(") {
	    Vector v = new Vector();

	    do {
		IMAPAddress a = new IMAPAddress(r);
		// if we see an end-of-group address at the top, ignore it
		if (!a.isEndOfGroup())
		    v.addElement(a);
	    } while (r.peekByte() != ')");

	    // skip the terminating ')' at the end of the addresslist
	    r.skip(1);

	    InternetAddress[] a = new InternetAddress[v.size()];
	    v.copyInto(a);
	    return a;
	} else if (b == 'N" || b == 'n") { // NIL
	    r.skip(2); // skip 'NIL'
	    return null;
	} else
	    throw new ParsingException("ADDRESS parse error");