|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.xml.sax.helpers.DefaultHandler
com.aliasi.xml.SimpleElementHandler
com.aliasi.xml.SAXFilterHandler
com.aliasi.xml.ElementStackFilter
public class ElementStackFilter
Provides a SAX filter that maintains a stack of elements visited.
The qualified name of the current element and attributes are
available through 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.
| Field Summary |
|---|
| Fields inherited from class com.aliasi.xml.SAXFilterHandler |
|---|
mHandler |
| Fields inherited from class com.aliasi.xml.SimpleElementHandler |
|---|
CDATA_ATTS_TYPE, EMPTY_ATTS, NO_OP_DEFAULT_HANDLER |
| Constructor Summary | |
|---|---|
ElementStackFilter()
Construct an element stack filter without a specified handler to which to delegate events. |
|
ElementStackFilter(DefaultHandler handler)
Construct an element stack filter that delegates events to the specified handler. |
|
| Method Summary | |
|---|---|
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. |
| Methods inherited from class com.aliasi.xml.SAXFilterHandler |
|---|
characters, endDocument, endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, setHandler, skippedEntity, startPrefixMapping, unparsedEntityDecl, warning |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ElementStackFilter(DefaultHandler handler)
SAXFilterHandler.setHandler(DefaultHandler).
handler - Handler to which events are delegated.public ElementStackFilter()
SAXFilterHandler.setHandler(DefaultHandler).
| Method Detail |
|---|
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.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||