Package net.sf.saxon.tree.iter
Class ArrayIterator
- java.lang.Object
-
- net.sf.saxon.tree.iter.ArrayIterator
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,LastPositionFinder
,FocusIterator
,SequenceIterator
,GroundedIterator
,LookaheadIterator
,ReversibleIterator
- Direct Known Subclasses:
ArrayIterator.Of
public abstract class ArrayIterator extends java.lang.Object implements SequenceIterator, FocusIterator, LastPositionFinder, LookaheadIterator, GroundedIterator, ReversibleIterator
ArrayIterator is used to enumerate items held in a Java 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-genericArrayIterator
class, withArrayIterator.Of<T extends Item>
as a subclass. A further subtlety is that we need an ArrayIterator of nodes to implementAxisIterator
, so we have another subclassArrayIterator.OfNodes<N extends NodeInfo>
for that purpose.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ArrayIterator.Of<T extends Item>
Parameterised subclass to accept items of a particular item typestatic class
ArrayIterator.OfNodes<N extends NodeInfo>
ArrayIterator.OfNodes is a subclass of ArrayIterator where the array always contains Nodes; it therefore implements the AxisIterator interface.
-
Constructor Summary
Constructors Constructor Description ArrayIterator()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description int
getLength()
Get the position of the last item in the sequenceboolean
isActuallyGrounded()
Ask if the iterator is actually grounded.abstract SequenceIterator
makeSliceIterator(int min, int max)
Create a new ArrayIterator over the same items, with a different start point and end pointint
position()
Get the current position.boolean
supportsHasNext()
Ask whether the hasNext() method can be called.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.sf.saxon.om.FocusIterator
current
-
Methods inherited from interface net.sf.saxon.tree.iter.GroundedIterator
getResidue, materialize
-
Methods inherited from interface net.sf.saxon.expr.LastPositionFinder
supportsGetLength
-
Methods inherited from interface net.sf.saxon.tree.iter.LookaheadIterator
hasNext
-
Methods inherited from interface net.sf.saxon.tree.iter.ReversibleIterator
getReverseIterator
-
Methods inherited from interface net.sf.saxon.om.SequenceIterator
close, next
-
-
-
-
Method Detail
-
makeSliceIterator
public abstract SequenceIterator makeSliceIterator(int min, int max)
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:GroundedIterator
Ask 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:
isActuallyGrounded
in interfaceGroundedIterator
- Returns:
- true if this iterator is grounded
-
supportsHasNext
public boolean supportsHasNext()
Description copied from interface:LookaheadIterator
Ask 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:
supportsHasNext
in interfaceLookaheadIterator
- Returns:
- true if the
LookaheadIterator.hasNext()
method is available
-
position
public int position()
Description copied from interface:FocusIterator
Get the current position. This will usually be zero before the first call on next(), otherwise it will be the number of times that next() has been called. Once next() has returned null, the preferred action is for subsequent calls on position() to return -1, but not all existing implementations follow this practice. (In particular, the EmptyIterator is stateless, and always returns 0 as the value of position(), whether or not next() has been called.)This method does not change the state of the iterator.
- Specified by:
position
in interfaceFocusIterator
- Returns:
- the current position, the position of the item returned by the most recent call of next(). This is 1 after next() has been successfully called once, 2 after it has been called twice, and so on. If next() has never been called, the method returns zero. If the end of the sequence has been reached, the value returned will always be <= 0; the preferred value is -1.
-
getLength
public int getLength()
Description copied from interface:FocusIterator
Get the position of the last item in the sequence- Specified by:
getLength
in interfaceFocusIterator
- Specified by:
getLength
in interfaceLastPositionFinder
- Returns:
- the position of the last item
-
-