| java.lang.Object com.sun.perseus.parser.AbstractParser
All known Subclasses: com.sun.perseus.parser.UnicodeParser, com.sun.perseus.parser.NumberParser, com.sun.perseus.parser.ClockParser,
AbstractParser | abstract public class AbstractParser (Code) | | AbstractParser is the base class for parsers found
in this package.
All parsers work on a String and the AbstractParser
keeps a reference to that string along with the current position
(@see #currentPos) and current character (@see current).
The key methods for this class are read which reads the next
character in the parsed string, setString which sets the string
to be parsed, and the utility methods skipCommaSpaces ,
skipSpaces and skipSpacesCommaSpaces which can
be used by descendants to skip common separators.
For an implementation example, see
TransformListParser .
version: $Id: AbstractParser.java,v 1.2 2006/04/21 06:40:21 st125089 Exp $ |
Method Summary | |
final protected boolean | currentStartsWith(String str) Tests if the current substring (i.e. | final protected int | read() the next character. | final protected void | setString(String str) Sets this parser's String. | final protected void | skipCommaSpaces() Skips the whitespaces and an optional comma. | final protected void | skipSepSpaces(char sep) Skips the whitespaces and an optional comma. | final protected void | skipSpaces() Skips the whitespaces in the current reader. | final protected void | skipSpacesCommaSpaces() Skips wsp*,wsp* and throws an IllegalArgumentException
if no comma is found. |
current | protected int current(Code) | | The current character being parsed
This is accessible by sub-classes
|
currentPos | protected int currentPos(Code) | | The current position in the string
|
currentStartsWith | final protected boolean currentStartsWith(String str)(Code) | | Tests if the current substring (i.e. the substring beginning at the
current position) starts with the specified prefix. If the current
substring starts with the specified prefix, the current character will
be updated to point to the character immediately following the last
character in the prefix; otherwise, the currentPos will
not be affected. For example, if the string being parsed is
"timingAttr", and the current character is 'A':
currentStartsWith("Att") returns true, current == 'r'
currentStartsWith("Attr") returns true, current == -1
currentStartsWith("Attx") returns false, current == 'A'
Parameters: str - the prefix to be tested true if the current substring starts with thespecified prefix. The result is false ifcurrentPos is non-positive, or if the current substringdoes not start with the specified prefix. |
read | final protected int read()(Code) | | the next character. Returns -1 when theend of the String has been reached. |
setString | final protected void setString(String str)(Code) | | Sets this parser's String. This also resets the
current position to 0
Parameters: str - the string this parser should parse. Shouldnot be null. |
skipCommaSpaces | final protected void skipCommaSpaces()(Code) | | Skips the whitespaces and an optional comma.
|
skipSepSpaces | final protected void skipSepSpaces(char sep)(Code) | | Skips the whitespaces and an optional comma.
Parameters: sep - seperator to skip in addition to spaces. |
skipSpaces | final protected void skipSpaces()(Code) | | Skips the whitespaces in the current reader.
|
skipSpacesCommaSpaces | final protected void skipSpacesCommaSpaces()(Code) | | Skips wsp*,wsp* and throws an IllegalArgumentException
if no comma is found.
|
|
|