Class CommandParser
java.lang.Object
com.icegreen.greenmail.imap.commands.CommandParser
- Version:
- $Revision: 109034 $
- Author:
- Darrell DeBoer <darrell@apache.org>
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classprotected static interfaceProvides the ability to ensure characters are part of a permitted set.protected static classprotected static class -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionastring(ImapRequestLineReader request) Reads an argument of type "astring" from the request.atom(ImapRequestLineReader request) Reads an argument of type "atom" from the request.atomOnly(ImapRequestLineReader request) Reads an argument of type "atom" from the request.protected voidconsumeChar(ImapRequestLineReader request, char expected) Consumes the next character in the request, checking that it matches the expected one.protected StringconsumeLiteral(ImapRequestLineReader request) Reads an argument of type "literal" from the request, in the format: "{" charCount "}" CRLF *CHAR8 Note before calling, the request should be positioned so that nextChar is '{'.protected byte[]longconsumeLong(ImapRequestLineReader request) protected StringconsumeQuoted(ImapRequestLineReader request) Reads a quoted string value from the request.protected StringconsumeWord(ImapRequestLineReader request) Reads the next "word" from the request, comprising all characters up to the next SPACE.protected StringconsumeWord(ImapRequestLineReader request, CommandParser.CharacterValidator validator) Reads the next "word" from the request, comprising all characters up to the next SPACE.protected StringconsumeWordOnly(ImapRequestLineReader request, CommandParser.CharacterValidator validator) Reads the next "word from the request, comprising all characters up to the next SPACE.dateTime(ImapRequestLineReader request) Reads a "date-time" argument from the request.voidendLine(ImapRequestLineReader request) Consumes the request up to and including the eno-of-line.jakarta.mail.FlagsflagList(ImapRequestLineReader request) Reads a "flags" argument from the request.protected booleanisAtomSpecial(char next) static booleanisCrOrLf(char chr) Checks if character is either CR or LF.protected booleanisListWildcard(char chr) mailbox(ImapRequestLineReader request) Reads a "mailbox" argument from the request.nstring(ImapRequestLineReader request) Reads an argument of type "nstring" from the request.longnumber(ImapRequestLineReader request) Reads an argument of type "number" from the request.longnzNumber(ImapRequestLineReader request) Reads an argument of type "nznumber" (a non-zero number) (NOTE this isn't strictly as per the spec, since the spec disallows numbers such as "0123" as nzNumbers (although it's ok as a "number".IdRange[]parseIdRange(ImapRequestLineReader request) Reads a "message set" argument, and parses into an IdSet.voidstring(ImapRequestLineReader request, Charset charset) Reads an argument of type "string" from the request.tag(ImapRequestLineReader request) Reads a command "tag" from the request.
-
Constructor Details
-
CommandParser
public CommandParser()
-
-
Method Details
-
atom
Reads an argument of type "atom" from the request.- Throws:
ProtocolException
-
atomOnly
Reads an argument of type "atom" from the request. Stops reading when non-atom chars are read.- Throws:
ProtocolException
-
tag
Reads a command "tag" from the request.- Throws:
ProtocolException
-
astring
Reads an argument of type "astring" from the request.- Throws:
ProtocolException
-
string
Reads an argument of type "string" from the request.string = quoted / literal
- Throws:
ProtocolException
-
nstring
Reads an argument of type "nstring" from the request. https://tools.ietf.org/html/rfc3501#page-88 : nstring = string / nil nil = "NIL"- Throws:
ProtocolException
-
mailbox
Reads a "mailbox" argument from the request. Not implemented *exactly* as per spec, since a quoted or literal "inbox" still yeilds "INBOX" (ie still case-insensitive if quoted or literal). I think this makes sense.mailbox ::= "INBOX" / astring ;; INBOX is case-insensitive. All case variants of ;; INBOX (e.g. "iNbOx") MUST be interpreted as INBOX ;; not as an astring.
- Throws:
ProtocolException
-
dateTime
Reads a "date-time" argument from the request.- Throws:
ProtocolException
-
consumeWord
Reads the next "word" from the request, comprising all characters up to the next SPACE.- Throws:
ProtocolException
-
consumeWord
protected String consumeWord(ImapRequestLineReader request, CommandParser.CharacterValidator validator) throws ProtocolException Reads the next "word" from the request, comprising all characters up to the next SPACE. Characters are tested by the supplied CharacterValidator, and an exception is thrown if invalid characters are encountered.- Throws:
ProtocolException
-
consumeWordOnly
protected String consumeWordOnly(ImapRequestLineReader request, CommandParser.CharacterValidator validator) throws ProtocolException Reads the next "word from the request, comprising all characters up to the next SPACE. Characters are tested by the supplied CharacterValidator, and if invalid characters are encountered these are not consumed.- Throws:
ProtocolException
-
consumeLong
- Throws:
ProtocolException
-
consumeLiteral
Reads an argument of type "literal" from the request, in the format: "{" charCount "}" CRLF *CHAR8 Note before calling, the request should be positioned so that nextChar is '{'. Leading whitespace is not skipped in this method.- Throws:
ProtocolException
-
consumeLiteralAsBytes
- Throws:
ProtocolException
-
consumeChar
Consumes the next character in the request, checking that it matches the expected one. This method should be used when the- Throws:
ProtocolException
-
consumeQuoted
Reads a quoted string value from the request.- Throws:
ProtocolException
-
flagList
Reads a "flags" argument from the request.- Throws:
ProtocolException
-
setFlag
-
number
Reads an argument of type "number" from the request.- Throws:
ProtocolException
-
nzNumber
Reads an argument of type "nznumber" (a non-zero number) (NOTE this isn't strictly as per the spec, since the spec disallows numbers such as "0123" as nzNumbers (although it's ok as a "number". I think the spec is a bit shonky.)- Throws:
ProtocolException
-
isListWildcard
protected boolean isListWildcard(char chr) -
isCrOrLf
public static boolean isCrOrLf(char chr) Checks if character is either CR or LF.- Parameters:
chr- the character- Returns:
- true, if either CR or LF.
-
endLine
Consumes the request up to and including the eno-of-line.- Parameters:
request- The request- Throws:
ProtocolException- If characters are encountered before the endLine.
-
parseIdRange
Reads a "message set" argument, and parses into an IdSet. Currently only supports a single range of values.- Throws:
ProtocolException
-
isAtomSpecial
protected boolean isAtomSpecial(char next)
-