Package net.sf.saxon.tree.iter
Class EmptyIterator<T extends Item>
- java.lang.Object
-
- net.sf.saxon.tree.iter.EmptyIterator<T>
-
- All Implemented Interfaces:
LastPositionFinder<T>
,SequenceIterator<T>
,GroundedIterator<T>
,LookaheadIterator<T>
,ReversibleIterator<T>
,UnfailingIterator<T>
- Direct Known Subclasses:
EmptyAxisIterator
public class EmptyIterator<T extends Item> extends java.lang.Object implements SequenceIterator<T>, ReversibleIterator<T>, LastPositionFinder<T>, GroundedIterator<T>, LookaheadIterator<T>, UnfailingIterator<T>
EmptyIterator: an iterator over an empty sequence. Since such an iterator has no state, only one instance is required; therefore a singleton instance is available via the static getInstance() method.
-
-
Field Summary
-
Fields inherited from interface net.sf.saxon.om.SequenceIterator
GROUNDED, LAST_POSITION_FINDER, LOOKAHEAD
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
EmptyIterator()
Protected constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Value
atomize()
Return the atomized value of the current node.void
close()
Close the iterator.T
current()
Get the current item, that is, the item returned by the most recent call of next().static <T extends Item>
EmptyIterator<T>emptyIterator()
EmptyIterator<T>
getAnother()
Get another iterator over the same items, positioned at the start.static EmptyIterator
getInstance()
Get an EmptyIterator, an iterator over an empty sequence.int
getLength()
Get the position of the last item in the sequence.int
getProperties()
Get properties of this iterator, as a bit-significant integer.EmptyIterator<T>
getReverseIterator()
Get another iterator over the same items, in reverse order.java.lang.CharSequence
getStringValue()
Return the string value of the current node.boolean
hasNext()
Determine whether there are more items to come.GroundedValue
materialize()
Return a Value containing all the items in the sequence returned by this SequenceIterator.T
next()
Get the next item.int
position()
Get the position of the current item.
-
-
-
Method Detail
-
getInstance
public static EmptyIterator getInstance()
Get an EmptyIterator, an iterator over an empty sequence.- Returns:
- an EmptyIterator (in practice, this always returns the same one)
-
emptyIterator
public static <T extends Item> EmptyIterator<T> emptyIterator()
-
next
public T next()
Get the next item.- Specified by:
next
in interfaceSequenceIterator<T extends Item>
- Specified by:
next
in interfaceUnfailingIterator<T extends Item>
- Returns:
- the next item. For the EmptyIterator this is always null.
-
current
public T current()
Get the current item, that is, the item returned by the most recent call of next().- Specified by:
current
in interfaceSequenceIterator<T extends Item>
- Specified by:
current
in interfaceUnfailingIterator<T extends Item>
- Returns:
- the current item. For the EmptyIterator this is always null.
-
position
public int position()
Get the position of the current item.- Specified by:
position
in interfaceSequenceIterator<T extends Item>
- Specified by:
position
in interfaceUnfailingIterator<T extends Item>
- Returns:
- the position of the current item. For the EmptyIterator this is always zero (whether or not the next() method has been called).
-
getLength
public int getLength()
Get the position of the last item in the sequence.- Specified by:
getLength
in interfaceLastPositionFinder<T extends Item>
- Returns:
- the position of the last item in the sequence, always zero in this implementation
-
close
public void close()
Description copied from interface:SequenceIterator
Close the iterator. This indicates to the supplier of the data that the client does not require any more items to be delivered by the iterator. This may enable the supplier to release resources. After calling close(), no further calls on the iterator should be made; if further calls are made, the effect of such calls is undefined.(Currently, closing an iterator is important only 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.)
- Specified by:
close
in interfaceSequenceIterator<T extends Item>
-
atomize
public Value atomize()
Return the atomized value of the current node.- Returns:
- the atomized value.
- Throws:
java.lang.NullPointerException
- always, because there is no current node
-
getStringValue
public java.lang.CharSequence getStringValue()
Return the string value of the current node.- Returns:
- the string value, as an instance of CharSequence.
- Throws:
java.lang.NullPointerException
- if there is no current node
-
getAnother
public EmptyIterator<T> getAnother()
Get another iterator over the same items, positioned at the start.- Specified by:
getAnother
in interfaceSequenceIterator<T extends Item>
- Specified by:
getAnother
in interfaceUnfailingIterator<T extends Item>
- Returns:
- another iterator over an empty sequence (in practice, it returns the same iterator each time)
-
getReverseIterator
public EmptyIterator<T> getReverseIterator()
Get another iterator over the same items, in reverse order.- Specified by:
getReverseIterator
in interfaceReversibleIterator<T extends Item>
- Returns:
- a reverse iterator over an empty sequence (in practice, it returns the same iterator each time)
-
getProperties
public int getProperties()
Get properties of this iterator, as a bit-significant integer.- Specified by:
getProperties
in interfaceSequenceIterator<T extends Item>
- Returns:
- the properties of this iterator. This will be some combination of
properties such as
SequenceIterator.GROUNDED
,SequenceIterator.LAST_POSITION_FINDER
, andSequenceIterator.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.
-
materialize
public GroundedValue materialize()
Return a Value containing all the items in the sequence returned by this SequenceIterator. This should be an "in-memory" value, not a Closure.- Specified by:
materialize
in interfaceGroundedIterator<T extends Item>
- Returns:
- the corresponding Value
-
hasNext
public boolean hasNext()
Determine whether there are more items to come. Note that this operation is stateless and it is not necessary (or usual) to call it before calling next(). It is used only when there is an explicit need to tell if we are at the last element.- Specified by:
hasNext
in interfaceLookaheadIterator<T extends Item>
- Returns:
- true if there are more nodes
-
-