public abstract class AbstractInput extends java.lang.Object implements CharacterInput
| Modifier and Type | Field and Description |
|---|---|
protected IntDeque |
deque
Contains the peeked characters that haven't been read (by the read methods) yet.
|
| Constructor and Description |
|---|
AbstractInput() |
| Modifier and Type | Method and Description |
|---|---|
protected CharsWrapper |
consumeDeque(char[] array,
int offset,
boolean mustReadAll)
Consumes the chars of the deque and put them in an array.
|
protected abstract int |
directRead()
Tries to parse the next character without taking care of the peek deque.
|
protected abstract char |
directReadChar()
Tries to parse the next character without taking care of the peek deque.
|
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.
|
char |
readChar()
Reads the next character, throwing an exception if there is no more available data.
|
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.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitread, readAndSkip, readCharAndSkip, readCharsprotected final IntDeque deque
protected abstract int directRead()
protected abstract char directReadChar()
ParsingException - if the EOS has been reachedpublic int read()
CharacterInputread in interface CharacterInputpublic char readChar()
CharacterInputreadChar in interface CharacterInputpublic int peek()
CharacterInputpeek(), the method CharacterInput.read() will return the exact same character.
This method behaves exactly like peek(0)
peek in interface CharacterInputpublic int peek(int n)
CharacterInputpeek in interface CharacterInputn - the position to peekpublic char peekChar()
CharacterInputpeek(), the method CharacterInput.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.
peekChar in interface CharacterInputpublic char peekChar(int n)
CharacterInputThis method throws an exception if there is no more available data.
peekChar in interface CharacterInputn - the position to peekpublic void skipPeeks()
CharacterInputskipPeeks in interface CharacterInputpublic void pushBack(char c)
CharacterInputpushBack in interface CharacterInputc - the character to push backpublic CharsWrapper readUntil(char[] stop)
CharacterInputstop 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).readUntil in interface CharacterInputstop - the characters to stop atpublic CharsWrapper readCharsUntil(char[] stop)
CharacterInputstop is reached, and returns
the CharsWrapper that contains all the characters before the stop.readCharsUntil in interface CharacterInputstop - the characters to stop atprotected CharsWrapper consumeDeque(char[] array, int offset, boolean mustReadAll)
array - the destination arrayoffset - the beginning index in the arraymustReadAll - true to throw an exception if the array can't be fulled,
false to return a CharsWrapper containing the read characters.