* org.apache.james.imap.decode.ImapRequestLineReader, java.lang.String,
* boolean, org.apache.james.imap.api.process.ImapSession)
*/
protected ImapMessage decode(ImapCommand command, ImapRequestLineReader request, String tag, boolean useUids, ImapSession session) throws DecodingException {
try {
SearchKey recent = null;
List<SearchResultOption> options = null;
int c = ImapRequestLineReader.cap(request.nextWordChar());
if (c == 'R') {
// if we found a R its either RECENT or RETURN so consume it
request.consume();
nextIsE(request);
c = consumeAndCap(request);
switch (c) {
case 'C':
recent = recent(request);
break;
case 'T':
nextIsU(request);
nextIsR(request);
nextIsN(request);
request.nextWordChar();
options = parseOptions(request);
break;
default:
throw new DecodingException(HumanReadableText.ILLEGAL_ARGUMENTS, "Unknown search key");
}
}
final SearchKey finalKey;
if (recent != null) {
if (request.nextChar() != ' ') {
request.eol();
finalKey = recent;
} else {
// Parse the search term from the request
final SearchKey key = decode(session, request);
finalKey = SearchKey.buildAnd(Arrays.asList(recent, key));
}
} else {
// Parse the search term from the request
finalKey = decode(session, request);