net.sf.saxon.om
Interface SequenceIterator

All Known Subinterfaces:
AxisIterator, GroupIterator, LastPositionFinder, ReversibleIterator
All Known Implementing Classes:
ArrayIterator, ArrayListIterator, AxisIteratorImpl, Closure.ProgressiveIterator, DifferenceEnumeration, DocumentOrderIterator, EmptyIterator, FilterIterator, GroupAdjacentIterator, GroupByIterator, GroupEndingIterator, GroupStartingIterator, IntersectionEnumeration, MappingIterator, PositionIterator, RegexIterator, ReverseArrayIterator, SingletonIterator, SortedGroupIterator, SortedIterator, StringTokenIterator, StringValue.CharacterIterator, TailExpression.TailIterator, Tokenize.TokenIterator, Trace.TracingIterator, UnionEnumeration

public interface SequenceIterator

A SequenceIterator is used to iterate over any XPath 2 sequence (of values or nodes). It is modelled on the JDK 1.2 Iterator class, but differs in two main respects: a SequenceIterator can be cloned (to create a new iterator that iterates over the same sequence of values, but with the initial position reset to the start); and the methods can throw exceptions if access to the underlying data fails. Also, a SequenceIterator keeps track of the current Item and the current position. The objects returned by the SequenceIterator will always be either nodes (class NodeInfo) or singleton values (class AtomicValue), these are represented by the interface Item.


Method Summary
 Item current()
          Get the current value in the sequence (the one returned by the most recent call on next()).
 SequenceIterator getAnother()
          Get another SequenceIterator that iterates over the same items as the original, but which is repositioned at the start of the sequence.
 boolean hasNext()
          Determine whether there are more items to come.
 Item next()
          Get the next item in the sequence.
 int position()
          Get the current position.
 

Method Detail

hasNext

public boolean hasNext()
                throws XPathException
Determine whether there are more items to come.
This method must be called before next() is called to get the next item, and next() must not be called unless hasNext() returns true. The hasNext() method must not change the current position, it must be possible to call hasNext() repeatedly and get the same result each time.

Returns:
true if there are more items available
Throws:
XPathException - if any error occurs while determining whether there are more items in the sequence

next

public Item next()
          throws XPathException
Get the next item in the sequence.
This must not be called unless hasNext() has been called to test whether there is a next item.

Returns:
the next item
Throws:
XPathException - if an error occurs retrieving the next item

current

public Item current()
Get the current value in the sequence (the one returned by the most recent call on next()). This will be null before the first call of next().

Returns:
the current item, the one most recently returned by a call on next(); or null, if next() has not been called

position

public int position()
Get the current position. This will be zero before the first call on next(), otherwise it will be the number of times that next() has been called.

Returns:
the current position, the position of the item returned by the most recent call of next()

getAnother

public SequenceIterator getAnother()
                            throws XPathException
Get another SequenceIterator that iterates over the same items as the original, but which is repositioned at the start of the sequence.

Returns:
a SequenceIterator that iterates over the same items, positioned before the first item
Throws:
XPathException - if any error occurs