org.codehaus.staxmate.in
Class SMHierarchicCursor

java.lang.Object
  extended by org.codehaus.staxmate.in.SMInputCursor
      extended by 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

Nested Class Summary
 
Nested classes/interfaces inherited from class org.codehaus.staxmate.in.SMInputCursor
SMInputCursor.State, SMInputCursor.Tracking
 
Field Summary
 
Fields inherited from class org.codehaus.staxmate.in.SMInputCursor
mChildCursor, mCurrEvent, mData, mElemCount, mElemInfoFactory, mElemTracking, mFilter, mNodeCount, mParentCount, mParentTrackedElement, mState, mStreamReader, mTrackedElement, sEventsByIds
 
Constructor Summary
SMHierarchicCursor(SMInputCursor parent, org.codehaus.stax2.XMLStreamReader2 sr, SMFilter f)
           
 
Method Summary
 SMInputCursor constructChildCursor(SMFilter f)
           
 SMInputCursor constructDescendantCursor(SMFilter f)
           
 int getDepth()
          Returns number of parent elements current node (or, the last node cursor pointed to, or in absence of one [before cursor has been advanced for the first time], it would point if advanced) has.
 SMEvent getNext()
          Main iterating method.
protected  void skipTree()
          Method called by the parent cursor, to skip over the scope this cursor iterates, and of its sub-scopes if any.
 
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, getCurrEvent, getCurrEventCode, getData, getElementCount, getElementInfoFactory, getElementTracking, getLocalName, getLocation, getNodeCount, getNsUri, getParentTrackedElement, getPrefix, getPrefixedName, getQName, getStateDesc, getStreamReader, getText, getTrackedElement, isRootCursor, notAccessible, processDescendantText, readerAccessible, setData, setElementInfoFactory, setElementTracking, setFilter, skipSubTree, throwXsEx, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SMHierarchicCursor

public SMHierarchicCursor(SMInputCursor parent,
                          org.codehaus.stax2.XMLStreamReader2 sr,
                          SMFilter f)
Method Detail

getDepth

public int getDepth()
Description copied from class: SMInputCursor
Returns number of parent elements current node (or, the last node cursor pointed to, or in absence of one [before cursor has been advanced for the first time], it would point if advanced) has.

For example, here are expected results for getDepth() for an example XML document:

  <!-- Comment outside tree --> [0]
  <root> [0]
    Text [1]
    <branch> [1]
      Inner text [2]
      <child /> [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 some APIs (such as XmlPull) return.

Specified by:
getDepth 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

skipTree

protected void skipTree()
                 throws javax.xml.stream.XMLStreamException
Description copied from class: SMInputCursor
Method called by the parent cursor, to skip over the scope this cursor iterates, and of its sub-scopes if any.

Specified by:
skipTree in class SMInputCursor
Throws:
javax.xml.stream.XMLStreamException