Class ArrayIterator
java.lang.Object
net.sf.saxon.tree.iter.ArrayIterator
- All Implemented Interfaces:
Closeable, AutoCloseable, LastPositionFinder, SequenceIterator, GroundedIterator, LookaheadIterator, ReversibleIterator
- Direct Known Subclasses:
ArrayIterator.Of
public abstract class ArrayIterator
extends Object
implements SequenceIterator, LastPositionFinder, LookaheadIterator, GroundedIterator, ReversibleIterator
ArrayIterator is used to enumerate items held in an array.
The items are always held in the correct sorted order for the sequence.
The challenge here is getting the generics right, especially in a way
that works for C#, which is less tolerant of generic abuse. The solution
is to have a non-generic
ArrayIterator class, with
ArrayIterator.Of<T extends Item> as a subclass. A further subtlety
is that we need an ArrayIterator of nodes to implement AxisIterator,
so we have another subclass ArrayIterator.OfNodes<N extends NodeInfo>
for that purpose.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classArrayIterator.Of<T extends Item>Parameterised subclass to accept items of a particular item typestatic classArrayIterator.OfNodes<N extends NodeInfo>ArrayIterator.OfNodes is a subclass of ArrayIterator where the array always contains Nodes; it therefore implements the AxisIterator interface. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanAsk if the iterator is actually grounded.abstract SequenceIteratormakeSliceIterator(int min, int max) Create a new ArrayIterator over the same items, with a different start point and end pointbooleanAsk whether the hasNext() method can be called.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface GroundedIterator
getResidue, materializeMethods inherited from interface LastPositionFinder
getLength, supportsGetLengthMethods inherited from interface LookaheadIterator
hasNextMethods inherited from interface ReversibleIterator
getReverseIteratorMethods inherited from interface SequenceIterator
close, discharge, next
-
Field Details
-
index
protected int index -
start
protected int start -
end
protected int end
-
-
Constructor Details
-
ArrayIterator
public ArrayIterator()
-
-
Method Details
-
makeSliceIterator
Create a new ArrayIterator over the same items, with a different start point and end point- Parameters:
min- the start position (1-based) of the new ArrayIterator relative to the originalmax- the end position (1-based) of the last item to be delivered by the new ArrayIterator, relative to the original. For example, min=2, max=3 delivers the two items ($base[2], $base[3]). Set this to Integer.MAX_VALUE if there is no end limit.- Returns:
- an iterator over the items between the min and max positions
-
isActuallyGrounded
public boolean isActuallyGrounded()Description copied from interface:GroundedIteratorAsk if the iterator is actually grounded. This method must be called before callingGroundedIterator.materialize()orGroundedIterator.getResidue(), because the iterator might be grounded under some conditions and not others (usually when it delegates to another iterator)- Specified by:
isActuallyGroundedin interfaceGroundedIterator- Returns:
- true if this iterator is grounded
-
supportsHasNext
public boolean supportsHasNext()Description copied from interface:LookaheadIteratorAsk whether the hasNext() method can be called. This method must be called before calling hasNext(), because some iterators implement this interface, but only support look-ahead under particular circumstances (this is usually because they delegate to another iterator)- Specified by:
supportsHasNextin interfaceLookaheadIterator- Returns:
- true if the
LookaheadIterator.hasNext()method is available
-