Fields Summary |
---|
protected int | _lastThe position of the last node within the iteration, as defined by XPath.
Note that this is _not_ the node's handle within the DTM. Also, don't
confuse it with the current (most recently returned) position. |
protected int | _positionThe position of the current node within the iteration, as defined by XPath.
Note that this is _not_ the node's handle within the DTM! |
protected int | _markedNodeThe position of the marked node within the iteration;
a saved itaration state that we may want to come back to.
Note that only one mark is maintained; there is no stack. |
protected int | _startNodeThe handle to the start, or root, of the iteration.
Set this to END to construct an empty iterator. |
protected boolean | _includeSelfTrue if the start node should be considered part of the iteration.
False will cause it to be skipped. |
protected boolean | _isRestartableTrue 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.) |
Methods Summary |
---|
public com.sun.org.apache.xml.internal.dtm.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.
try
{
final DTMAxisIteratorBase clone = (DTMAxisIteratorBase) super.clone();
clone._isRestartable = false;
// return clone.reset();
return clone;
}
catch (CloneNotSupportedException e)
{
throw new com.sun.org.apache.xml.internal.utils.WrappedRuntimeException(e);
}
|
public int | getAxis()Returns the axis being iterated, if it is known.
return -1;
|
public int | getLast()Returns the position of the last node within the iteration, as
defined by XPath. In a forward iterator, I believe this equals the number of nodes which this
iterator will yield. In a reverse iterator, I believe it should return
1 (since the "last" is the first produced.)
This may be an expensive operation when called the first time, since
it may have to iterate through a large part of the document to produce
its answer.
if (_last == -1) // Not previously established
{
// Note that we're doing both setMark() -- which saves _currentChild
// -- and explicitly saving our position counter (number of nodes
// yielded so far).
//
// %REVIEW% Should position also be saved by setMark()?
// (It wasn't in the XSLTC version, but I don't understand why not.)
final int temp = _position; // Save state
setMark();
reset(); // Count the nodes found by this iterator
do
{
_last++;
}
while (next() != END);
gotoMark(); // Restore saved state
_position = temp;
}
return _last;
|
public int | getNodeByPosition(int position)Return the node at the given position.
if (position > 0) {
final int pos = isReverse() ? getLast() - position + 1
: position;
int node;
while ((node = next()) != DTMAxisIterator.END) {
if (pos == getPosition()) {
return node;
}
}
}
return END;
|
public int | getPosition()
return _position == 0 ? 1 : _position;
|
public int | getStartNode()Get start to END should 'close' the iterator,
i.e. subsequent call to next() should return END.
return _startNode;
|
public com.sun.org.apache.xml.internal.dtm.DTMAxisIterator | includeSelf()Set the flag to include the start node in the iteration.
_includeSelf = true;
return this;
|
public boolean | isDocOrdered()Returns true if all the nodes in the iteration well be returned in document
order.
return true;
|
public boolean | isReverse()
return false;
|
public com.sun.org.apache.xml.internal.dtm.DTMAxisIterator | reset()
final boolean temp = _isRestartable;
_isRestartable = true;
setStartNode(_startNode);
_isRestartable = temp;
return this;
|
protected final com.sun.org.apache.xml.internal.dtm.DTMAxisIterator | 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?
_position = 0;
return this;
|
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.
_position++;
return node;
|
public void | setRestartable(boolean isRestartable)
_isRestartable = isRestartable;
|