| java.lang.Object org.apache.catalina.util.StringParser
StringParser | final public class StringParser (Code) | | Utility class for string parsing that is higher performance than
StringParser for simple delimited text cases. Parsing is performed
by setting the string, and then using the findXxxx() and
skipXxxx() families of methods to remember significant
offsets. To retrieve the parsed substrings, call the extract()
method with the appropriate saved offset values.
author: Craig R. McClanahan version: $Revision: 1.2 $ $Date: 2001/07/22 20:25:14 $ |
Constructor Summary | |
public | StringParser() Construct a string parser with no preset string to be parsed. | public | StringParser(String string) Construct a string parser that is initialized to parse the specified
string. |
Method Summary | |
public void | advance() Advance the current parsing position by one, if we are not already
past the end of the string. | public 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. | public 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. | 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. | 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. | 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. | public int | getIndex() Return the zero-relative index of our current parsing position
within the string being parsed. | public int | getLength() Return the length of the string we are parsing. | public String | getString() Return the String we are currently parsing. | protected boolean | isWhite(char ch) | public void | reset() Reset the current state of the parser to the beginning of the
current string being parsed. | public void | setString(String string) Set the String we are currently parsing. | 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. | 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. | 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. |
StringParser | public StringParser()(Code) | | Construct a string parser with no preset string to be parsed.
|
StringParser | public StringParser(String string)(Code) | | Construct a string parser that is initialized to parse the specified
string.
Parameters: string - The string to be parsed |
advance | public void advance()(Code) | | Advance the current parsing position by one, if we are not already
past the end of the string.
|
extract | public String extract(int start)(Code) | | 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.
Parameters: start - Starting index, zero relative, inclusive |
extract | public String extract(int start, int end)(Code) | | 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.
Parameters: start - Starting index, zero relative, inclusive Parameters: end - Ending index, zero relative, exclusive |
findChar | public int findChar(char ch)(Code) | | 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.
Parameters: ch - Character to be found |
findText | public int findText()(Code) | | 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.
|
findWhite | public int findWhite()(Code) | | 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.
|
getIndex | public int getIndex()(Code) | | Return the zero-relative index of our current parsing position
within the string being parsed.
|
getLength | public int getLength()(Code) | | Return the length of the string we are parsing.
|
getString | public String getString()(Code) | | Return the String we are currently parsing.
|
isWhite | protected boolean isWhite(char ch)(Code) | | Is the specified character considered to be whitespace?
Parameters: ch - Character to be checked |
reset | public void reset()(Code) | | Reset the current state of the parser to the beginning of the
current string being parsed.
|
setString | public void setString(String string)(Code) | | Set the String we are currently parsing. The parser state is also reset
to begin at the start of this string.
Parameters: string - The string to be parsed. |
skipChar | public int skipChar(char ch)(Code) | | 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.
Parameters: ch - Character to be skipped |
skipText | public int skipText()(Code) | | 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.
|
skipWhite | public int skipWhite()(Code) | | 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.
|
|
|