private boolean parseCommandContinuationRequest() throws IOException { expect('+'); return true; }
private void skipIfSpace() throws IOException { if (inputStream.peek() == ' ') { expect(' '); } }
private String readStringUntilEndOfLine() throws IOException { String rest = readStringUntil('\r'); expect('\n'); return rest; }
private String parseQuoted() throws IOException { expect('"'); StringBuilder sb = new StringBuilder(); int ch; boolean escape = false; while ((ch = inputStream.read()) != -1) { if (!escape && ch == '\\') { // Found the escape character escape = true; } else if (!escape && ch == '"') { return sb.toString(); } else { sb.append((char) ch); escape = false; } } throw new IOException("parseQuoted(): end of stream reached"); }
return parseList(parent, '[', ']'); } else if (ch == ')') { expect(')'); return ")"; } else if (ch == ']') { expect(']'); return "]"; } else if (ch == '"') { return parseLiteral(); } else if (ch == ' ') { expect(' '); } else if (ch == '\r') { expect('\r'); expect('\n'); return null; } else if (ch == '\n') { expect('\n'); return null; } else if (ch == '\t') { expect('\t'); } else { return parseBareString(true);
private ImapList parseList(ImapList parent, char start, char end) throws IOException { expect(start); ImapList list = new ImapList(); parent.add(list); String endString = String.valueOf(end); Object token; while (true) { token = parseToken(list); if (token == null) { return null; } else if (token.equals(endString)) { break; } else if (!(token instanceof ImapList)) { list.add(token); } } return list; }