Package org.htmlunit.xpath.xml.dtm.ref
Class DTMAxisIteratorBase
- java.lang.Object
-
- org.htmlunit.xpath.xml.dtm.ref.DTMAxisIteratorBase
-
- All Implemented Interfaces:
java.lang.Cloneable
,DTMAxisIterator
- Direct Known Subclasses:
DTMDefaultBaseIterators.InternalAxisIteratorBase
public abstract class DTMAxisIteratorBase extends java.lang.Object implements DTMAxisIterator
This class serves as a default base for implementations of mutable DTMAxisIterators.
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
_includeSelf
True if the start node should be considered part of the iteration.protected boolean
_isRestartable
True if this iteration can be restarted.protected int
_position
The position of the current node within the iteration, as defined by XPath.protected int
_startNode
The handle to the start, or root, of the iteration.-
Fields inherited from interface org.htmlunit.xpath.xml.dtm.DTMAxisIterator
END
-
-
Constructor Summary
Constructors Constructor Description DTMAxisIteratorBase()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DTMAxisIterator
cloneIterator()
Returns a deep copy of this iterator.DTMAxisIterator
includeSelf()
Set the flag to include the start node in the iteration.boolean
isReverse()
void
reset()
Resets the iterator to the last start node.protected void
resetPosition()
Reset the position to zero.protected int
returnNode(int node)
Do any final cleanup that is required before returning the node that was passed in, and then return it.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.htmlunit.xpath.xml.dtm.DTMAxisIterator
next, setStartNode
-
-
-
-
Field Detail
-
_position
protected int _position
The position of the current node within the iteration, as defined by XPath. Note that this is _not_ the node's handle within the DTM!
-
_startNode
protected int _startNode
The handle to the start, or root, of the iteration. Set this to END to construct an empty iterator.
-
_includeSelf
protected boolean _includeSelf
True if the start node should be considered part of the iteration. False will cause it to be skipped.
-
_isRestartable
protected boolean _isRestartable
True if this iteration can be restarted. False otherwise (eg, if we are iterating over a stream that can not be re-scanned, or if the iterator was produced by cloning another iterator.)
-
-
Method Detail
-
reset
public void reset()
Description copied from interface:DTMAxisIterator
Resets the iterator to the last start node.- Specified by:
reset
in interfaceDTMAxisIterator
-
includeSelf
public DTMAxisIterator includeSelf()
Set the flag to include the start node in the iteration.- Returns:
- This default method returns just returns this DTMAxisIterator, after setting the flag. (Returning "this" permits C++-style chaining of method calls into a single expression.)
-
isReverse
public boolean isReverse()
- Specified by:
isReverse
in interfaceDTMAxisIterator
- Returns:
- true if this iterator has a reversed axis, else false
-
cloneIterator
public DTMAxisIterator cloneIterator()
Returns a deep copy of this iterator. Cloned iterators may not be restartable. The iterator being cloned may or may not become non-restartable as a side effect of this operation.- Specified by:
cloneIterator
in interfaceDTMAxisIterator
- Returns:
- a deep copy of this iterator.
-
returnNode
protected final int returnNode(int node)
Do any final cleanup that is required before returning the node that was passed in, and then return it. The intended use is
return returnNode(node);
%REVIEW% If we're calling it purely for side effects, should we really be bothering with a return value? Something like
accept(node); return node;
would probably optimize just about as well and avoid questions about whether what's returned could ever be different from what's passed in.- Parameters:
node
- Node handle which iteration is about to yield.- Returns:
- The node handle passed in.
-
resetPosition
protected final void resetPosition()
Reset the position to zero. NOTE that this does not change the iteration state, only the position number associated with that state.%REVIEW% Document when this would be used?
-
-