net.sf.saxon.om
Class SingletonIterator
java.lang.Object
net.sf.saxon.om.SingletonIterator
- GroundedIterator, LastPositionFinder, LookaheadIterator, ReversibleIterator, SequenceIterator, UnfailingIterator
public class SingletonIterator
extends java.lang.Object
SingletonIterator: an iterator over a sequence of zero or one values
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
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
makeIterator
public static UnfailingIterator makeIterator(Item 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.
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().