public class StringScanner
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected char[] |
buffer |
static char |
END_REACHED |
protected int |
length |
protected int |
pos_marker |
protected int |
position |
Constructor and Description |
---|
StringScanner(java.lang.String stringToScan)
Initialize the new instance with the string that should be scanned.
|
Modifier and Type | Method and Description |
---|---|
boolean |
atEnd()
Returns true, if the scanner has reached the end and a further invocation
of nextChar() would return the END_REACHED character.
|
boolean |
endNotReached(char character)
Returns true, if the given character does not indicate that the
end of the scanned string si reached.
|
boolean |
endReached(char character)
Returns true, if the given character indicates that the end of the
scanned string is reached.
|
int |
getPosition()
Returns the current position in the string
|
boolean |
hasNext()
Returns true, if the scanner has not yet reached the end.
|
int |
length()
Returns the length of the underlying string.
|
void |
markPosition()
Remembers the current position for later use with restorePosition()
|
char |
nextChar()
Returns the character at the current position and increments
the position afterwards by 1.
|
char |
nextNoneWhitespaceChar()
Returns the next character that is no whitespace and leaves the
position pointer one character after the returned one.
|
char |
peek()
Returns the character at the current position without changing
the position, that is subsequent calls to this method return always
the same character.
|
void |
restorePosition()
Restores the position to the value of the latest markPosition() call
|
protected void |
setPosition(int pos) |
void |
skip(int count)
Moves the position pointer count characters.
|
java.lang.String |
toString()
Returns the string the scanner was initialized with
|
public static final char END_REACHED
protected int length
protected int position
protected int pos_marker
protected char[] buffer
public StringScanner(java.lang.String stringToScan)
public boolean endReached(char character)
public boolean endNotReached(char character)
public java.lang.String toString()
toString
in class java.lang.Object
public void skip(int count)
public char peek()
public char nextChar()
public boolean atEnd()
public boolean hasNext()
public char nextNoneWhitespaceChar()
public int getPosition()
public void markPosition()
public void restorePosition()
public int length()
protected void setPosition(int pos)