public abstract class AbstractParser extends java.lang.Object implements Parser
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
BUNDLE_CLASSNAME
The default resource bundle base name.
|
protected int |
current
The current character.
|
protected ErrorHandler |
errorHandler
The error handler.
|
protected NormalizingReader |
reader
The normalizing reader.
|
Constructor and Description |
---|
AbstractParser() |
Modifier and Type | Method and Description |
---|---|
protected java.lang.String |
createErrorMessage(java.lang.String key,
java.lang.Object[] args)
Returns a localized error message.
|
protected abstract void |
doParse()
Method responsible for actually parsing data after AbstractParser
has initialized itself.
|
protected java.lang.String |
getBundleClassName()
Returns the resource bundle base name.
|
int |
getCurrent()
Returns the current character value.
|
void |
parse(java.lang.String s)
Parses the given string.
|
protected void |
reportCharacterExpectedError(char expectedChar,
int currentChar)
simple api to call often reported error.
|
protected void |
reportError(java.lang.String key,
java.lang.Object[] args)
Signals an error to the error handler.
|
protected void |
reportUnexpectedCharacterError(int currentChar)
simple api to call often reported error.
|
void |
setErrorHandler(ErrorHandler handler)
Allow an application to register an error event handler.
|
protected void |
skipCommaSpaces()
Skips the whitespaces and an optional comma.
|
protected void |
skipSpaces()
Skips the whitespaces in the current reader.
|
public static final java.lang.String BUNDLE_CLASSNAME
protected ErrorHandler errorHandler
protected NormalizingReader reader
protected int current
public int getCurrent()
public void setErrorHandler(ErrorHandler handler)
If the application does not register an error event handler, all error events reported by the parser will cause an exception to be thrown.
Applications may register a new or different handler in the middle of a parse, and the parser must begin using the new handler immediately.
setErrorHandler
in interface Parser
handler
- The error handler.public void parse(java.lang.String s) throws ParseException
parse
in interface Parser
ParseException
protected abstract void doParse() throws ParseException, java.io.IOException
ParseException
java.io.IOException
protected void reportError(java.lang.String key, java.lang.Object[] args) throws ParseException
key
- The message key in the resource bundle.args
- The message arguments.ParseException
protected void reportCharacterExpectedError(char expectedChar, int currentChar)
expectedChar
- what caller expectedcurrentChar
- what caller foundprotected void reportUnexpectedCharacterError(int currentChar)
currentChar
- what the caller found and didnt expectprotected java.lang.String createErrorMessage(java.lang.String key, java.lang.Object[] args)
key
- The message key in the resource bundle.args
- The message arguments.protected java.lang.String getBundleClassName()
protected void skipSpaces() throws java.io.IOException
java.io.IOException
protected void skipCommaSpaces() throws java.io.IOException
java.io.IOException
Copyright (c) 2010 Gaudenz Alder, David Benson. All rights reserved.