# Class SAXNestedTagHandler

java.lang.Object
org.xml.sax.helpers.DefaultHandler
org.apache.cayenne.configuration.xml.SAXNestedTagHandler

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

Direct Known Subclasses:
  `NamespaceAwareNestedTagHandler`

public class SAXNestedTagHandler extends DefaultHandler
A superclass of nested tag handlers for parsing of XML documents with SAX. This class is not namespace aware, i.e. tags like <info:property/> and <property/> will be treated as equal. Use `NamespaceAwareNestedTagHandler` if you need to process namespaces.

Since:
  3.1, 4.1 redesigned and moved from `org.apache.cayenne.configuration` package
See Also:
  - `NamespaceAwareNestedTagHandler`

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected LoaderContext`
  `loaderContext`
  `protected Locator`
  `locator`
  `protected ContentHandler`
  `parentHandler`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `SAXNestedTagHandler(LoaderContext loaderContext)`
  `SAXNestedTagHandler(SAXNestedTagHandler parentHandler)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected void`
  `beforeScopeEnd()`
  Callback method that is called before this handler pushed out of parsers stack.
  `protected ContentHandler`
  `createChildTagHandler(String namespaceURI, String localName, String qName, Attributes attributes)`
  This method should be used to create nested handlers to process children elements.
  `void`
  `endElement(String namespaceURI, String localName, String qName)`
  `ContentHandler`
  `getParentHandler()`
  `protected boolean`
  `processElement(String namespaceURI, String localName, Attributes attributes)`
  Main method to process XML content.
  `void`
  `setDocumentLocator(Locator locator)`
  `void`
  `startElement(String namespaceURI, String localName, String qName, Attributes attributes)`
  This method directly called by SAX parser, do not override it directly, use `processElement(String, String, Attributes)` method instead to process content.
  `protected void`
  `stop()`
  `protected String`
  `unexpectedTagMessage(String tagFound, String... tagsExpected)`

  ### Methods inherited from class DefaultHandler

  `characters, endDocument, endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warning`

  ### Methods inherited from class Object

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

  ### Methods inherited from interface ContentHandler

  `declaration`

- ## Field Details

  - ### loaderContext

    protected LoaderContext loaderContext

  - ### parentHandler

    protected ContentHandler parentHandler

  - ### locator

    protected Locator locator

- ## Constructor Details

  - ### SAXNestedTagHandler

    public SAXNestedTagHandler(LoaderContext loaderContext)

  - ### SAXNestedTagHandler

    public SAXNestedTagHandler(SAXNestedTagHandler parentHandler)

- ## Method Details

  - ### unexpectedTagMessage

    protected String unexpectedTagMessage(String tagFound, String... tagsExpected)

  - ### processElement

    protected boolean processElement(String namespaceURI, String localName, Attributes attributes) throws SAXException
    Main method to process XML content. Should be override in subclasses, by default do nothing. Return value should be true if tag was fully processed and shouldn't be passed down to child handler.
    Parameters:
      `namespaceURI` - namespace for tag
      `localName` - tag local name (i.e. w/o namespace prefix)
      `attributes` - tag attributes
    Returns:
      true if tag was processed
    Throws:
      `SAXException` - can be thrown to abort parsing
    See Also:
      - `createChildTagHandler(String, String, String, Attributes)`

  - ### beforeScopeEnd

    protected void beforeScopeEnd()
    Callback method that is called before this handler pushed out of parsers stack. Can be used to flush some aggregate state.

  - ### createChildTagHandler

    protected ContentHandler createChildTagHandler(String namespaceURI, String localName, String qName, Attributes attributes)
    This method should be used to create nested handlers to process children elements. This method should never return `null`.
    Parameters:
      `namespaceURI` - namespace for tag
      `localName` - tag local name (i.e. w/o namespace prefix)
      `qName` - tag full name (i.e. with namespace prefix)
      `attributes` - tag attributes
    Returns:
      new handler to process child tag

  - ### stop

    protected void stop()

  - ### startElement

    public void startElement(String namespaceURI, String localName, String qName, Attributes attributes) throws SAXException
    This method directly called by SAX parser, do not override it directly, use `processElement(String, String, Attributes)` method instead to process content.
    Specified by:
      `startElement` in interface `ContentHandler`
    Overrides:
      `startElement` in class `DefaultHandler`
    Throws:
      `SAXException`
    See Also:
      - `createChildTagHandler(String, String, String, Attributes)`

  - ### endElement

    public void endElement(String namespaceURI, String localName, String qName) throws SAXException
    Specified by:
      `endElement` in interface `ContentHandler`
    Overrides:
      `endElement` in class `DefaultHandler`
    Throws:
      `SAXException`

  - ### setDocumentLocator

    public void setDocumentLocator(Locator locator)
    Specified by:
      `setDocumentLocator` in interface `ContentHandler`
    Overrides:
      `setDocumentLocator` in class `DefaultHandler`

  - ### getParentHandler

    public ContentHandler getParentHandler()