public class ImapLine extends Object
A Imap conformant parser/scanner.
Constructor and Description |
---|
ImapLine(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.
|
Modifier and Type | Method and Description |
---|---|
static String |
charlistBuilder(int start,
int end)
Builds a set of chracters ranging from the ASCII code of start until the ASCII code
of end.
|
static String |
charlistDifferencer(String superset,
String subset)
Removes a given set of characters from a superset.
|
static String |
commandEncoder(String command)
Encodes a command so that newlines are visible.
|
String |
getAString()
Get an IMAP AString (direct, quoted or prefixed) from the current buffer position.
|
String |
getATag()
Get the tag at the current position.
|
String |
getCommand()
Getter for the command.
|
ImapConnection |
getConnection()
Getter for the Imap connection in Control of this command.
|
String |
getContext()
Returns the current buffer (including position) and some of the already read characters.
|
static String |
getNextTag()
Get a unique identifier as a tag.
|
static String |
getNextTag(String prefix)
Get a unique identifier as a tag.
|
String |
getString()
Get an IMAP String from the buffer (quoted or prefixed).
|
String |
getTag()
Getter for the command tag.
|
String |
skipBytes(long num)
Skips the specified number of characters and adds them to the past context.
|
String |
skipBytes(long num,
boolean modContext)
Skips the specified number of bytes.
|
boolean |
skipLineEnd()
Skips a CRLF combo in the buffer.
|
boolean |
skipUntilLineEnd()
Skips up to a CRLF combo in the buffer.
|
int |
skipWhitespace(int num)
Skips the specified number of SPACES.
|
String |
snoopBytes(long num)
Get the specified number of characters without moving from the current position.
|
boolean |
snoopEscQuotes()
Returns true if escaped quotes are present at the current position.
|
public ImapLine(ImapConnection con, String line, InputStream input) throws ImapException
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.
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 requiredImapException
- if reading failsNullPointerException
- if connection and line are nullpublic ImapLine(ImapConnection con, String line) throws ImapException
Trivial constructor omiting a stream.
This constructor is mainly meant for testing purposes
con
- The ImapConnection object which generated the Command lineline
- The String which has already been read (as Read ahead)ImapException
- if reading failsNullPointerException
- if connection and line are nullpublic static String charlistBuilder(int start, int end)
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.
start
- The first ASCII code to be usedend
- The last ASCII code to be usedpublic static String charlistDifferencer(String superset, String subset)
Removes a given set of characters from a superset.
superset
- the set where character should be removed fromsubset
- the set of characters to be removedpublic static String commandEncoder(String command)
Encodes a command so that newlines are visible.
command
- the command to be encoded for output on screenpublic static String getNextTag()
Get a unique identifier as a tag.
public static String getNextTag(String prefix)
Get a unique identifier as a tag.
prefix
- the prefix prepended to the tagpublic ImapConnection getConnection()
Getter for the Imap connection in Control of this command.
public String getCommand()
Getter for the command.
public String getTag()
Getter for the command tag.
public boolean snoopEscQuotes()
Returns true if escaped quotes are present at the current position.
public String snoopBytes(long num)
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.
num
- the number of bytes to be snoopedpublic String getContext()
Returns the current buffer (including position) and some of the already read characters.
public String skipBytes(long num)
Skips the specified number of characters and adds them to the past context.
num
- number of characters to be skippedpublic String skipBytes(long num, boolean modContext)
Skips the specified number of bytes.
num
- the number of bytes to be skippedmodContext
- if true the context is updated by the operationpublic final int skipWhitespace(int num)
Skips the specified number of SPACES.
num
- number of spaces to be skippedpublic boolean skipLineEnd()
Skips a CRLF combo in the buffer.
public boolean skipUntilLineEnd()
Skips up to a CRLF combo in the buffer.
public String getString()
Get an IMAP String from the buffer (quoted or prefixed).
public String getAString()
Get an IMAP AString (direct, quoted or prefixed) from the current buffer position.
public String getATag()
Get the tag at the current position.
Copyright © 2023. All rights reserved.