public class ElementStackFilter extends SAXFilterHandler
currentElement() and currentAttributes() respectively.
The implementation uses Attributes2Impl to copy the
attributes from each element. This defends against the policy of
some SAX parsers to re-use elements.
mHandlerCDATA_ATTS_TYPE, EMPTY_ATTS, NO_OP_DEFAULT_HANDLER| Constructor and Description |
|---|
ElementStackFilter()
Construct an element stack filter without a specified
handler to which to delegate events.
|
ElementStackFilter(org.xml.sax.helpers.DefaultHandler handler)
Construct an element stack filter that delegates
events to the specified handler.
|
| Modifier and Type | Method and Description |
|---|---|
Attributes |
currentAttributes()
Returns the attributes as specified for the current containing
element.
|
String |
currentElement()
Returns the qualified name of the current containing element's
qualified name.
|
void |
endElement(String namespaceURI,
String localName,
String qName)
End the specified element, popping its qualified name
and attributes off the stack, and delegating the SAX event
to the contained handler.
|
List<Attributes> |
getAttributesStack()
Returns an unmodifiable view of the stack of attributes
associated with the stack of elements.
|
List<String> |
getElementStack()
Returns an unmodifiable view of the stack of qualified names of
elements.
|
boolean |
noElement()
Returns
true if there are no elements in the stack. |
void |
startDocument()
Start the document, clearing the element stack
and delegating the start document even to the contained
handler.
|
void |
startElement(String namespaceURI,
String localName,
String qName,
Attributes atts)
Start the specified element, adding its qualified name
and attributes to the stack, and delegating the SAX event
to the contained handler.
|
characters, endDocument, endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, setHandler, skippedEntity, startPrefixMapping, unparsedEntityDecl, warningaddSimpleAttribute, characters, characters, characters, characters, createAttributes, createAttributes, createAttributes, createAttributes, createAttributes, createAttributes, endSimpleElement, endSimpleElement, startEndSimpleElement, startEndSimpleElement, startSimpleElement, startSimpleElement, startSimpleElement, startSimpleElement, startSimpleElement, startSimpleElement, startSimpleElementpublic ElementStackFilter(org.xml.sax.helpers.DefaultHandler handler)
SAXFilterHandler.setHandler(DefaultHandler).handler - Handler to which events are delegated.public ElementStackFilter()
SAXFilterHandler.setHandler(DefaultHandler).public List<String> getElementStack()
The elements are indexed from the bottom of the stack
to the top. So getElementStack().size()-1 is
the index of the top of a non-empty stack, and 0
is the index of the bottom of a non-empty stack.
See getAttributesStack() for
a method to return the corresponding attributes for the elements.
public List<Attributes> getAttributesStack()
The members of this stack are implementations of
the XML SAX Attributes interface.
The elements are indexed from the bottom of the stack
to the top. So getAttributesStack().size()-1 is
the index of the top of a non-empty stack, and 0
is the index of the bottom of a non-empty stack.
See getElementStack()
to get a parallel stack of qualified element names.
public void startDocument()
throws SAXException
startDocument in interface ContentHandlerstartDocument in class SAXFilterHandlerSAXException - If there is an exception raised by the
contained handler.public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException
startElement in interface ContentHandlerstartElement in class SAXFilterHandlernamespaceURI - The URI of the namespace for this element.localName - The local name (without prefix) for this
element.qName - The qualified name (with prefix, if any) for this
element.atts - The attributes for this element.SAXException - If there is an exception raised by the
contained handler.public void endElement(String namespaceURI, String localName, String qName) throws SAXException
endElement in interface ContentHandlerendElement in class SAXFilterHandlernamespaceURI - The URI of the namespace for this element.localName - The local name (without prefix) for this
element.qName - The qualified name (with prefix, if any) for this
element.SAXException - If there is an exception raised by the
contained handler.public boolean noElement()
true if there are no elements in the stack.
Should only return true outside of the top-level
element.true if there are no elements in the stack.public String currentElement()
EmptyStackException - If there is no containing element.public Attributes currentAttributes()
EmptyStackException - If there is no containing element.Copyright © 2016 Alias-i, Inc.. All rights reserved.