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
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:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected LoaderContext
protected Locator
protected ContentHandler
-
Constructor Summary
ConstructorsConstructorDescriptionSAXNestedTagHandler
(LoaderContext loaderContext) SAXNestedTagHandler
(SAXNestedTagHandler parentHandler) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
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) 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, useprocessElement(String, String, Attributes)
method instead to process content.protected void
stop()
protected String
unexpectedTagMessage
(String tagFound, String... tagsExpected) Methods inherited from class org.xml.sax.helpers.DefaultHandler
characters, endDocument, endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warning
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.xml.sax.ContentHandler
declaration
-
Field Details
-
loaderContext
-
parentHandler
-
locator
-
-
Constructor Details
-
SAXNestedTagHandler
-
SAXNestedTagHandler
-
-
Method Details
-
unexpectedTagMessage
-
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 taglocalName
- 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:
-
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 returnnull
.- Parameters:
namespaceURI
- namespace for taglocalName
- 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, useprocessElement(String, String, Attributes)
method instead to process content.- Specified by:
startElement
in interfaceContentHandler
- Overrides:
startElement
in classDefaultHandler
- Throws:
SAXException
- See Also:
-
endElement
- Specified by:
endElement
in interfaceContentHandler
- Overrides:
endElement
in classDefaultHandler
- Throws:
SAXException
-
setDocumentLocator
- Specified by:
setDocumentLocator
in interfaceContentHandler
- Overrides:
setDocumentLocator
in classDefaultHandler
-
getParentHandler
-