org.apache.batik.refimpl.parser
Class AbstractParser

java.lang.Object
  |
  +--org.apache.batik.refimpl.parser.AbstractParser
All Implemented Interfaces:
Localizable, Parser
Direct Known Subclasses:
ConcretePreserveAspectRatioParser, NumberParser

public abstract class AbstractParser
extends java.lang.Object
implements Parser

This class is the superclass of all parsers. It provides localization and error handling methods.


Field Summary
static java.lang.String BUNDLE_CLASSNAME
          The default resource bundle base name.
protected  int column
          The current column number.
protected  int current
          The current character.
protected  ErrorHandler errorHandler
          The error handler.
protected  int line
          The current line number.
protected  LocalizableSupport localizableSupport
          The localizable support.
protected  boolean newlineRead
          Whether the last character read was a newline.
protected  java.io.Reader reader
          The current input reader.
 
Constructor Summary
AbstractParser()
           
 
Method Summary
protected  java.lang.String createErrorMessage(java.lang.String key, java.lang.Object[] args)
          Returns a localized error message.
 java.lang.String formatMessage(java.lang.String key, java.lang.Object[] args)
          Implements Localizable.formatMessage(String,Object[]).
protected  java.lang.String getBundleClassName()
          Returns the resource bundle base name.
 int getCurrent()
          Returns the current character value.
 java.util.Locale getLocale()
          Implements Localizable.getLocale().
protected  void initialize(java.io.Reader r)
          Initializes the parser.
protected  void read()
          Reads one character from the given reader and sets 'current' to this value.
protected  void reportError(java.lang.String key, java.lang.Object[] args)
          Signals an error to the error handler.
 void setErrorHandler(ErrorHandler handler)
          Allow an application to register an error event handler.
 void setLocale(java.util.Locale l)
          Implements Localizable.setLocale(Locale).
protected  void skipCommaSpaces()
          Skips the whitespaces and an optional comma.
protected  void skipSpaces()
          Skips the whitespaces in the current reader.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.batik.parser.Parser
parse
 

Field Detail

BUNDLE_CLASSNAME

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

errorHandler

protected ErrorHandler errorHandler
The error handler.

localizableSupport

protected LocalizableSupport localizableSupport
The localizable support.

line

protected int line
The current line number.

column

protected int column
The current column number.

newlineRead

protected boolean newlineRead
Whether the last character read was a newline.

reader

protected java.io.Reader reader
The current input reader.

current

protected int current
The current character.
Constructor Detail

AbstractParser

public AbstractParser()
Method Detail

getCurrent

public int getCurrent()
Returns the current character value.

setLocale

public void setLocale(java.util.Locale l)
Implements Localizable.setLocale(Locale).
Specified by:
setLocale in interface Localizable
Following copied from interface: org.apache.batik.i18n.Localizable
Parameters:
l - The locale to set.

getLocale

public java.util.Locale getLocale()
Implements Localizable.getLocale().
Specified by:
getLocale in interface Localizable

formatMessage

public java.lang.String formatMessage(java.lang.String key,
                                      java.lang.Object[] args)
                               throws java.util.MissingResourceException
Implements Localizable.formatMessage(String,Object[]).
Specified by:
formatMessage in interface Localizable
Following copied from interface: org.apache.batik.i18n.Localizable
Parameters:
key - The key used to retreive the message from the resource bundle.
args - The objects that compose the message.
Throws:
java.util.MissingResourceException - if the key is not in the bundle.

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.

Specified by:
setErrorHandler in interface Parser
Parameters:
handler - The error handler.

initialize

protected void initialize(java.io.Reader r)
Initializes the parser.

read

protected void read()
Reads one character from the given reader and sets 'current' to this value.

reportError

protected void reportError(java.lang.String key,
                           java.lang.Object[] args)
                    throws ParseException
Signals an error to the error handler.
Parameters:
key - The message key in the resource bundle.
args - The message arguments.

createErrorMessage

protected java.lang.String createErrorMessage(java.lang.String key,
                                              java.lang.Object[] args)
Returns a localized error message.
Parameters:
key - The message key in the resource bundle.
args - The message arguments.

getBundleClassName

protected java.lang.String getBundleClassName()
Returns the resource bundle base name.
Returns:
BUNDLE_CLASSNAME.

skipSpaces

protected void skipSpaces()
Skips the whitespaces in the current reader.

skipCommaSpaces

protected void skipCommaSpaces()
Skips the whitespaces and an optional comma.
Parameters:
r - The parsed reader.


Copyright © 2000 Apache Software Foundation. All Rights Reserved.