/** * If the response contains a CAPABILITY response code, extract * it and save the capabilities. * * @param r the response */ protected void setCapabilities(Response r) { byte b; while ((b = r.readByte()) > 0 && b != (byte)'[') ; if (b == 0) return; String s; s = r.readAtom(); if (!s.equalsIgnoreCase("CAPABILITY")) return; capabilities = new HashMap<String, String>(10); authmechs = new ArrayList<String>(5); parseCapabilities(r); }
/** * If the response contains a CAPABILITY response code, extract * it and save the capabilities. * * @param r the response */ protected void setCapabilities(Response r) { byte b; while ((b = r.readByte()) > 0 && b != (byte)'[') ; if (b == 0) return; String s; s = r.readAtom(); if (!s.equalsIgnoreCase("CAPABILITY")) return; capabilities = new HashMap<>(10); authmechs = new ArrayList<>(5); parseCapabilities(r); }
/** * Parse out one of the three sets of namespaces. */ private Namespace[] getNamespaces(Response r) throws ProtocolException { r.skipSpaces(); // Namespace = nil / "(" 1*( Namespace_Element) ")" if (r.peekByte() == '(') { List<Namespace> v = new ArrayList<Namespace>(); r.readByte(); do { Namespace ns = new Namespace(r); v.add(ns); } while (r.peekByte() != ')'); r.readByte(); return v.toArray(new Namespace[v.size()]); } 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; } } }
/** * Parse a QUOTA response. */ private Quota parseQuota(Response r) throws ParsingException { // quota_response ::= "QUOTA" SP astring SP quota_list String quotaRoot = r.readAtomString(); // quotaroot ::= astring Quota q = new Quota(quotaRoot); r.skipSpaces(); // quota_list ::= "(" #quota_resource ")" if (r.readByte() != '(') throw new ParsingException("parse error in QUOTA"); List<Quota.Resource> v = new ArrayList<Quota.Resource>(); while (r.peekByte() != ')') { // quota_resource ::= atom SP number SP number String name = r.readAtom(); if (name != null) { long usage = r.readLong(); long limit = r.readLong(); Quota.Resource res = new Quota.Resource(name, usage, limit); v.add(res); } } r.readByte(); q.resources = v.toArray(new Quota.Resource[v.size()]); return q; }
byte b = r.readByte(); if (b == '(') {
IMAPAddress(Response r) throws ParsingException { if (r.readByte() != '(') throw new ParsingException("ADDRESS parse error");
if (r.readByte() != '(') throw new ProtocolException( "Missing '(' at start of Namespace"); r.readByte(); delimiter = (char)r.readByte(); if (delimiter == '\\') delimiter = (char)r.readByte(); if (r.readByte() != '"') throw new ProtocolException( "Missing '\"' at end of QUOTED_CHAR"); r.readStringList(); if (r.readByte() != ')') throw new ProtocolException("Missing ')' at end of Namespace");
private void parseBodyExtension(Response r) throws ParsingException { r.skipSpaces(); byte b = r.peekByte(); if (b == '(') { r.skip(1); // skip '(' do { parseBodyExtension(r); } while (r.readByte() != ')'); } else if (Character.isDigit((char)b)) // number r.readNumber(); else // nstring r.readString(); } }
/** * If the response contains an APPENDUID response code, extract * it and return an AppendUID object with the information. */ private AppendUID getAppendUID(Response r) { if (!r.isOK()) return null; byte b; while ((b = r.readByte()) > 0 && b != (byte)'[') ; if (b == 0) return null; String s; s = r.readAtom(); if (!s.equalsIgnoreCase("APPENDUID")) return null; long uidvalidity = r.readLong(); long uid = r.readLong(); return new AppendUID(uidvalidity, uid); }
/** * If the response contains an APPENDUID response code, extract * it and return an AppendUID object with the information. */ private AppendUID getAppendUID(Response r) { if (!r.isOK()) return null; byte b; while ((b = r.readByte()) > 0 && b != (byte)'[') ; if (b == 0) return null; String s; s = r.readAtom(); if (!s.equalsIgnoreCase("APPENDUID")) return null; long uidvalidity = r.readLong(); long uid = r.readLong(); return new AppendUID(uidvalidity, uid); }
byte b = r.readByte(); if (b == '(') {
/** * Parse a QUOTA response. */ private Quota parseQuota(Response r) throws ParsingException { // quota_response ::= "QUOTA" SP astring SP quota_list String quotaRoot = r.readAtomString(); // quotaroot ::= astring Quota q = new Quota(quotaRoot); r.skipSpaces(); // quota_list ::= "(" #quota_resource ")" if (r.readByte() != '(') throw new ParsingException("parse error in QUOTA"); List<Quota.Resource> v = new ArrayList<>(); while (!r.isNextNonSpace(')')) { // quota_resource ::= atom SP number SP number String name = r.readAtom(); if (name != null) { long usage = r.readLong(); long limit = r.readLong(); Quota.Resource res = new Quota.Resource(name, usage, limit); v.add(res); } } q.resources = v.toArray(new Quota.Resource[v.size()]); return q; }
byte b = r.readByte(); if (b == '(') { list = new ParameterList();
continue; byte b; while ((b = r.readByte()) > 0 && b != (byte)'[')
continue; byte b; while ((b = r.readByte()) > 0 && b != (byte)'[')