public class SingletonIterator<T extends Item<?>> extends java.lang.Object implements SequenceIterator<T>, UnfailingIterator<T>, ReversibleIterator<T>, LastPositionFinder, GroundedIterator<T>, LookaheadIterator<T>
ATOMIZING, GROUNDED, LAST_POSITION_FINDER, LOOKAHEAD
Modifier and Type | Method and Description |
---|---|
void |
close()
Close the iterator.
|
void |
forEach(java.util.function.Consumer<T> consumer) |
void |
forEachOrFail(ItemConsumer<T> consumer)
Process all the remaining items delivered by the SequenceIterator using a supplied consumer function.
|
int |
getLength()
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.
|
GroundedValue<T> |
getResidue()
Return a GroundedValue containing all the remaining items in the sequence returned by this
SequenceIterator, starting at the current position.
|
SingletonIterator<T> |
getReverseIterator()
Get a new SequenceIterator that returns the same items in reverse order.
|
Item |
getValue() |
boolean |
hasNext()
Determine whether there are more items to come.
|
static <T extends Item<?>> |
makeIterator(T item)
Factory method.
|
GroundedValue<T> |
materialize()
Return a Value containing all the items in the sequence returned by this
SequenceIterator
|
T |
next()
Get the next item in the sequence.
|
static <T extends Item<?>> |
rawIterator(T item)
Factory method for use when it is known the item will not be null
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
firstWith, toGroundedValue, toList
public static <T extends Item<?>> UnfailingIterator<T> makeIterator(T item)
item
- the item to iterate overpublic static <T extends Item<?>> SingletonIterator<T> rawIterator(T item)
item
- the item to iterate over; must not be nullpublic boolean hasNext()
hasNext
in interface LookaheadIterator<T extends Item<?>>
public T next()
SequenceIterator
next
in interface SequenceIterator<T extends Item<?>>
next
in interface UnfailingIterator<T extends Item<?>>
public int getLength()
LastPositionFinder
SequenceIterator.LAST_POSITION_FINDER
getLength
in interface LastPositionFinder
public void close()
SequenceIterator
For example, the iterator returned by the unparsed-text-lines() function has a close() method that causes the underlying input stream to be closed, whether or not the file has been read to completion.
Closing an iterator is important when the data is being "pushed" in another thread. Closing the iterator terminates that thread and means that it needs to do no additional work. Indeed, failing to close the iterator may cause the push thread to hang waiting for the buffer to be emptied.
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in interface SequenceIterator<T extends Item<?>>
public SingletonIterator<T> getReverseIterator()
ReversibleIterator
getReverseIterator
in interface ReversibleIterator<T extends Item<?>>
public Item getValue()
public GroundedValue<T> materialize()
materialize
in interface SequenceIterator<T extends Item<?>>
materialize
in interface GroundedIterator<T extends Item<?>>
public GroundedValue<T> getResidue()
GroundedIterator
getResidue
in interface GroundedIterator<T extends Item<?>>
public int getProperties()
getProperties
in interface SequenceIterator<T extends Item<?>>
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.public void forEach(java.util.function.Consumer<T> consumer)
forEach
in interface UnfailingIterator<T extends Item<?>>
public void forEachOrFail(ItemConsumer<T> consumer) throws XPathException
SequenceIterator
forEachOrFail
in interface SequenceIterator<T extends Item<?>>
consumer
- the supplied consumer functionXPathException
- if either (a) an error occurs obtaining an item from the input sequence,
or (b) the consumer throws an exception.Copyright (c) 2004-2020 Saxonica Limited. All rights reserved.