Package net.ontopia.xml
Class SAXTracker
- java.lang.Object
-
- org.xml.sax.helpers.DefaultHandler
-
- net.ontopia.xml.SAXTracker
-
- All Implemented Interfaces:
ContentHandler
,DTDHandler
,EntityResolver
,ErrorHandler
- Direct Known Subclasses:
NavigatorConfigurationContentHandler
,PluginContentHandler
,RelationMapping
public abstract class SAXTracker extends DefaultHandler
INTERNAL: A helper base class for SAX applications that makes it much easier to write SAX applications, since it helps applications keep track of the element stack and preserve the contents of various elements.
-
-
Field Summary
Fields Modifier and Type Field Description protected StringBuilder
content
The contents of the current element, or null if not instructed to keep the contents of the current element.protected Set<String>
keepContentsOf
protected Locator
locator
protected Stack<String>
openElements
The stack of currently open elements.
-
Constructor Summary
Constructors Constructor Description SAXTracker()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
characters(char[] chars, int start, int length)
void
endElement(String nsuri, String lname, String qname)
boolean
isParent(String localName)
INTERNAL: Returns true if the parent element has the given name.void
keepContentsOf(String elementName)
INTERNAL: Instructs the tracker to keep the contents of all elements with the given name.void
setDocumentLocator(Locator locator)
void
startElement(String nsuri, String lname, String qname, Attributes attrs)
-
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endDocument, endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warning
-
-
-
-
Field Detail
-
locator
protected Locator locator
-
content
protected StringBuilder content
The contents of the current element, or null if not instructed to keep the contents of the current element.
-
-
Method Detail
-
keepContentsOf
public void keepContentsOf(String elementName)
INTERNAL: Instructs the tracker to keep the contents of all elements with the given name.
-
isParent
public boolean isParent(String localName)
INTERNAL: Returns true if the parent element has the given name.
-
startElement
public void startElement(String nsuri, String lname, String qname, Attributes attrs) throws SAXException
- Specified by:
startElement
in interfaceContentHandler
- Overrides:
startElement
in classDefaultHandler
- Throws:
SAXException
-
characters
public void characters(char[] chars, int start, int length)
- Specified by:
characters
in interfaceContentHandler
- Overrides:
characters
in classDefaultHandler
-
endElement
public void endElement(String nsuri, String lname, String qname) throws SAXException
- Specified by:
endElement
in interfaceContentHandler
- Overrides:
endElement
in classDefaultHandler
- Throws:
SAXException
-
setDocumentLocator
public void setDocumentLocator(Locator locator)
- Specified by:
setDocumentLocator
in interfaceContentHandler
- Overrides:
setDocumentLocator
in classDefaultHandler
-
-