Package org.codehaus.staxmate.in
Class SMHierarchicCursor
java.lang.Object
org.codehaus.staxmate.in.CursorBase
org.codehaus.staxmate.in.SMInputCursor
org.codehaus.staxmate.in.SMHierarchicCursor
Default implementation of generic nested (scoped) cursor; cursor that only
traverses direct children of a single start element.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.codehaus.staxmate.in.SMInputCursor
SMInputCursor.Tracking
Nested classes/interfaces inherited from class org.codehaus.staxmate.in.CursorBase
CursorBase.State
-
Field Summary
Fields inherited from class org.codehaus.staxmate.in.SMInputCursor
mData, mElemInfoFactory, mElemTracking, mFilter
Fields inherited from class org.codehaus.staxmate.in.CursorBase
_baseDepth, _childCursor, _context, _currEvent, _elemCount, _nodeCount, _parentTrackedElement, _state, _streamReader, _trackedElement
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAbstract method that concrete sub-classes implement, and is used for all instantiation of child cursors by this cursor instance.Abstract method that concrete sub-classes implement, and is used for all instantiation of descendant cursors by this cursor instance.getNext()
Main iterating method.int
Number of parent elements that the token/event cursor points to has, if it points to one.protected void
Method called when current event/token is START_ELEMENT, but we are not interested in its contents (children).Methods inherited from class org.codehaus.staxmate.in.SMInputCursor
_markConsumed, advance, asEvent, childCursor, childCursor, childElementCursor, childElementCursor, childElementCursor, childMixedCursor, collectDescendantText, collectDescendantText, constructElementInfo, constructStreamException, descendantCursor, descendantCursor, descendantElementCursor, descendantElementCursor, descendantElementCursor, descendantMixedCursor, findAttrIndex, getAttrBinaryValue, getAttrBinaryValue, getAttrBooleanValue, getAttrBooleanValue, getAttrCount, getAttrDoubleValue, getAttrDoubleValue, getAttrEnumValue, getAttrIntValue, getAttrIntValue, getAttrIntValue, getAttrIntValue, getAttrLocalName, getAttrLongValue, getAttrLongValue, getAttrName, getAttrNsUri, getAttrPrefix, getAttrValue, getAttrValue, getAttrValue, getCurrEvent, getCurrEventCode, getCurrEventDesc, getCursorLocation, getData, getElemBinaryValue, getElemBinaryValue, getElemBooleanValue, getElemBooleanValue, getElemDoubleValue, getElemDoubleValue, getElementCount, getElementInfoFactory, getElementTracking, getElemEnumValue, getElemIntValue, getElemIntValue, getElemLongValue, getElemLongValue, getElemStringValue, getLocalName, getLocation, getNodeCount, getNsUri, getParentTrackedElement, getPathDesc, getPrefix, getPrefixedName, getQName, getStreamLocation, getStreamReader, getText, getTrackedElement, hasLocalName, hasName, hasName, isRootCursor, processDescendantText, readerAccessible, setData, setElementInfoFactory, setElementTracking, setFilter, throwStreamException, toString
Methods inherited from class org.codehaus.staxmate.in.CursorBase
_constructTypedException, _getStreamReader, _notAccessible, _throwUnexpectedEndDoc, _throwWrongEndElem, _wrongState, currentEventStr, eventObjectByEventId, getBaseParentCount, getStateDesc, invalidate, rewindPastChild
-
Constructor Details
-
SMHierarchicCursor
-
-
Method Details
-
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 classSMInputCursor
- 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
Description copied from class:SMInputCursor
Main iterating method. Will try to advance the cursor to the next visible event (visibility defined by the filter cursor is configured with, if any), and return event type. If no such events are available, will return null.Note that one side-effect of calling this method is to invalidate the child cursor, if one was active. This is done by iterating over any events child cursor (and its descendants if any) might expose.
- Specified by:
getNext
in classSMInputCursor
- Returns:
- Type of event (from
XMLStreamConstants
, such asXMLStreamConstants.START_ELEMENT
, if a new node was iterated over;null
when there are no more nodes this cursor can iterate over. - Throws:
XMLStreamException
- If there are underlying parsing problems.
-
constructChildCursor
Description copied from class:SMInputCursor
Abstract method that concrete sub-classes implement, and is used for all instantiation of child cursors by this cursor instance.Note that custom cursor implementations can be used by overriding this method.
- Specified by:
constructChildCursor
in classSMInputCursor
-
constructDescendantCursor
Description copied from class:SMInputCursor
Abstract method that concrete sub-classes implement, and is used for all instantiation of descendant cursors by this cursor instance.Note that custom cursor implementations can be used by overriding this method.
- Specified by:
constructDescendantCursor
in classSMInputCursor
-
skipToEndElement
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:
XMLStreamException
-