Package org.codehaus.staxmate.in
Class CursorBase
java.lang.Object
org.codehaus.staxmate.in.CursorBase
- Direct Known Subclasses:
SMInputCursor
Abstract base class that contains non-public methods to be used by
public sub-classes (
SMInputCursor
and its sub-classes).-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
State constants are used for keeping track of state of individual cursors. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final int
Depth the underlying stream reader had when this cursor was created (which is the number of currently open parent elements).protected SMInputCursor
Cursor that has been opened for iterating child nodes of the start element node this cursor points to.protected final SMInputContext
protected SMEvent
Event that this cursor currently points to, if valid, or it last pointed to if not (including null if cursor has not yet been advanced).protected int
Number of start elements iterated over by this cursor, including the current one.protected int
Number of nodes iterated over by this cursor, including the current one.protected SMElementInfo
Element that the parent of this cursor tracked (if any), when this cursor was created.protected CursorBase.State
Current state of the cursor.protected final org.codehaus.stax2.XMLStreamReader2
Underlying stream reader used.protected SMElementInfo
Element that was last "tracked"; element over which cursor was moved, and of which state has been saved for further use.private static final SMEvent[]
This is the mapping array, indexed by Stax 1.0 event type integer code, value being matchingSMEvent
enumeration value. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) org.codehaus.stax2.typed.TypedXMLStreamException
_constructTypedException
(String value, IllegalArgumentException rootCause, String msg) protected final org.codehaus.stax2.XMLStreamReader2
Internal method (but available to sub-classes) that allows access to the underlying stream reader.protected XMLStreamException
_notAccessible
(String method) Internal method for throwing a stream exception that indicates that given method can not be called because the cursor does not point to event of expected type.(package private) void
(package private) void
_throwWrongEndElem
(int expDepth, int actDepth) protected XMLStreamException
_wrongState
(String method, SMEvent expState) abstract XMLStreamException
protected String
Method for constructing human-readable description of the event this cursor points to (if cursor valid) or last pointed to (if not valid; possibly null if cursor has not yet been advanced).protected static final SMEvent
eventObjectByEventId
(int type) Note: no checks are done regarding validity of passed-in type.protected final int
This method is needed by flattening cursors when they have child cursors: if so, they can determine their depth relative to child cursor's base parent count (and can not check stream -- as it may have moved -- nor want to have separate field to track this information)protected abstract String
protected String
protected void
Method called by the parent cursor, to indicate it has to traverse over xml content and that child cursor as well as all of its descendant cursors (if any) are to be considered invalid.abstract boolean
protected final void
Method called to skim through the content that the child cursor(s) are pointing to, end return once next call to XMLStreamReader2.next() will return the next event this cursor should see.abstract void
toString()
-
Field Details
-
EVENTS_BY_IDS
This is the mapping array, indexed by Stax 1.0 event type integer code, value being matchingSMEvent
enumeration value. -
_context
-
_streamReader
protected final org.codehaus.stax2.XMLStreamReader2 _streamReaderUnderlying stream reader used. It will either be a nativeXMLStreamReader2
instance, or a regular (Stax 1.0)XMLStreamReader
wrapped in an adapter. -
_baseDepth
protected final int _baseDepthDepth the underlying stream reader had when this cursor was created (which is the number of currently open parent elements). 0 only for root cursor. -
_state
Current state of the cursor. -
_currEvent
Event that this cursor currently points to, if valid, or it last pointed to if not (including null if cursor has not yet been advanced). -
_nodeCount
protected int _nodeCountNumber of nodes iterated over by this cursor, including the current one. -
_elemCount
protected int _elemCountNumber of start elements iterated over by this cursor, including the current one. -
_trackedElement
Element that was last "tracked"; element over which cursor was moved, and of which state has been saved for further use. At this point, it can be null if no elements have yet been iterater over. Alternatively, if it's not null, it may be currently pointed to or not; if it's not, either child cursor is active, or this cursor points to a non-start-element node. -
_parentTrackedElement
Element that the parent of this cursor tracked (if any), when this cursor was created. -
_childCursor
Cursor that has been opened for iterating child nodes of the start element node this cursor points to. Needed to keep cursor hierarchy synchronized, independent of which ones are traversed.
-
-
Constructor Details
-
CursorBase
- Parameters:
baseDepth
- Base depth (number of enclosing open start elements) of the underlying stream at point when this cursor was instantiated
-
-
Method Details
-
getCurrEventDesc
- Returns:
- Developer-readable description of the event this cursor currently points to.
-
isRootCursor
public abstract boolean isRootCursor()- Returns:
- True if this cursor iterates over root level of the underlying stream reader
-
constructStreamException
-
throwStreamException
- Throws:
XMLStreamException
-
getBaseParentCount
protected final int getBaseParentCount()This method is needed by flattening cursors when they have child cursors: if so, they can determine their depth relative to child cursor's base parent count (and can not check stream -- as it may have moved -- nor want to have separate field to track this information) -
rewindPastChild
Method called to skim through the content that the child cursor(s) are pointing to, end return once next call to XMLStreamReader2.next() will return the next event this cursor should see.- Throws:
XMLStreamException
-
invalidate
Method called by the parent cursor, to indicate it has to traverse over xml content and that child cursor as well as all of its descendant cursors (if any) are to be considered invalid.- Throws:
XMLStreamException
-
_getStreamReader
protected final org.codehaus.stax2.XMLStreamReader2 _getStreamReader()Internal method (but available to sub-classes) that allows access to the underlying stream reader. -
eventObjectByEventId
Note: no checks are done regarding validity of passed-in type.
- Returns:
SMEvent
matching given type
-
_notAccessible
Internal method for throwing a stream exception that indicates that given method can not be called because the cursor does not point to event of expected type. This can be either because cursor is invalid (doesn't point to any event), or because it points to "wrong" event type. Distinction is reflected in the exception message.- Throws:
XMLStreamException
-
_wrongState
- Throws:
XMLStreamException
-
getStateDesc
-
currentEventStr
Method for constructing human-readable description of the event this cursor points to (if cursor valid) or last pointed to (if not valid; possibly null if cursor has not yet been advanced).- Returns:
- Human-readable description of the underlying Stax event this cursor points to.
-
_throwUnexpectedEndDoc
- Throws:
XMLStreamException
-
_throwWrongEndElem
- Throws:
IllegalStateException
-
_constructTypedException
org.codehaus.stax2.typed.TypedXMLStreamException _constructTypedException(String value, IllegalArgumentException rootCause, String msg) -
toString
-