Package org.apache.batik.parser
Class AbstractParser
java.lang.Object
org.apache.batik.parser.AbstractParser
- All Implemented Interfaces:
Localizable
,Parser
- Direct Known Subclasses:
LengthParser
,NumberParser
,PreserveAspectRatioParser
,TimingParser
This class is the superclass of all parsers. It provides localization
and error handling methods.
- Version:
- $Id: AbstractParser.java 1802297 2017-07-18 13:58:12Z ssteiner $
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
The default resource bundle base name.protected int
The current character.protected ErrorHandler
The error handler.protected LocalizableSupport
The localizable support.protected NormalizingReader
The normalizing reader. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected String
createErrorMessage
(String key, Object[] args) Returns a localized error message.protected abstract void
doParse()
Method responsible for actually parsing data after AbstractParser has initialized itself.formatMessage
(String key, Object[] args) ImplementsLocalizable.formatMessage(String,Object[])
.protected String
Returns the resource bundle base name.int
Returns the current character value.ImplementsLocalizable.getLocale()
.void
parse
(InputStream is, String enc) Parses the given input stream.void
Parses the given readervoid
Parses the given string.protected void
reportCharacterExpectedError
(char expectedChar, int currentChar) simple api to call often reported error.protected void
reportError
(String key, 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.void
ImplementsLocalizable.setLocale(Locale)
.protected void
Skips the whitespaces and an optional comma.protected void
Skips the whitespaces in the current reader.
-
Field Details
-
BUNDLE_CLASSNAME
The default resource bundle base name.- See Also:
-
errorHandler
The error handler. -
localizableSupport
The localizable support. -
reader
The normalizing reader. -
current
protected int currentThe current character.
-
-
Constructor Details
-
AbstractParser
public AbstractParser()
-
-
Method Details
-
getCurrent
public int getCurrent()Returns the current character value. -
setLocale
ImplementsLocalizable.setLocale(Locale)
.- Specified by:
setLocale
in interfaceLocalizable
- Parameters:
l
- The locale to set.
-
getLocale
ImplementsLocalizable.getLocale()
.- Specified by:
getLocale
in interfaceLocalizable
-
formatMessage
ImplementsLocalizable.formatMessage(String,Object[])
.- Specified by:
formatMessage
in interfaceLocalizable
- Parameters:
key
- The key used to retreive the message from the resource bundle.args
- The objects that compose the message.- Throws:
MissingResourceException
- if the key is not in the bundle.
-
setErrorHandler
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 interfaceParser
- Parameters:
handler
- The error handler.
-
parse
Parses the given reader- Specified by:
parse
in interfaceParser
- Throws:
ParseException
-
parse
Parses the given input stream. If the encoding is null, ISO-8859-1 is used.- Throws:
ParseException
-
parse
Parses the given string.- Specified by:
parse
in interfaceParser
- Throws:
ParseException
-
doParse
Method responsible for actually parsing data after AbstractParser has initialized itself.- Throws:
ParseException
IOException
-
reportError
Signals an error to the error handler.- Parameters:
key
- The message key in the resource bundle.args
- The message arguments.- Throws:
ParseException
-
reportCharacterExpectedError
protected void reportCharacterExpectedError(char expectedChar, int currentChar) simple api to call often reported error. Just a wrapper for reportError().- Parameters:
expectedChar
- what caller expectedcurrentChar
- what caller found
-
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
-
createErrorMessage
Returns a localized error message.- Parameters:
key
- The message key in the resource bundle.args
- The message arguments.
-
getBundleClassName
Returns the resource bundle base name.- Returns:
- BUNDLE_CLASSNAME.
-
skipSpaces
Skips the whitespaces in the current reader.- Throws:
IOException
-
skipCommaSpaces
Skips the whitespaces and an optional comma.- Throws:
IOException
-