FileDocCategorySizeDatePackage
IMAPResponse.javaAPI DocGlassfish v2 API4330Mon May 14 15:28:44 BST 2007com.sun.mail.imap.protocol

IMAPResponse

public class IMAPResponse extends Response
This class represents a response obtained from the input stream of an IMAP server.
version
1.5, 07/05/04
author
John Mani

Fields Summary
private String
key
private int
number
Constructors Summary
public IMAPResponse(Protocol c)

	super(c);

	// continue parsing if this is an untagged response
	if (isUnTagged() && !isOK() && !isNO() && !isBAD() && !isBYE()) {
	    key = readAtom();

	    // Is this response of the form "* <number> <command>"
	    try {
		number = Integer.parseInt(key);
		key = readAtom();
	    } catch (NumberFormatException ne) { }
	}
    
public IMAPResponse(IMAPResponse r)
Copy constructor.

	super((Response)r);
	key = r.key;
	number = r.number;
    
Methods Summary
public java.lang.StringgetKey()

	return key;
    
public intgetNumber()

	return number;
    
public booleankeyEquals(java.lang.String k)

	if (key != null && key.equalsIgnoreCase(k))
	    return true;
	else
	    return false;
    
public static com.sun.mail.imap.protocol.IMAPResponsereadResponse(com.sun.mail.iap.Protocol p)

	IMAPResponse r = new IMAPResponse(p);
	if (r.keyEquals("FETCH"))
	    r = new FetchResponse(r);
	return r;
    
public java.lang.String[]readSimpleList()
Read a list of space-separated "flag_extension" sequences and return the list as a array of Strings. An empty list is returned as null. This is an IMAP-ism, and perhaps this method should moved into the IMAP layer.

	skipSpaces();

	if (buffer[index] != '(") // not what we expected
	    return null;
	index++; // skip '('

	Vector v = new Vector();
	int start;
	for (start = index; buffer[index] != ')"; index++) {
	    if (buffer[index] == ' ") { // got one item
		v.addElement(ASCIIUtility.toString(buffer, start, index));
		start = index+1; // index gets incremented at the top
	    }
	}
	if (index > start) // get the last item
	    v.addElement(ASCIIUtility.toString(buffer, start, index));
	index++; // skip ')'
	
	int size = v.size();
	if (size > 0) {
	    String[] s = new String[size];
	    v.copyInto(s);
	    return s;
	} else  // empty list
	    return null;