Class ImapLine
A Imap conformant parser/scanner.
- Author:
- Martin Gwerder
-
Constructor Summary
ConstructorsConstructorDescriptionImapLine(ImapConnection con, String line) Trivial constructor omiting a stream.ImapLine(ImapConnection con, String line, InputStream input) Creates an imap line object with a parser for a command. -
Method Summary
Modifier and TypeMethodDescriptionstatic StringcharlistBuilder(int start, int end) Builds a set of chracters ranging from the ASCII code of start until the ASCII code of end.static StringcharlistDifferencer(String superset, String subset) Removes a given set of characters from a superset.static StringcommandEncoder(String command) Encodes a command so that newlines are visible.Get an IMAP AString (direct, quoted or prefixed) from the current buffer position.getATag()Get the tag at the current position.Getter for the command.Getter for the Imap connection in Control of this command.Returns the current buffer (including position) and some of the already read characters.static StringGet a unique identifier as a tag.static StringgetNextTag(String prefix) Get a unique identifier as a tag.Get an IMAP String from the buffer (quoted or prefixed).getTag()Getter for the command tag.skipBytes(long num) Skips the specified number of characters and adds them to the past context.skipBytes(long num, boolean modContext) Skips the specified number of bytes.booleanSkips a CRLF combo in the buffer.booleanSkips up to a CRLF combo in the buffer.final intskipWhitespace(int num) Skips the specified number of SPACES.snoopBytes(long num) Get the specified number of characters without moving from the current position.booleanReturns true if escaped quotes are present at the current position.
-
Constructor Details
-
ImapLine
Creates an imap line object with a parser for a command.
A passed input stream is appended to line. Reading takes place according to the ABNF-Rules defined in the respective RFC.
- Parameters:
con- The ImapConnection object which generated the Command lineline- The String which has already been read (as Read ahead)input- The Stream offering more data to read if required- Throws:
ImapException- if reading failsNullPointerException- if connection and line are null
-
ImapLine
Trivial constructor omiting a stream.
This constructor is mainly meant for testing purposes
- Parameters:
con- The ImapConnection object which generated the Command lineline- The String which has already been read (as Read ahead)- Throws:
ImapException- if reading failsNullPointerException- if connection and line are null
-
-
Method Details
-
charlistBuilder
Builds a set of chracters ranging from the ASCII code of start until the ASCII code of end.
This helper is mainly used to build ABNF strings.
- Parameters:
start- The first ASCII code to be usedend- The last ASCII code to be used- Returns:
- the generated character list
-
charlistDifferencer
Removes a given set of characters from a superset.
- Parameters:
superset- the set where character should be removed fromsubset- the set of characters to be removed- Returns:
- the difference of the two given charsets
-
commandEncoder
Encodes a command so that newlines are visible.
- Parameters:
command- the command to be encoded for output on screen- Returns:
- a printable string representation
-
getNextTag
Get a unique identifier as a tag.
- Returns:
- A unique tag ("A" prefixed)
-
getNextTag
Get a unique identifier as a tag.
- Parameters:
prefix- the prefix prepended to the tag- Returns:
- A unique tag
-
getConnection
Getter for the Imap connection in Control of this command.
- Returns:
- ImapConnection storing the context of this command
-
getCommand
Getter for the command.
- Returns:
- command token
-
getTag
Getter for the command tag.
- Returns:
- command tag
-
snoopEscQuotes
public boolean snoopEscQuotes()Returns true if escaped quotes are present at the current position.
- Returns:
- true if escaped quotes are present
-
snoopBytes
Get the specified number of characters without moving from the current position.
if num is 0 or negative then null is returned. If the number of available bytes is lower than the number of requested characters then the buffer content is returned.
- Parameters:
num- the number of bytes to be snooped- Returns:
- the requested string
-
getContext
Returns the current buffer (including position) and some of the already read characters.
- Returns:
- String representation of the current context
-
skipBytes
Skips the specified number of characters and adds them to the past context.
- Parameters:
num- number of characters to be skipped- Returns:
- String representation of the skipped characters
-
skipBytes
Skips the specified number of bytes.
- Parameters:
num- the number of bytes to be skippedmodContext- if true the context is updated by the operation- Returns:
- the skipped bytes
-
skipWhitespace
public final int skipWhitespace(int num) Skips the specified number of SPACES.
- Parameters:
num- number of spaces to be skipped- Returns:
- number of skipped spaces
-
skipLineEnd
public boolean skipLineEnd()Skips a CRLF combo in the buffer.
- Returns:
- True if a combo has been skipped
-
skipUntilLineEnd
public boolean skipUntilLineEnd()Skips up to a CRLF combo in the buffer.
- Returns:
- True if a combo has been skipped (false if buffer ended before a CRLF combo was read
-
getString
Get an IMAP String from the buffer (quoted or prefixed).
- Returns:
- The String or null if no string is at the current position
-
getAString
Get an IMAP AString (direct, quoted or prefixed) from the current buffer position.
- Returns:
- The String or null if no string at the current position
-
getATag
Get the tag at the current position.
- Returns:
- the tag or null if no valid is found
-