public class ManualIterator<T extends Item<?>> extends java.lang.Object implements FocusIterator<T>, UnfailingIterator<T>, ReversibleIterator<T>, LastPositionFinder, GroundedIterator<T>, LookaheadIterator<T>
ATOMIZING, GROUNDED, LAST_POSITION_FINDER, LOOKAHEAD
Constructor and Description |
---|
ManualIterator()
Create an uninitialized ManualIterator: this is only usable after the context item, position, and size (if required)
have been initialized using setter methods.
|
ManualIterator(T value)
Create a ManualIterator supplying the context item, and setting the value of
both "position()" and "last()" implicitly to 1.
|
ManualIterator(T value,
int position)
Create a ManualIterator initializing the context item and position.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Close the iterator.
|
T |
current()
Get the current value in the sequence (the one returned by the
most recent call on next()).
|
int |
getLength()
Get the position of the last item 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.
|
ManualIterator<T> |
getReverseIterator()
Get a new SequenceIterator that returns the same items in reverse order.
|
boolean |
hasNext()
Determine whether there are more items to come.
|
void |
incrementPosition() |
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.
|
int |
position()
Return the current position in the sequence.
|
void |
setContextItem(T value) |
void |
setLastPositionFinder(LastPositionFinder finder) |
void |
setPosition(int position) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
firstWith, forEach, toGroundedValue, toList
forEachOrFail
public ManualIterator()
public ManualIterator(T value, int position)
value
- the context item. May be null if the value is to be initialized later.position
- the context positionpublic ManualIterator(T value)
value
- the context itempublic void setContextItem(T value)
public void setLastPositionFinder(LastPositionFinder finder)
public void incrementPosition()
public void setPosition(int position)
public 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 T current()
FocusIterator
current
in interface FocusIterator<T extends Item<?>>
public int position()
position
in interface FocusIterator<T extends Item<?>>
public int getLength() throws XPathException
FocusIterator
getLength
in interface LastPositionFinder
getLength
in interface FocusIterator<T extends Item<?>>
XPathException
- if a failure occurs reading the sequencepublic 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 ManualIterator<T> getReverseIterator()
ReversibleIterator
getReverseIterator
in interface ReversibleIterator<T extends Item<?>>
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.Copyright (c) 2004-2020 Saxonica Limited. All rights reserved.