net.sf.saxon.om
Class SingleNodeIterator
java.lang.Object
net.sf.saxon.om.SingleNodeIterator
- AxisIterator, GroundedIterator, LastPositionFinder, LookaheadIterator, ReversibleIterator, SequenceIterator, UnfailingIterator
public class SingleNodeIterator
extends java.lang.Object
SingletonIterator: an iterator over a sequence of zero or one values
getAnother
public SequenceIterator getAnother()
Get another iterator over the same sequence of items, positioned at the
start of the sequence. It must be possible to call this method at any time, whether
none, some, or all of the items in the original iterator have been read. The method
is non-destructive: it does not change the state of the original iterator.
- getAnother in interface UnfailingIterator
- getAnother in interface SequenceIterator
- a new iterator over the same sequence
getLastPosition
public int getLastPosition()
Get the last position (that is, the number of items in the sequence). This method is
non-destructive: it does not change the state of the iterator.
The result is undefined if the next() method of the iterator has already returned null.
This method must not be called unless the result of getProperties() on the iterator
includes the bit setting
SequenceIterator.LAST_POSITION_FINDER
- getLastPosition in interface LastPositionFinder
getProperties
public int getProperties()
Get properties of this iterator, as a bit-significant integer.
- getProperties in interface SequenceIterator
getReverseIterator
public SequenceIterator getReverseIterator()
Get a new SequenceIterator that returns the same items in reverse order.
If this SequenceIterator is an AxisIterator, then the returned SequenceIterator
must also be an AxisIterator.
- getReverseIterator in interface ReversibleIterator
- an iterator over the items in reverse order
getStringValue
public CharSequence getStringValue()
Return the string value of the current node.
- getStringValue in interface AxisIterator
- the string value, as an instance of CharSequence.
getValue
public Item getValue()
hasNext
public boolean hasNext()
Determine whether there are more items to come. Note that this operation
is stateless and it is not necessary (or usual) to call it before calling
next(). It is used only when there is an explicit need to tell if we
are at the last element.
- hasNext in interface LookaheadIterator
- true if there are more items
iterateAxis
public AxisIterator iterateAxis(byte axis,
NodeTest test)
Return an iterator over an axis, starting at the current node.
- iterateAxis in interface AxisIterator
axis
- the axis to iterate over, using a constant such as
Axis.CHILD
test
- a predicate to apply to the nodes before returning them.
makeIterator
public static AxisIterator makeIterator(NodeInfo item)
Factory method.
item
- the item to iterate over
- a SingletonIterator over the supplied item, or an EmptyIterator
if the supplied item is null.
materialize
public GroundedValue materialize()
Return a Value containing all the items in the sequence returned by this
SequenceIterator
- materialize in interface GroundedIterator
- the corresponding Value. If the value is a closure or a function call package, it will be
evaluated and expanded.
moveNext
public boolean moveNext()
Move to the next node, without returning it. Returns true if there is
a next node, false if the end of the sequence has been reached. After
calling this method, the current node may be retrieved using the
current() function.
- moveNext in interface AxisIterator
position
public int position()
Return the current position in the sequence.
- position in interface UnfailingIterator
- position in interface SequenceIterator
- 0 before the first call on next(); 1 before the second call on next(); -1 after the second
call on next().