Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.eclipse.birt.core.framework.parser
Class XMLParserHandler

    java.lang.Object
      org.xml.sax.helpers.DefaultHandler
          org.eclipse.birt.core.framework.parser.XMLParserHandler

All Implemented Interfaces:
  org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler

    public abstract class XMLParserHandler

extends org.xml.sax.helpers.DefaultHandler

Framework for parsing an XML file using a SAX parser. This framework provides a separate class for each element. These classes are called "state" classes because they represent the state of the parser. Generally, a state represents some object being created. This handler manages the stack of active states, and routes the SAX callbacks to the current state.

See Also:
  `AbstractParseState`, `AnyElementState`, `XMLParserHandler.InnerParseState`, `XMLParserException`

Nested Class Summary
`class` | `XMLParserHandler.InnerAnyTagState` Parses any valid XML; handles unimplemented tags.
`class` | `XMLParserHandler.InnerParseState` Base class provides the parse state framework.

Field Summary
`protected java.lang.String` | `currentElement` The current element being parsed.
`protected java.util.ArrayList` | `errors` The list contains errors encountered when parsing a XML file.
`protected org.xml.sax.Locator` | `locator` SAX `Locator` for reporting errors.
`protected java.util.Stack` | `stateStack` Stack of active parse states.

Constructor Summary
`XMLParserHandler()` Constructor

Method Summary
`void` | `characters(char[] ch, int start, int length)`
`abstract AbstractParseState` | `createStartState()` Parser handlers must implement this method to return the "start state": the state that will recognize the top-level element(s) in the XML file.
`void` | `endDocument()`
`void` | `endElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName)` Ends the parse state for an element.
`void` | `error(org.xml.sax.SAXParseException e)`
`void` | `fatalError(org.xml.sax.SAXParseException e)`
`java.util.List` | `getErrors()` Returns the error list when parsing xml file.
`protected void` | `pushState(AbstractParseState state)` Private method to add a parse state to the state stack.
`void` | `semanticError(java.lang.Exception e)` Add a recoverable semantic error to the error list.
`abstract void` | `semanticError(XMLParserException e)` Add a recoverable semantic error to the error list.
`void` | `setDocumentLocator(org.xml.sax.Locator theLocator)`
`void` | `startDocument()`
`void` | `startElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes atts)` Starts an XML element.
`protected AbstractParseState` | `topState()` Private method to return the top of the state stack.
`void` | `warning(org.xml.sax.SAXParseException e)`

Methods inherited from class org.xml.sax.helpers.DefaultHandler
`endPrefixMapping, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, skippedEntity, startPrefixMapping, unparsedEntityDecl`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### currentElement

    protected java.lang.String currentElement

  The current element being parsed.

### stateStack

    protected java.util.Stack stateStack

  Stack of active parse states. Corresponds to the stack of currently active elements.

### locator

    protected org.xml.sax.Locator locator

  SAX `Locator` for reporting errors.

### errors

    protected java.util.ArrayList errors

  The list contains errors encountered when parsing a XML file.

Constructor Detail

### XMLParserHandler

    public XMLParserHandler()

  Constructor

Method Detail

### startDocument

    public void startDocument()
                       throws org.xml.sax.SAXException

  Specified by:
    `startDocument` in interface `org.xml.sax.ContentHandler`
  Overrides:
    `startDocument` in class `org.xml.sax.helpers.DefaultHandler`
  Throws:
    `org.xml.sax.SAXException`

### endDocument

    public void endDocument()
                     throws org.xml.sax.SAXException

  Specified by:
    `endDocument` in interface `org.xml.sax.ContentHandler`
  Overrides:
    `endDocument` in class `org.xml.sax.helpers.DefaultHandler`
  Throws:
    `org.xml.sax.SAXException`

### semanticError

    public void semanticError(java.lang.Exception e)

  Add a recoverable semantic error to the error list.

  Parameters:
    `e` - The exception to log.

### semanticError

    public abstract void semanticError(XMLParserException e)

  Add a recoverable semantic error to the error list.

  Parameters:
    `e` - The exception to log.

### pushState

    protected void pushState(AbstractParseState state)

  Private method to add a parse state to the state stack.

  Parameters:
    `state` - the state to push

### topState

    protected AbstractParseState topState()

  Private method to return the top of the state stack.

  Returns:
    the state at the top of the state stack

### startElement

    public void startElement(java.lang.String namespaceURI,
                             java.lang.String localName,
                             java.lang.String qName,
                             org.xml.sax.Attributes atts)
                      throws org.xml.sax.SAXException

  Starts an XML element. Delegates to the current state the task of creating a new parse state for the new element.

  Specified by:
    `startElement` in interface `org.xml.sax.ContentHandler`
  Overrides:
    `startElement` in class `org.xml.sax.helpers.DefaultHandler`
  Throws:
    `org.xml.sax.SAXException`
  See Also:
    `ContentHandler.startElement(String, String, String, Attributes)`

### endElement

    public void endElement(java.lang.String namespaceURI,
                           java.lang.String localName,
                           java.lang.String qName)
                    throws org.xml.sax.SAXException

  Ends the parse state for an element.

  Specified by:
    `endElement` in interface `org.xml.sax.ContentHandler`
  Overrides:
    `endElement` in class `org.xml.sax.helpers.DefaultHandler`
  Throws:
    `org.xml.sax.SAXException`
  See Also:
    `ContentHandler.endElement(String, String, String)`

### characters

    public void characters(char[] ch,
                           int start,
                           int length)
                    throws org.xml.sax.SAXException

  Specified by:
    `characters` in interface `org.xml.sax.ContentHandler`
  Overrides:
    `characters` in class `org.xml.sax.helpers.DefaultHandler`
  Throws:
    `org.xml.sax.SAXException`
  See Also:
    `ContentHandler.characters(char[], int, int)`

### createStartState

    public abstract AbstractParseState createStartState()

  Parser handlers must implement this method to return the "start state": the state that will recognize the top-level element(s) in the XML file.

  Returns:
    the start state specific to the derived parser

### setDocumentLocator

    public void setDocumentLocator(org.xml.sax.Locator theLocator)

  Specified by:
    `setDocumentLocator` in interface `org.xml.sax.ContentHandler`
  Overrides:
    `setDocumentLocator` in class `org.xml.sax.helpers.DefaultHandler`

### error

    public void error(org.xml.sax.SAXParseException e)
               throws org.xml.sax.SAXException

  Specified by:
    `error` in interface `org.xml.sax.ErrorHandler`
  Overrides:
    `error` in class `org.xml.sax.helpers.DefaultHandler`
  Throws:
    `org.xml.sax.SAXException`

### warning

    public void warning(org.xml.sax.SAXParseException e)
                 throws org.xml.sax.SAXException

  Specified by:
    `warning` in interface `org.xml.sax.ErrorHandler`
  Overrides:
    `warning` in class `org.xml.sax.helpers.DefaultHandler`
  Throws:
    `org.xml.sax.SAXException`

### fatalError

    public void fatalError(org.xml.sax.SAXParseException e)
                    throws org.xml.sax.SAXException

  Specified by:
    `fatalError` in interface `org.xml.sax.ErrorHandler`
  Overrides:
    `fatalError` in class `org.xml.sax.helpers.DefaultHandler`
  Throws:
    `org.xml.sax.SAXException`

### getErrors

    public java.util.List getErrors()

  Returns the error list when parsing xml file.

  Returns:
    the errors

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2008 Actuate Corp. All rights reserved.