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

Namespaces

public class Namespaces extends Object
This class and its inner class represent the response to the NAMESPACE command.
see
RFC2342
author
Bill Shannon

Fields Summary
public Namespace[]
personal
The personal namespaces. May be null.
public Namespace[]
otherUsers
The namespaces for other users. May be null.
public Namespace[]
shared
The shared namespace. May be null.
Constructors Summary
public Namespaces(Response r)
Parse out all the namespaces.

	personal = getNamespaces(r);
	otherUsers = getNamespaces(r);
	shared = getNamespaces(r);
    
Methods Summary
private com.sun.mail.imap.protocol.Namespaces$Namespace[]getNamespaces(com.sun.mail.iap.Response r)
Parse out one of the three sets of namespaces.

	r.skipSpaces();
	//    Namespace = nil / "(" 1*( Namespace_Element) ")"
	if (r.peekByte() == '(") {
	    Vector v = new Vector();
	    r.readByte();
	    do {
		Namespace ns = new Namespace(r);
		v.addElement(ns);
	    } while (r.peekByte() != ')");
	    r.readByte();
	    Namespace[] nsa = new Namespace[v.size()];
	    v.copyInto(nsa);
	    return nsa;
	} else {
	    String s = r.readAtom();
	    if (s == null)
		throw new ProtocolException("Expected NIL, got null");
	    if (!s.equalsIgnoreCase("NIL"))
		throw new ProtocolException("Expected NIL, got " + s);
	    return null;
	}