Package net.sf.saxon.om
Class EmptyIterator
- java.lang.Object
-
- net.sf.saxon.om.EmptyIterator
-
- All Implemented Interfaces:
LastPositionFinder,ReversibleIterator,AxisIterator,GroundedIterator,LookaheadIterator,SequenceIterator,UnfailingIterator
public class EmptyIterator extends java.lang.Object implements AxisIterator, ReversibleIterator, LastPositionFinder, GroundedIterator, LookaheadIterator
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
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Valueatomize()Return the atomized value of the current node.voidclose()Close the iterator.Itemcurrent()Get the current item, that is, the item returned by the most recent call of next().SequenceIteratorgetAnother()Get another iterator over the same items, positioned at the start.static EmptyIteratorgetInstance()Get an EmptyIterator, an iterator over an empty sequence.intgetLastPosition()Get the position of the last item in the sequence.intgetProperties()Get properties of this iterator, as a bit-significant integer.SequenceIteratorgetReverseIterator()Get another iterator over the same items, in reverse order.java.lang.CharSequencegetStringValue()Return the string value of the current node.booleanhasNext()Determine whether there are more items to come.AxisIteratoriterateAxis(byte axis, NodeTest test)Return an iterator over an axis, starting at the current node.GroundedValuematerialize()Return a Value containing all the items in the sequence returned by this SequenceIterator.booleanmoveNext()Move to the next node, without returning it.Itemnext()Get the next item.intposition()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)
-
moveNext
public boolean moveNext()
Move to the next node, without returning it. Returns true if there is a next node, false if the end of the sequence has been reached. After calling this method, the current node may be retrieved using the current() function.- Specified by:
moveNextin interfaceAxisIterator
-
next
public Item next()
Get the next item.- Specified by:
nextin interfaceSequenceIterator- Specified by:
nextin interfaceUnfailingIterator- Returns:
- the next item. For the EmptyIterator this is always null.
-
current
public Item current()
Get the current item, that is, the item returned by the most recent call of next().- Specified by:
currentin interfaceSequenceIterator- Specified by:
currentin interfaceUnfailingIterator- Returns:
- the current item. For the EmptyIterator this is always null.
-
position
public int position()
Get the position of the current item.- Specified by:
positionin interfaceSequenceIterator- Specified by:
positionin interfaceUnfailingIterator- Returns:
- the position of the current item. For the EmptyIterator this is always zero (whether or not the next() method has been called).
-
getLastPosition
public int getLastPosition()
Get the position of the last item in the sequence.- Specified by:
getLastPositionin interfaceLastPositionFinder- Returns:
- the position of the last item in the sequence, always zero in this implementation
-
close
public void close()
Description copied from interface:SequenceIteratorClose 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:
closein interfaceSequenceIterator
-
iterateAxis
public AxisIterator iterateAxis(byte axis, NodeTest test)
Return an iterator over an axis, starting at the current node.- Specified by:
iterateAxisin interfaceAxisIterator- Parameters:
axis- the axis to iterate over, using a constant such asAxis.CHILDtest- a predicate to apply to the nodes before returning them.- Throws:
java.lang.NullPointerException- if there is no current node
-
atomize
public Value atomize() throws XPathException
Return the atomized value of the current node.- Specified by:
atomizein interfaceAxisIterator- Returns:
- the atomized value.
- Throws:
java.lang.NullPointerException- if there is no current nodeXPathException
-
getStringValue
public java.lang.CharSequence getStringValue()
Return the string value of the current node.- Specified by:
getStringValuein interfaceAxisIterator- Returns:
- the string value, as an instance of CharSequence.
- Throws:
java.lang.NullPointerException- if there is no current node
-
getAnother
public SequenceIterator getAnother()
Get another iterator over the same items, positioned at the start.- Specified by:
getAnotherin interfaceSequenceIterator- Specified by:
getAnotherin interfaceUnfailingIterator- Returns:
- another iterator over an empty sequence (in practice, it returns the same iterator each time)
-
getReverseIterator
public SequenceIterator getReverseIterator()
Get another iterator over the same items, in reverse order.- Specified by:
getReverseIteratorin interfaceReversibleIterator- 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:
getPropertiesin interfaceSequenceIterator- 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:
materializein interfaceGroundedIterator- 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:
hasNextin interfaceLookaheadIterator- Returns:
- true if there are more nodes
-
-