Methods Summary |
---|
private int | expect(char ch)
int d;
if ((d = mIn.read()) != ch) {
if (d == -1 && Config.LOGD && Email.DEBUG) {
Log.d(Email.LOG_TAG, "expect(): end of stream reached");
}
throw new IOException(String.format("Expected %04x (%c) but got %04x (%c)", (int)ch,
ch, d, (char)d));
}
return d;
|
private java.lang.String | parseAtom()
StringBuffer sb = new StringBuffer();
int ch;
while (true) {
ch = mIn.peek();
if (ch == -1) {
if (Config.LOGD && Email.DEBUG) {
Log.d(Email.LOG_TAG, "parseAtom(): end of stream reached");
}
throw new IOException("parseAtom(): end of stream reached");
} else if (ch == '(" || ch == ')" || ch == '{" || ch == ' " ||
// docs claim that flags are \ atom but atom isn't supposed to
// contain
// * and some falgs contain *
// ch == '%' || ch == '*' ||
ch == '%" ||
// TODO probably should not allow \ and should recognize
// it as a flag instead
// ch == '"' || ch == '\' ||
ch == '"" || (ch >= 0x00 && ch <= 0x1f) || ch == 0x7f) {
if (sb.length() == 0) {
throw new IOException(String.format("parseAtom(): (%04x %c)", (int)ch, ch));
}
return sb.toString();
} else {
sb.append((char)mIn.read());
}
}
|
private boolean | parseCommandContinuationRequest()
expect('+");
expect(' ");
return true;
|
private com.android.email.mail.store.ImapResponseParser$ImapList | parseList()
expect('(");
ImapList list = new ImapList();
Object token;
while (true) {
token = parseToken();
if (token == null) {
break;
} else if (token instanceof InputStream) {
list.add(token);
break;
} else if (token.equals(")")) {
break;
} else {
list.add(token);
}
}
return list;
|
private java.io.InputStream | parseLiteral()A { has been read, read the rest of the size string, the space and then
notify the listener with an InputStream.
expect('{");
int size = Integer.parseInt(readStringUntil('}"));
expect('\r");
expect('\n");
FixedLengthInputStream fixed = new FixedLengthInputStream(mIn, size);
return fixed;
|
private java.lang.String | parseQuoted()A " has been read, read to the end of the quoted string and notify the
listener.
expect('"");
return readStringUntil('"");
|
private java.lang.String | parseTaggedResponse()
String tag = readStringUntil(' ");
return tag;
|
private java.lang.Object | parseToken()
if (mActiveLiteral != null) {
while (mActiveLiteral.read() != -1)
;
mActiveLiteral = null;
}
while (true) {
int ch = mIn.peek();
if (ch == '(") {
return parseList();
} else if (ch == ')") {
expect(')");
return ")";
} else if (ch == '"") {
return parseQuoted();
} else if (ch == '{") {
mActiveLiteral = parseLiteral();
return mActiveLiteral;
} else if (ch == ' ") {
expect(' ");
} else if (ch == '\r") {
expect('\r");
expect('\n");
return null;
} else if (ch == '\n") {
expect('\n");
return null;
} else {
return parseAtom();
}
}
|
private void | parseUntaggedResponse()
expect('*");
expect(' ");
|
public com.android.email.mail.store.ImapResponseParser$ImapResponse | readResponse()Reads the next response available on the stream and returns an
ImapResponse object that represents it.
ImapResponse response = new ImapResponse();
if (mActiveLiteral != null) {
while (mActiveLiteral.read() != -1)
;
mActiveLiteral = null;
}
int ch = mIn.peek();
if (ch == '*") {
parseUntaggedResponse();
readTokens(response);
} else if (ch == '+") {
response.mCommandContinuationRequested =
parseCommandContinuationRequest();
readTokens(response);
} else {
response.mTag = parseTaggedResponse();
readTokens(response);
}
if (Config.LOGD) {
if (Email.DEBUG) {
Log.d(Email.LOG_TAG, "<<< " + response.toString());
}
}
return response;
|
private java.lang.String | readStringUntil(char end)
StringBuffer sb = new StringBuffer();
int ch;
while ((ch = mIn.read()) != -1) {
if (ch == end) {
return sb.toString();
} else {
sb.append((char)ch);
}
}
if (Config.LOGD && Email.DEBUG) {
Log.d(Email.LOG_TAG, "readQuotedString(): end of stream reached");
}
throw new IOException("readQuotedString(): end of stream reached");
|
public java.lang.Object | readToken()Reads the next token of the response. The token can be one of: String -
for NIL, QUOTED, NUMBER, ATOM. InputStream - for LITERAL.
InputStream.available() returns the total length of the stream.
ImapResponseList - for PARENTHESIZED LIST. Can contain any of the above
elements including List.
while (true) {
Object token = parseToken();
if (token == null || !token.equals(")")) {
return token;
}
}
|
private void | readTokens(com.android.email.mail.store.ImapResponseParser$ImapResponse response)
response.clear();
Object token;
while ((token = readToken()) != null) {
if (response != null) {
response.add(token);
}
if (mActiveLiteral != null) {
break;
}
}
response.mCompleted = token == null;
|