Interface IParser
- All Known Implementing Classes:
LineParser,Parser,StringParser
public interface IParser
Character-level parser with lookahead, used by the text readers to peek at, match and consume their input.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()voidconsume()voidconsume(int count) voidvoidconsumeWhitespace(char[] exception) Skips whitespace at the current position, stopping where the given string (such as a field separator) begins.voidconsumeWhitespace(int exception) Skips spaces and tabs at the current position, stopping early at the given character.voidconsumeWhitespace(CharSequence exception) Skips whitespace at the current position, stopping where the given string (such as a field separator) begins.Wraps the exception in aDataExceptionand adds the parser's buffer and position as properties.longReturns the number of characters consumed so far (within the current line forLineParser).voidmatch(char expectedChar) Consumes the next character, throwing aDataExceptionif it is not the expected one.voidmatch(char[] expectedString) Consumes the expected string, throwing aDataExceptionat the first character that differs.voidConsumes the expected string, throwing aDataExceptionprefixed withfailureMessageat the first character that differs.voidConsumes the next character, throwing aDataExceptionprefixed withfailureMessageif it is not the expected one.voidmatch(CharSequence expectedString) Consumes the expected string, throwing aDataExceptionat the first character that differs.voidmatch(CharSequence expectedString, String failureMessage) Consumes the expected string, throwing aDataExceptionprefixed withfailureMessageat the first character that differs.matchUntil(char terminatingChar) Consumes and returns the text before the terminating character, then consumes the terminator; throws aDataExceptionif the input ends first.matchUntil(char terminatingChar, String failureMessage) Consumes and returns the text before the terminating character, then consumes the terminator; throws aDataExceptionprefixed withfailureMessageif the input ends first.Consumes and returns all remaining characters (of the current line forLineParser).intpeek(int index) Returns the character at the given 0-based offset ahead without consuming it, orEOFpast the end of the input.peekSequence(int offset, int length) Returns up tolengthcharacters starting at the given lookahead offset without consuming them; fewer if the input ends first.booleanpeekString(char[] lookahead) Indicates if the upcoming characters match the given string, without consuming them.booleanpeekString(CharSequence lookahead) Indicates if the upcoming characters match the given string, without consuming them.intpeekStringArray(char[][] lookahead) Returns the index of the first string that matches the upcoming characters or -1 if none do, without consuming them.intpeekStringArray(char[][] lookahead, int offset) Returns the index of the first string that matches the characters at the given lookahead offset or -1 if none do.intpeekStringArray(CharSequence... lookahead) Returns the index of the first string that matches the upcoming characters or -1 if none do, without consuming them.intpeekStringArray(CharSequence[] lookahead, int offset) Returns the index of the first string that matches the characters at the given lookahead offset or -1 if none do.booleanpeekStringOffset(char[] lookahead, int offset) Indicates if the characters starting at the given lookahead offset match the given string, without consuming them.booleanpeekStringOffset(CharSequence lookahead, int offset) Indicates if the characters starting at the given lookahead offset match the given string, without consuming them.intpeekWhitespaceLength(int index) Returns the number of consecutive whitespace characters starting at the given 0-based lookahead offset.intpop()Consumes and returns the next character, orEOFat the end of the input.booleanready()
-
Field Details
-
EOF
static final int EOF- See Also:
-
-
Method Details
-
exception
Wraps the exception in aDataExceptionand adds the parser's buffer and position as properties. -
ready
- Throws:
IOException
-
getColumn
long getColumn()Returns the number of characters consumed so far (within the current line forLineParser). -
peek
int peek(int index) Returns the character at the given 0-based offset ahead without consuming it, orEOFpast the end of the input. -
peekWhitespaceLength
int peekWhitespaceLength(int index) Returns the number of consecutive whitespace characters starting at the given 0-based lookahead offset. -
peekSequence
Returns up tolengthcharacters starting at the given lookahead offset without consuming them; fewer if the input ends first. -
peekString
Indicates if the upcoming characters match the given string, without consuming them. -
peekString
boolean peekString(char[] lookahead) Indicates if the upcoming characters match the given string, without consuming them. -
peekStringOffset
Indicates if the characters starting at the given lookahead offset match the given string, without consuming them. -
peekStringOffset
boolean peekStringOffset(char[] lookahead, int offset) Indicates if the characters starting at the given lookahead offset match the given string, without consuming them. -
peekStringArray
Returns the index of the first string that matches the upcoming characters or -1 if none do, without consuming them. -
peekStringArray
int peekStringArray(char[][] lookahead) Returns the index of the first string that matches the upcoming characters or -1 if none do, without consuming them. -
peekStringArray
Returns the index of the first string that matches the characters at the given lookahead offset or -1 if none do. -
peekStringArray
int peekStringArray(char[][] lookahead, int offset) Returns the index of the first string that matches the characters at the given lookahead offset or -1 if none do. -
pop
int pop()Consumes and returns the next character, orEOFat the end of the input. -
match
Consumes the next character, throwing aDataExceptionprefixed withfailureMessageif it is not the expected one. -
match
void match(char expectedChar) Consumes the next character, throwing aDataExceptionif it is not the expected one. -
match
Consumes the expected string, throwing aDataExceptionprefixed withfailureMessageat the first character that differs. -
match
Consumes the expected string, throwing aDataExceptionprefixed withfailureMessageat the first character that differs. -
match
Consumes the expected string, throwing aDataExceptionat the first character that differs. -
match
void match(char[] expectedString) Consumes the expected string, throwing aDataExceptionat the first character that differs. -
matchUntil
Consumes and returns the text before the terminating character, then consumes the terminator; throws aDataExceptionif the input ends first. -
matchUntil
Consumes and returns the text before the terminating character, then consumes the terminator; throws aDataExceptionprefixed withfailureMessageif the input ends first. -
matchUntilEof
StringBuilder matchUntilEof()Consumes and returns all remaining characters (of the current line forLineParser). -
consume
void consume() -
consume
void consume(int count) -
consumeWhitespace
void consumeWhitespace() -
consumeWhitespace
void consumeWhitespace(int exception) Skips spaces and tabs at the current position, stopping early at the given character. -
consumeWhitespace
Skips whitespace at the current position, stopping where the given string (such as a field separator) begins. -
consumeWhitespace
void consumeWhitespace(char[] exception) Skips whitespace at the current position, stopping where the given string (such as a field separator) begins. -
close
void close()
-