org.apache.batik.parser

Class AbstractParser

public abstract class AbstractParser extends Object implements Parser

This class is the superclass of all parsers. It provides localization and error handling methods.
Field Summary
static StringBUNDLE_CLASSNAME
The default resource bundle base name.
protected intcurrent
The current character.
protected ErrorHandlererrorHandler
The error handler.
protected LocalizableSupportlocalizableSupport
The localizable support.
protected NormalizingReaderreader
The normalizing reader.
Method Summary
protected StringcreateErrorMessage(String key, Object[] args)
Returns a localized error message.
protected abstract voiddoParse()
Method responsible for actually parsing data after AbstractParser has initialized itself.
StringformatMessage(String key, Object[] args)
Implements {@link org.apache.batik.i18n.Localizable#formatMessage(String,Object[])}.
protected StringgetBundleClassName()
Returns the resource bundle base name.
intgetCurrent()
Returns the current character value.
LocalegetLocale()
Implements {@link org.apache.batik.i18n.Localizable#getLocale()}.
voidparse(Reader r)
Parses the given reader
voidparse(InputStream is, String enc)
Parses the given input stream.
voidparse(String s)
Parses the given string.
protected voidreportCharacterExpectedError(char expectedChar, int currentChar)
simple api to call often reported error.
protected voidreportError(String key, Object[] args)
Signals an error to the error handler.
protected voidreportUnexpectedCharacterError(int currentChar)
simple api to call often reported error.
voidsetErrorHandler(ErrorHandler handler)
Allow an application to register an error event handler.
voidsetLocale(Locale l)
Implements {@link org.apache.batik.i18n.Localizable#setLocale(Locale)}.
protected voidskipCommaSpaces()
Skips the whitespaces and an optional comma.
protected voidskipSpaces()
Skips the whitespaces in the current reader.

Field Detail

BUNDLE_CLASSNAME

public static final String BUNDLE_CLASSNAME
The default resource bundle base name.

current

protected int current
The current character.

errorHandler

protected ErrorHandler errorHandler
The error handler.

localizableSupport

protected LocalizableSupport localizableSupport
The localizable support.

reader

protected NormalizingReader reader
The normalizing reader.

Method Detail

createErrorMessage

protected String createErrorMessage(String key, Object[] args)
Returns a localized error message.

Parameters: key The message key in the resource bundle. args The message arguments.

doParse

protected abstract void doParse()
Method responsible for actually parsing data after AbstractParser has initialized itself.

formatMessage

public String formatMessage(String key, Object[] args)
Implements {@link org.apache.batik.i18n.Localizable#formatMessage(String,Object[])}.

getBundleClassName

protected String getBundleClassName()
Returns the resource bundle base name.

Returns: BUNDLE_CLASSNAME.

getCurrent

public int getCurrent()
Returns the current character value.

getLocale

public Locale getLocale()
Implements {@link org.apache.batik.i18n.Localizable#getLocale()}.

parse

public void parse(Reader r)
Parses the given reader

parse

public void parse(InputStream is, String enc)
Parses the given input stream. If the encoding is null, ISO-8859-1 is used.

parse

public void parse(String s)
Parses the given string.

reportCharacterExpectedError

protected void reportCharacterExpectedError(char expectedChar, int currentChar)
simple api to call often reported error. Just a wrapper for reportError().

Parameters: expectedChar what caller expected currentChar what caller found

reportError

protected void reportError(String key, Object[] args)
Signals an error to the error handler.

Parameters: key The message key in the resource bundle. args The message arguments.

reportUnexpectedCharacterError

protected void reportUnexpectedCharacterError(int currentChar)
simple api to call often reported error. Just a wrapper for reportError().

Parameters: currentChar what the caller found and didnt expect

setErrorHandler

public void setErrorHandler(ErrorHandler handler)
Allow an application to register an error event 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.

Parameters: handler The error handler.

setLocale

public void setLocale(Locale l)
Implements {@link org.apache.batik.i18n.Localizable#setLocale(Locale)}.

skipCommaSpaces

protected void skipCommaSpaces()
Skips the whitespaces and an optional comma.

skipSpaces

protected void skipSpaces()
Skips the whitespaces in the current reader.
Copyright B) 2007 Apache Software Foundation. All Rights Reserved.