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. UseNamespaceAwareNestedTagHandlerif you need to process namespaces.- Since:
- 3.1, 4.1 redesigned and moved from
org.apache.cayenne.configurationpackage - See Also:
NamespaceAwareNestedTagHandler
-
-
Field Summary
Fields Modifier and Type Field Description protected LoaderContextloaderContextprotected Locatorlocatorprotected ContentHandlerparentHandler
-
Constructor Summary
Constructors Constructor Description SAXNestedTagHandler(LoaderContext loaderContext)SAXNestedTagHandler(SAXNestedTagHandler parentHandler)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidbeforeScopeEnd()Callback method that is called before this handler pushed out of parsers stack.protected ContentHandlercreateChildTagHandler(String namespaceURI, String localName, String qName, Attributes attributes)This method should be used to create nested handlers to process children elements.voidendElement(String namespaceURI, String localName, String qName)ContentHandlergetParentHandler()protected booleanprocessElement(String namespaceURI, String localName, Attributes attributes)Main method to process XML content.voidsetDocumentLocator(Locator locator)voidstartElement(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 voidstop()protected StringunexpectedTagMessage(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
-
-
-
-
Field Detail
-
loaderContext
protected LoaderContext loaderContext
-
parentHandler
protected ContentHandler parentHandler
-
locator
protected Locator locator
-
-
Constructor Detail
-
SAXNestedTagHandler
public SAXNestedTagHandler(LoaderContext loaderContext)
-
SAXNestedTagHandler
public SAXNestedTagHandler(SAXNestedTagHandler parentHandler)
-
-
Method Detail
-
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 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:
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 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:
startElementin interfaceContentHandler- Overrides:
startElementin classDefaultHandler- Throws:
SAXException- See Also:
createChildTagHandler(String, String, String, Attributes)
-
endElement
public void endElement(String namespaceURI, String localName, String qName) throws SAXException
- Specified by:
endElementin interfaceContentHandler- Overrides:
endElementin classDefaultHandler- Throws:
SAXException
-
setDocumentLocator
public void setDocumentLocator(Locator locator)
- Specified by:
setDocumentLocatorin interfaceContentHandler- Overrides:
setDocumentLocatorin classDefaultHandler
-
getParentHandler
public ContentHandler getParentHandler()
-
-