com.sshtools.daemon.util
Class StringScanner
java.lang.Object
com.sshtools.daemon.util.StringScanner
public class StringScanner
extends java.lang.Object
Simple scanner that allows to navigate over the characters of a string.
StringScanner(String stringToScan) - Initialize the new instance with the string that should be scanned.
|
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.
|
protected int | length()
|
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.
|
String | toString() - Returns the string the scanner was initialized with
|
END_REACHED
public static final char END_REACHED
buffer
protected char[] buffer
length
protected int length
pos_marker
protected int pos_marker
position
protected int position
StringScanner
public StringScanner(String stringToScan)
Initialize the new instance with the string that should be scanned.
atEnd
public boolean atEnd()
Returns true, if the scanner has reached the end and a further
invocation of nextChar() would return the END_REACHED character.
endNotReached
public boolean endNotReached(char character)
Returns true, if the given character does not indicate that the
end of the scanned string si reached.
endReached
public boolean endReached(char character)
Returns true, if the given character indicates that the end of the
scanned string is reached.
getPosition
public int getPosition()
Returns the current position in the string
hasNext
public boolean hasNext()
Returns true, if the scanner has not yet reached the end.
length
protected int length()
markPosition
public void markPosition()
Remembers the current position for later use with restorePosition()
nextChar
public char nextChar()
Returns the character at the current position and increments the
position afterwards by 1.
nextNoneWhitespaceChar
public char nextNoneWhitespaceChar()
Returns the next character that is no whitespace and leaves the position
pointer one character after the returned one.
peek
public 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.
restorePosition
public void restorePosition()
Restores the position to the value of the latest markPosition() call
setPosition
protected void setPosition(int pos)
skip
public void skip(int count)
Moves the position pointer count characters. positive values move
forwards, negative backwards. The position never becomes negative !
toString
public String toString()
Returns the string the scanner was initialized with
Copyright © 2002-2003 Lee David Painter & Contributors. All Rights Reserved.