org.codehaus.staxmate.in
Class SMHierarchicCursor
java.lang.Object
org.codehaus.staxmate.in.SMInputCursor
org.codehaus.staxmate.in.SMHierarchicCursor
public class SMHierarchicCursor
- extends SMInputCursor
Default implementation of generic nested (scoped) cursor; cursor that only
traverses direct children of a single start element.
- Author:
- Tatu Saloranta
| Fields inherited from class org.codehaus.staxmate.in.SMInputCursor |
mBaseDepth, mChildCursor, mCurrEvent, mData, mElemCount, mElemInfoFactory, mElemTracking, mFilter, mNodeCount, mParentTrackedElement, mState, mStreamReader, mTrackedElement, sEventsByIds |
| Methods inherited from class org.codehaus.staxmate.in.SMInputCursor |
childCursor, childCursor, childElementCursor, childElementCursor, childElementCursor, childMixedCursor, collectDescendantText, constructElementInfo, currentEventStr, descendantCursor, descendantCursor, descendantElementCursor, descendantElementCursor, descendantElementCursor, descendantMixedCursor, doParseInt, doParseInt, findAttrIndex, getAttrCount, getAttrIntValue, getAttrIntValue, getAttrIntValue, getAttrIntValue, getAttrLocalName, getAttrName, getAttrNsUri, getAttrPrefix, getAttrValue, getAttrValue, getAttrValue, getBaseParentCount, getCurrEvent, getCurrEventCode, getData, getDepth, getElementCount, getElementInfoFactory, getElementTracking, getLocalName, getLocation, getNodeCount, getNsUri, getParentTrackedElement, getPrefix, getPrefixedName, getQName, getStateDesc, getStreamReader, getText, getTrackedElement, hasLocalName, hasName, invalidate, isRootCursor, notAccessible, processDescendantText, readerAccessible, rewindPastChild, setData, setElementInfoFactory, setElementTracking, setFilter, throwUnexpectedEndDoc, throwWrongEndElem, throwXsEx, toString |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
SMHierarchicCursor
public SMHierarchicCursor(SMInputCursor parent,
org.codehaus.stax2.XMLStreamReader2 sr,
SMFilter f)
getParentCount
public int getParentCount()
- Description copied from class:
SMInputCursor
- Number of parent elements that the token/event cursor points to has,
if it points to one. If not, either most recent valid parent
count (if cursor is closed), or the depth that it will have
once is is advanced. One practical result is that a nested
cursor instance will always have a single constant value it
returns, whereas flattening cursors can return different
values during traversal. Another thing to notice that matching
START_ELEMENT and END_ELEMENT will always correspond to the
same parent count.
For example, here are expected return values
for an example XML document:
<!-- Comment outside tree --> [0]
<root> [0]
Text [1]
<branch> [1]
Inner text [2]
<child /> [2]/[2]
</branch> [1]
</root> [0]
Numbers in bracket are depths that would be returned when the
cursor points to the node.
Note: depths are different from what many other xml processing
APIs (such as Stax and XmlPull)return.
- Specified by:
getParentCount in class SMInputCursor
- Returns:
- Number of enclosing nesting levels, ie. number of parent
start elements for the node that cursor currently points to (or,
in case of initial state, that it will point to if scope has
node(s)).
getNext
public SMEvent getNext()
throws javax.xml.stream.XMLStreamException
- Description copied from class:
SMInputCursor
- Main iterating method.
- Specified by:
getNext in class SMInputCursor
- Returns:
- Type of event (from
XMLStreamConstants, such as
XMLStreamConstants.START_ELEMENT, if a new node was
iterated over; null when there are no more
nodes this cursor can iterate over.
- Throws:
javax.xml.stream.XMLStreamException
constructChildCursor
public SMInputCursor constructChildCursor(SMFilter f)
- Specified by:
constructChildCursor in class SMInputCursor
constructDescendantCursor
public SMInputCursor constructDescendantCursor(SMFilter f)
- Specified by:
constructDescendantCursor in class SMInputCursor
skipToEndElement
protected void skipToEndElement()
throws javax.xml.stream.XMLStreamException
- Method called when current event/token is START_ELEMENT, but
we are not interested in its contents (children). Hence, needs
to skip all intervening events/tokens until matching END_ELEMENT
is encountered.
- Throws:
javax.xml.stream.XMLStreamException