Class RangeIterator

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, SequenceIterator, GroundedIterator
    Direct Known Subclasses:
    BigRangeIterator

    public abstract class RangeIterator
    extends java.lang.Object
    implements GroundedIterator
    This abstract class represents an iteration over the results of a range expression (A by B to C). There are implementations for ascending and descending iterators, implemented separately for integer ranges within the 64-bit long range, and for ranges that might include larger integers.

    As well as being able to deliver a sequence of integers, these iterators also allow testing the length of the sequence returned, for the existence of a particular value, for the minimum and maximum values, for the first and last values, and for the Nth value.

    • Constructor Detail

      • RangeIterator

        public RangeIterator()
    • Method Detail

      • getResidue

        public abstract GroundedValue getResidue()
        Return a GroundedValue containing all the remaining items in the sequence returned by this SequenceIterator, starting at the current position. This should be an "in-memory" value, not a Closure. This method does not change the state of the iterator (in particular, it does not consume the iterator).
        Specified by:
        getResidue in interface GroundedIterator
        Returns:
        the corresponding Value
        Throws:
        UncheckedXPathException - in the cases of subclasses (such as the iterator over a MemoClosure) which cause evaluation of expressions while materializing the value.
      • getStep

        public abstract IntegerValue getStep()
        Get the increment between successive values. For a descending iterator this will be negatiive value.
        Returns:
        the increment between successive values
      • containsEq

        public boolean containsEq​(NumericValue val)
        Ask whether the iterator will deliver a value equal to a supplied value
        Parameters:
        val - the supplied value
        Returns:
        true if the value is one of those that the iterator will deliver