Class EmptyIterator
java.lang.Object
net.sf.saxon.om.EmptyIterator
- All Implemented Interfaces:
LastPositionFinder, ReversibleIterator, AxisIterator, GroundedIterator, LookaheadIterator, SequenceIterator
public class EmptyIterator
extends Object
implements AxisIterator, ReversibleIterator, LastPositionFinder, GroundedIterator, LookaheadIterator
EmptyIterator: an iterator over an empty sequence. Since such an iterator has no state,
only one instance is required; therefore a singleton instance is available via the static
getInstance() method.
-
Field Summary
Fields inherited from interface SequenceIterator
ATOMIZABLE, GROUNDED, LAST_POSITION_FINDER, LOOKAHEAD -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncurrent()Get the current item, that is, the item returned by the most recent call of next().Get another iterator over the same items, positioned at the start.static EmptyIteratorGet an EmptyIterator, an iterator over an empty sequence.intGet the position of the last item in the sequence.intGet properties of this iterator, as a bit-significant integer.Get another iterator over the same items, in reverse order.booleanhasNext()Determine whether there are more items to come.Return a Value containing all the items in the sequence returned by this SequenceIterator.next()Get the next item.intposition()Get the position of the current item.
-
Constructor Details
-
EmptyIterator
public EmptyIterator()
-
-
Method Details
-
getInstance
Get an EmptyIterator, an iterator over an empty sequence.- Returns:
- an EmptyIterator (in practice, this always returns the same one)
-
next
Get the next item. This method should not be called unless hasNext() returns true.- Specified by:
nextin interfaceAxisIterator- Specified by:
nextin interfaceSequenceIterator- Returns:
- the next item. For the EmptyIterator this is always null.
-
current
Get the current item, that is, the item returned by the most recent call of next().- Specified by:
currentin interfaceAxisIterator- Specified by:
currentin interfaceSequenceIterator- Returns:
- the current item. For the EmptyIterator this is always null.
-
position
public int position()Get the position of the current item.- Specified by:
positionin interfaceAxisIterator- Specified by:
positionin interfaceSequenceIterator- Returns:
- the position of the current item. For the EmptyIterator this is always zero (whether or not the next() method has been called).
-
getLastPosition
public int getLastPosition()Get the position of the last item in the sequence.- Specified by:
getLastPositionin interfaceLastPositionFinder- Returns:
- the position of the last item in the sequence, always zero in this implementation
-
getAnother
Get another iterator over the same items, positioned at the start.- Specified by:
getAnotherin interfaceAxisIterator- Specified by:
getAnotherin interfaceSequenceIterator- Returns:
- another iterator over an empty sequence (in practice, it returns the same iterator each time)
-
getReverseIterator
Get another iterator over the same items, in reverse order.- Specified by:
getReverseIteratorin interfaceReversibleIterator- Returns:
- a reverse iterator over an empty sequence (in practice, it returns the same iterator each time)
-
getProperties
public int getProperties()Get properties of this iterator, as a bit-significant integer.- Specified by:
getPropertiesin interfaceSequenceIterator- Returns:
- the properties of this iterator. This will be some combination of
properties such as
SequenceIterator.GROUNDED,SequenceIterator.LAST_POSITION_FINDER, andSequenceIterator.LOOKAHEAD. It is always acceptable to return the value zero, indicating that there are no known special properties. It is acceptable for the properties of the iterator to change depending on its state.
-
materialize
Return a Value containing all the items in the sequence returned by this SequenceIterator. This should be an "in-memory" value, not a Closure.- Specified by:
materializein interfaceGroundedIterator- Returns:
- the corresponding Value
-
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.- Specified by:
hasNextin interfaceLookaheadIterator- Returns:
- true if there are more nodes
-