Methods Summary |
---|
public void | advance()Advance the current parsing position by one, if we are not already
past the end of the string.
if (index < length)
index++;
|
public java.lang.String | extract(int start)Extract and return a substring that starts at the specified position,
and extends to the end of the string being parsed. If this is not
possible, a zero-length string is returned.
if ((start < 0) || (start >= length))
return ("");
else
return (string.substring(start));
|
public java.lang.String | extract(int start, int end)Extract and return a substring that starts at the specified position,
and ends at the character before the specified position. If this is
not possible, a zero-length string is returned.
if ((start < 0) || (start >= end) || (end > length))
return ("");
else
return (string.substring(start, end));
|
public int | findChar(char ch)Return the index of the next occurrence of the specified character,
or the index of the character after the last position of the string
if no more occurrences of this character are found. The current
parsing position is updated to the returned value.
while ((index < length) && (ch != chars[index]))
index++;
return (index);
|
public int | findText()Return the index of the next occurrence of a non-whitespace character,
or the index of the character after the last position of the string
if no more non-whitespace characters are found. The current
parsing position is updated to the returned value.
while ((index < length) && isWhite(chars[index]))
index++;
return (index);
|
public int | findWhite()Return the index of the next occurrence of a whitespace character,
or the index of the character after the last position of the string
if no more whitespace characters are found. The current parsing
position is updated to the returned value.
while ((index < length) && !isWhite(chars[index]))
index++;
return (index);
|
public int | getIndex()Return the zero-relative index of our current parsing position
within the string being parsed.
// ------------------------------------------------------------- Properties
return (this.index);
|
public int | getLength()Return the length of the string we are parsing.
return (this.length);
|
public java.lang.String | getString()Return the String we are currently parsing.
return (this.string);
|
protected boolean | isWhite(char ch)Is the specified character considered to be whitespace?
if ((ch == ' ") || (ch == '\t") || (ch == '\r") || (ch == '\n"))
return (true);
else
return (false);
|
public void | reset()Reset the current state of the parser to the beginning of the
current string being parsed.
index = 0;
|
public void | setString(java.lang.String string)Set the String we are currently parsing. The parser state is also reset
to begin at the start of this string.
this.string = string;
if (string != null) {
this.length = string.length();
chars = this.string.toCharArray();
} else {
this.length = 0;
chars = new char[0];
}
reset();
|
public int | skipChar(char ch)Advance the current parsing position while it is pointing at the
specified character, or until it moves past the end of the string.
Return the final value.
while ((index < length) && (ch == chars[index]))
index++;
return (index);
|
public int | skipText()Advance the current parsing position while it is pointing at a
non-whitespace character, or until it moves past the end of the string.
Return the final value.
while ((index < length) && !isWhite(chars[index]))
index++;
return (index);
|
public int | skipWhite()Advance the current parsing position while it is pointing at a
whitespace character, or until it moves past the end of the string.
Return the final value.
while ((index < length) && isWhite(chars[index]))
index++;
return (index);
|