public interface CharacterInput
The readXXX() and peek() methods do not throw any exception when the end of the available data is reached, but return special non-null values.
The readCharXXX() and peekChar() methods do throw a RuntimeException when the end of the available data is reached.
| Modifier and Type | Method and Description |
|---|---|
int |
peek()
Returns the next character, without moving the reading position forward.
|
int |
peek(int n)
Returns the next (n+1)th character, without moving the reading position forward.
|
char |
peekChar()
Returns the next character, without moving the reading position forward.
|
char |
peekChar(int n)
Returns the next (n+1)th character, without moving the reading position forward.
|
void |
pushBack(char c)
Pushes a character back to the input, so that it will be returned by the next reading
operation.
|
int |
read()
Reads the next character.
|
default CharsWrapper |
read(int n)
Reads the next n characters, if possible.
|
default int |
readAndSkip(char[] toSkip)
Reads the next characters, skipping some characters.
|
char |
readChar()
Reads the next character, throwing an exception if there is no more available data.
|
default char |
readCharAndSkip(char[] toSkip)
Reads the next characters, skipping some characters.
|
default CharsWrapper |
readChars(int n)
Reads the next n characters.
|
CharsWrapper |
readCharsUntil(char[] stop)
Reads all the characters until a character contained in
stop is reached, and returns
the CharsWrapper that contains all the characters before the stop. |
CharsWrapper |
readUntil(char[] stop)
Reads all the character until a character containde in
stop is reached or there is no
more available data, and returns the CharsWrapper that contains all the characters
before the stop (or the end of the data). |
void |
skipPeeks()
Skips all the character that have been peeked and not parsed yet.
|
int read()
char readChar()
ParsingException - if there is no more available datadefault int readAndSkip(char[] toSkip)
toSkip - the characters to skiptoSkip, or -1 if there is no more available
datadefault char readCharAndSkip(char[] toSkip)
toSkip - the characters to skiptoSkipParsingException - if there is no more available datadefault CharsWrapper read(int n)
n - the number of characters to parsedefault CharsWrapper readChars(int n)
n - the number of characters to parseParsingException - if there is no more available dataCharsWrapper readUntil(char[] stop)
stop is reached or there is no
more available data, and returns the CharsWrapper that contains all the characters
before the stop (or the end of the data).stop - the characters to stop atCharsWrapper readCharsUntil(char[] stop)
stop is reached, and returns
the CharsWrapper that contains all the characters before the stop.stop - the characters to stop atParsingException - if the end of the data is reached before a stop characterint peek()
peek(), the method read() will return the exact same character.
This method behaves exactly like peek(0)
int peek(int n)
n - the position to peekParsingException - if there is no (n+1)th characterchar peekChar()
peek(), the method read() will return the exact same character.
This method behaves exactly like peekChar(0)
This method throws an exception if there is no more available data.
ParsingException - if there is no more available datachar peekChar(int n)
This method throws an exception if there is no more available data.
n - the position to peekParsingException - if there is no (n+1)th charactervoid skipPeeks()
void pushBack(char c)
c - the character to push back