## javanet.staxutils
Class StAXContentHandler

    java.lang.Object
      org.xml.sax.helpers.DefaultHandler
          javanet.staxutils.StAXContentHandler

All Implemented Interfaces:
  ContentHandler, DTDHandler, EntityResolver, ErrorHandler, LexicalHandler

Direct Known Subclasses:
  StAXEventContentHandler, StAXStreamContentHandler

    public abstract class StAXContentHandler

extends DefaultHandler
implements LexicalHandler

Base class for SAX-to-STAX bridge classes that provides common functionality.

Version:
  $Revision: 1.3 $
Author:
  Christian Niles

Field Summary
`protected StringBuffer` `CDATABuffer` Buffer containing text read within the current CDATA section.
`protected Locator` `docLocator` The SAX `Locator`provided to the handler.
`protected boolean` `isCDATA` Whether the parser is currently within a CDATA section.
`protected SimpleNamespaceContext` `namespaces` Stack used to store declared namespaces.
`protected XMLReporter` `reporter` The STAX `XMLReporter`registered to receive notifications.

Constructor Summary
`StAXContentHandler()`
`StAXContentHandler(XMLReporter reporter)`

Method Summary
`void` `characters(char[] ch, int start, int length)`
`void` `comment(char[] ch, int start, int length)`
`void` `endCDATA()`
`void` `endDocument()`
`void` `endDTD()`
`void` `endElement(String uri, String localName, String qName)`
`void` `endEntity(String name)`
`void` `endPrefixMapping(String prefix)`
`void` `error(SAXParseException e)`
`void` `fatalError(SAXParseException e)`
`Location` `getCurrentLocation()` Calculates the STAX `Location`from the SAX `Locator` registered with this handler.
`static void` `parseQName(String qName, String[] results)` Parses an XML qualified name, and places the resulting prefix and local name in the provided String array.
`protected void` `reportException(String type, SAXException e)` Used to report a `SAXException`to the `XMLReporter` registered with this handler.
`void` `setDocumentLocator(Locator locator)`
`void` `setXMLReporter(XMLReporter reporter)` Sets the `XMLReporter`to which warning and error messages will be sent.
`void` `startCDATA()`
`void` `startDocument()`
`void` `startDTD(String name, String publicId, String systemId)`
`void` `startElement(String uri, String localName, String qName, Attributes attributes)`
`void` `startEntity(String name)`
`void` `startPrefixMapping(String prefix, String uri)`
`void` `warning(SAXParseException e)`

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

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

Field Detail

### isCDATA

    protected boolean isCDATA

  Whether the parser is currently within a CDATA section.

### CDATABuffer

    protected StringBuffer CDATABuffer

  Buffer containing text read within the current CDATA section.

### namespaces

    protected SimpleNamespaceContext namespaces

  Stack used to store declared namespaces.

### docLocator

    protected Locator docLocator

  The SAX `Locator`provided to the handler.

### reporter

    protected XMLReporter reporter

  The STAX `XMLReporter`registered to receive notifications.

Constructor Detail

### StAXContentHandler

    public StAXContentHandler()

### StAXContentHandler

    public StAXContentHandler(XMLReporter reporter)

Method Detail

### setXMLReporter

    public void setXMLReporter(XMLReporter reporter)

  Sets the `XMLReporter`to which warning and error messages will be sent.

  Parameters:
    `reporter` - The `XMLReporter`to notify of errors.

### setDocumentLocator

    public void setDocumentLocator(Locator locator)

  Specified by:
    `setDocumentLocator` in interface `ContentHandler`
  Overrides:
    `setDocumentLocator` in class `DefaultHandler`

### getCurrentLocation

    public Location getCurrentLocation()

  Calculates the STAX `Location`from the SAX `Locator` registered with this handler. If no `Locator`was provided, then this method will return `null`.

### error

    public void error(SAXParseException e)
               throws SAXException

  Specified by:
    `error` in interface `ErrorHandler`
  Overrides:
    `error` in class `DefaultHandler`
  Throws:
    `SAXException`

### fatalError

    public void fatalError(SAXParseException e)
                    throws SAXException

  Specified by:
    `fatalError` in interface `ErrorHandler`
  Overrides:
    `fatalError` in class `DefaultHandler`
  Throws:
    `SAXException`

### warning

    public void warning(SAXParseException e)
                 throws SAXException

  Specified by:
    `warning` in interface `ErrorHandler`
  Overrides:
    `warning` in class `DefaultHandler`
  Throws:
    `SAXException`

### startDocument

    public void startDocument()
                       throws SAXException

  Specified by:
    `startDocument` in interface `ContentHandler`
  Overrides:
    `startDocument` in class `DefaultHandler`
  Throws:
    `SAXException`

### endDocument

    public void endDocument()
                     throws SAXException

  Specified by:
    `endDocument` in interface `ContentHandler`
  Overrides:
    `endDocument` in class `DefaultHandler`
  Throws:
    `SAXException`

### startElement

    public void startElement(String uri,
                             String localName,
                             String qName,
                             Attributes attributes)
                      throws SAXException

  Specified by:
    `startElement` in interface `ContentHandler`
  Overrides:
    `startElement` in class `DefaultHandler`
  Throws:
    `SAXException`

### endElement

    public void endElement(String uri,
                           String localName,
                           String qName)
                    throws SAXException

  Specified by:
    `endElement` in interface `ContentHandler`
  Overrides:
    `endElement` in class `DefaultHandler`
  Throws:
    `SAXException`

### startPrefixMapping

    public void startPrefixMapping(String prefix,
                                   String uri)
                            throws SAXException

  Specified by:
    `startPrefixMapping` in interface `ContentHandler`
  Overrides:
    `startPrefixMapping` in class `DefaultHandler`
  Throws:
    `SAXException`

### endPrefixMapping

    public void endPrefixMapping(String prefix)
                          throws SAXException

  Specified by:
    `endPrefixMapping` in interface `ContentHandler`
  Overrides:
    `endPrefixMapping` in class `DefaultHandler`
  Throws:
    `SAXException`

### startCDATA

    public void startCDATA()
                    throws SAXException

  Specified by:
    `startCDATA` in interface `LexicalHandler`
  Throws:
    `SAXException`

### characters

    public void characters(char[] ch,
                           int start,
                           int length)
                    throws SAXException

  Specified by:
    `characters` in interface `ContentHandler`
  Overrides:
    `characters` in class `DefaultHandler`
  Throws:
    `SAXException`

### endCDATA

    public void endCDATA()
                  throws SAXException

  Specified by:
    `endCDATA` in interface `LexicalHandler`
  Throws:
    `SAXException`

### comment

    public void comment(char[] ch,
                        int start,
                        int length)
                 throws SAXException

  Specified by:
    `comment` in interface `LexicalHandler`
  Throws:
    `SAXException`

### endDTD

    public void endDTD()
                throws SAXException

  Specified by:
    `endDTD` in interface `LexicalHandler`
  Throws:
    `SAXException`

### endEntity

    public void endEntity(String name)
                   throws SAXException

  Specified by:
    `endEntity` in interface `LexicalHandler`
  Throws:
    `SAXException`

### startDTD

    public void startDTD(String name,
                         String publicId,
                         String systemId)
                  throws SAXException

  Specified by:
    `startDTD` in interface `LexicalHandler`
  Throws:
    `SAXException`

### startEntity

    public void startEntity(String name)
                     throws SAXException

  Specified by:
    `startEntity` in interface `LexicalHandler`
  Throws:
    `SAXException`

### reportException

    protected void reportException(String type,
                                   SAXException e)
                            throws SAXException

  Used to report a `SAXException`to the `XMLReporter` registered with this handler.

  Throws:
    `SAXException`

### parseQName

    public static final void parseQName(String qName,
                                        String[] results)

  Parses an XML qualified name, and places the resulting prefix and local name in the provided String array.

  Parameters:
    `qName` - The qualified name to parse.
    `results` - An array where parse results will be placed. The prefix will be placed at `results[0]`, and the local part at `results[1]`