private void skipIfSpace() throws IOException { if (inputStream.peek() == ' ') { expect(' '); } }
private String parseBareString(boolean allowBrackets) throws IOException { StringBuilder sb = new StringBuilder(); int ch; while (true) { ch = inputStream.peek(); if (ch == -1) { throw new IOException("parseBareString(): end of stream reached"); } if (ch == '(' || ch == ')' || (allowBrackets && (ch == '[' || ch == ']')) || ch == '{' || ch == ' ' || ch == '"' || (ch >= 0x00 && ch <= 0x1f) || ch == 0x7f) { if (sb.length() == 0) { throw new IOException(String.format("parseBareString(): (%04x %c)", ch, ch)); } return sb.toString(); } else { sb.append((char) inputStream.read()); } } }
private String parseQuotedOrNil() throws IOException { int peek = inputStream.peek(); if (peek == '"') { return parseQuoted(); } else { parseNil(); return null; } }
private String parseString() throws IOException { int ch = inputStream.peek(); if (ch == '"') { return parseQuoted(); } else if (ch == '{') { return (String) parseLiteral(); } else { return parseBareString(false); } }
/** * Reads the next response available on the stream and returns an {@code ImapResponse} object that represents it. */ public ImapResponse readResponse(ImapResponseCallback callback) throws IOException { try { int peek = inputStream.peek(); if (peek == '+') { readContinuationRequest(callback); } else if (peek == '*') { readUntaggedResponse(callback); } else { readTaggedResponse(callback); } if (exception != null) { throw new ImapResponseParserException("readResponse(): Exception in callback method", exception); } return response; } finally { response = null; exception = null; } }
skipIfSpace(); int next = inputStream.peek(); if (next == '[') { parseList(parent, '[', ']');
private Object parseToken(ImapList parent) throws IOException { while (true) { int ch = inputStream.peek();