net.sf.saxon.expr

Class ReverseRangeIterator

Implemented Interfaces:
LastPositionFinder, LookaheadIterator, ReversibleIterator, SequenceIterator

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

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

ReverseRangeIterator(long start, long end)
Create an iterator over a range of integers in monotonic descending order

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.
Item
next()
int
position()

Constructor Details

ReverseRangeIterator

public ReverseRangeIterator(long start,
                            long end)
Create an iterator over a range of integers in monotonic descending order
Parameters:
start - the first integer to be delivered (the highest in the range)
end - the last integer to be delivered (the lowest in the range). 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

next

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

position

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