net.sf.saxon.expr

Class RangeIterator

Implemented Interfaces:
GroundedIterator, LastPositionFinder, LookaheadIterator, ReversibleIterator, SequenceIterator

public class RangeIterator
extends java.lang.Object
implements SequenceIterator, ReversibleIterator, LastPositionFinder, LookaheadIterator, GroundedIterator

An Iterator that produces numeric values in a monotonic sequence, ascending or descending. Although a range expression (N to M) is always in ascending order, applying the reverse() function will produce a RangeIterator that works in descending order.

Fields inherited from interface net.sf.saxon.om.SequenceIterator

GROUNDED, LAST_POSITION_FINDER, LOOKAHEAD

Constructor Summary

RangeIterator(long start, long end)
Create an iterator over a range of monotonically increasing integers

Method Summary

Item
current()
SequenceIterator
getAnother()
int
getLastPosition()
Get the last position (that is, the number of items in the sequence).
int
getProperties()
Get properties of this iterator, as a bit-significant integer.
SequenceIterator
getReverseIterator()
Get a new SequenceIterator that returns the same items in reverse order.
boolean
hasNext()
Determine whether there are more items to come.
GroundedValue
materialize()
Return a Value containing all the items in the sequence returned by this SequenceIterator.
Item
next()
int
position()

Constructor Details

RangeIterator

public RangeIterator(long start,
                     long end)
Create an iterator over a range of monotonically increasing integers
Parameters:
start - the first integer in the sequence
end - the last integer in the sequence. Must be >= start.

Method Details

current

public Item current()
Specified by:
current in interface SequenceIterator

getAnother

public SequenceIterator getAnother()
            throws XPathException
Specified by:
getAnother in interface SequenceIterator

getLastPosition

public int getLastPosition()
Specified by:
getLastPosition in interface LastPositionFinder

getProperties

public int getProperties()
Get properties of this iterator, as a bit-significant integer.
Specified by:
getProperties in interface SequenceIterator
Returns:
the properties of this iterator. This will be some combination of properties such as SequenceIterator.GROUNDED, SequenceIterator.LAST_POSITION_FINDER, and SequenceIterator.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.

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.
Specified by:
getReverseIterator in interface ReversibleIterator
Returns:
an iterator over the items in reverse order

hasNext

public boolean hasNext()
Specified by:
hasNext in interface LookaheadIterator
Returns:
true if there are more items in the sequence

materialize

public GroundedValue materialize()
            throws XPathException
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:
materialize in interface GroundedIterator
Returns:
the corresponding Value

next

public Item next()
Specified by:
next in interface SequenceIterator

position

public int position()
Specified by:
position in interface SequenceIterator