Package org.dellroad.stuff.xml
Class StackXMLEventReader
java.lang.Object
javax.xml.stream.util.EventReaderDelegate
org.dellroad.stuff.xml.StackXMLEventReader
- All Implemented Interfaces:
- Iterator<Object>,- XMLEventReader
Wrapper for a 
XMLEventReader that keeps track of the current element(s) being parsed as a stack
 of StartElement events.
 
 Each time a StartElement is read from the underlying XMLEventReader, it is pushed onto
 the stack; each time a EndElement is read from the underlying XMLEventReader,
 the previously push StartElement is popped off.
 
 Invocations of EventReaderDelegate.peek() do not affect the element stack.
 
 If an XMLStreamException is thrown at any point, the element stack is no longer guaranteed to track properly.
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionprotected XMLEventAdjust the stack after reading the given event.Get the entire stack ofStartElements.Get the top-mostStartElementevent on the stack.next()nextTag()Methods inherited from class javax.xml.stream.util.EventReaderDelegateclose, getParent, getProperty, hasNext, peek, remove, setParentMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.IteratorforEachRemaining
- 
Constructor Details- 
StackXMLEventReaderConstructor.- Parameters:
- reader- underlying reader
- Throws:
- IllegalArgumentException- if- readeris null
 
 
- 
- 
Method Details- 
getTopElementGet the top-mostStartElementevent on the stack. This corresponds to the innermost XML element currently being read.- Returns:
- current element, or null if the current parse position is outside of the document element
 
- 
getElementStackGet the entire stack ofStartElements.A copy is returned; changes to the returned list do not affect this instance. - Returns:
- element stack; the first element in the list is the document element
 
- 
getElementText- Specified by:
- getElementTextin interface- XMLEventReader
- Overrides:
- getElementTextin class- EventReaderDelegate
- Throws:
- XMLStreamException
 
- 
next- Specified by:
- nextin interface- Iterator<Object>
- Overrides:
- nextin class- EventReaderDelegate
 
- 
nextEvent- Specified by:
- nextEventin interface- XMLEventReader
- Overrides:
- nextEventin class- EventReaderDelegate
- Throws:
- XMLStreamException
 
- 
nextTag- Specified by:
- nextTagin interface- XMLEventReader
- Overrides:
- nextTagin class- EventReaderDelegate
- Throws:
- XMLStreamException
 
- 
adjustAdjust the stack after reading the given event.- Parameters:
- event- newly read event
- Returns:
- event
 
 
-