com.mxgraph.util.svg

## Class AbstractParser

- java.lang.Object
- - com.mxgraph.util.svg.AbstractParser

- All Implemented Interfaces:
    Parser
  Direct Known Subclasses:
    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

    Fields
    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 Summary

    Constructors
    Constructor and Description
    `AbstractParser()`

  - ### Method Summary

    Methods
    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.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### BUNDLE_CLASSNAME

          public static final java.lang.String BUNDLE_CLASSNAME

      The default resource bundle base name.
      See Also:
        Constant Field Values

    - #### errorHandler

          protected ErrorHandler errorHandler

      The error handler.

    - #### reader

          protected NormalizingReader reader

      The normalizing reader.

    - #### current

          protected int current

      The current character.

  - ### Constructor Detail

    - #### AbstractParser

          public AbstractParser()

  - ### Method Detail

    - #### getCurrent

          public int getCurrent()

      Returns the current character value.

    - #### 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.

    - #### parse

          public void parse(java.lang.String s)
                     throws ParseException

      Parses the given string.
      Specified by:
        `parse` in interface `Parser`
      Throws:
        `ParseException`

    - #### doParse

          protected abstract void doParse()
                                   throws ParseException,
                                          java.io.IOException

      Method responsible for actually parsing data after AbstractParser has initialized itself.
      Throws:
        `ParseException`
        `java.io.IOException`

    - #### 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.
      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 expected
        `currentChar` - 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

          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()
                             throws java.io.IOException

      Skips the whitespaces in the current reader.
      Throws:
        `java.io.IOException`

    - #### skipCommaSpaces

          protected void skipCommaSpaces()
                                  throws java.io.IOException

      Skips the whitespaces and an optional comma.
      Throws:
        `java.io.IOException`

Copyright (c) 2010 Gaudenz Alder. All rights reserved.