Package org.codehaus.staxmate.in
Class SMFlatteningCursor
- java.lang.Object
-
- org.codehaus.staxmate.in.CursorBase
-
- org.codehaus.staxmate.in.SMInputCursor
-
- org.codehaus.staxmate.in.SMFlatteningCursor
-
public class SMFlatteningCursor extends SMInputCursor
Default implementation of generic flat (non-scoped) cursor; cursor that traverse all descendants (children and grandchildren) of a start element.Differences to
SMHierarchicCursor
are:- Flat cursors return
XMLStreamConstants.END_ELEMENT
nodes (except for the one that closes the outermost level), unless filtered out by the filter, whereas the nested cursor automatically leaves those out. - Flat cursors can not have child/descendant cursors
- Flat cursors return
-
-
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 Constructor Description SMFlatteningCursor(SMInputContext ctxt, SMInputCursor parent, SMFilter f)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SMInputCursor
constructChildCursor(SMFilter f)
Abstract method that concrete sub-classes implement, and is used for all instantiation of child cursors by this cursor instance.SMInputCursor
constructDescendantCursor(SMFilter f)
Abstract method that concrete sub-classes implement, and is used for all instantiation of descendant cursors by this cursor instance.SMEvent
getNext()
Main iterating method.int
getParentCount()
Number of parent elements that the token/event cursor points to has, if it points to one.-
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 Detail
-
SMFlatteningCursor
public SMFlatteningCursor(SMInputContext ctxt, SMInputCursor parent, SMFilter f)
-
-
Method Detail
-
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
public SMEvent getNext() throws javax.xml.stream.XMLStreamException
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:
javax.xml.stream.XMLStreamException
- If there are underlying parsing problems.
-
constructChildCursor
public SMInputCursor constructChildCursor(SMFilter f)
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
public SMInputCursor constructDescendantCursor(SMFilter f)
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
-
-