Class NodeIteratorImpl
- java.lang.Object
-
- org.apache.jackrabbit.jcr2spi.query.NodeIteratorImpl
-
- All Implemented Interfaces:
Iterator
,NodeIterator
,RangeIterator
,ScoreNodeIterator
public class NodeIteratorImpl extends Object implements ScoreNodeIterator
Implements aNodeIterator
returned byQueryResult.getNodes()
.
-
-
Constructor Summary
Constructors Constructor Description NodeIteratorImpl(ItemManager itemMgr, HierarchyManager hierarchyMgr, QueryInfo queryInfo)
Creates a newNodeIteratorImpl
instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description long
getPosition()
Returns the current position in thisNodeIterator
.double
getScore()
Returns the score of the node returned bynextNode()
.long
getSize()
Returns the number of nodes in this iterator.boolean
hasNext()
Returnstrue
if there is anotherNode
available;false
otherwise.Object
next()
Returns the nextNode
in the result set.Node
nextNode()
Returns the nextNode
in the result set.void
remove()
void
skip(long skipNum)
Skip a number ofNode
s in this iterator.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.util.Iterator
forEachRemaining
-
-
-
-
Constructor Detail
-
NodeIteratorImpl
public NodeIteratorImpl(ItemManager itemMgr, HierarchyManager hierarchyMgr, QueryInfo queryInfo)
Creates a newNodeIteratorImpl
instance.- Parameters:
itemMgr
- TheItemManager
to buildNode
instances.hierarchyMgr
- TheHierarchyManager
used to retrieve the HierarchyEntry objects from the ids returned by the query.queryInfo
- the query result.
-
-
Method Detail
-
getScore
public double getScore() throws NoSuchElementException
Returns the score of the node returned bynextNode()
. In other words, this method returns the score value of the nextNode
.- Specified by:
getScore
in interfaceScoreNodeIterator
- Returns:
- the score of the node returned by
nextNode()
. - Throws:
NoSuchElementException
- if there is no next node.- See Also:
ScoreNodeIterator.getScore()
-
nextNode
public Node nextNode() throws NoSuchElementException
Returns the nextNode
in the result set.- Specified by:
nextNode
in interfaceNodeIterator
- Returns:
- the next
Node
in the result set. - Throws:
NoSuchElementException
- if iteration has no moreNode
s.- See Also:
NodeIterator.nextNode()
-
skip
public void skip(long skipNum) throws NoSuchElementException
Skip a number ofNode
s in this iterator.- Specified by:
skip
in interfaceRangeIterator
- Parameters:
skipNum
- the non-negative number ofNode
s to skip- Throws:
NoSuchElementException
- if skipped past the lastNode
in this iterator.- See Also:
RangeIterator.skip(long)
-
getSize
public long getSize()
Returns the number of nodes in this iterator.Note: The number returned by this method may differ from the number of nodes actually returned by calls to hasNext() / getNextNode()! This is because this iterator works on a lazy instantiation basis and while iterating over the nodes some of them might have been deleted in the meantime. Those will not be returned by getNextNode(). As soon as an invalid node is detected, the size of this iterator is adjusted.
- Specified by:
getSize
in interfaceRangeIterator
- Returns:
- the number of node in this iterator.
- See Also:
RangeIterator.getSize()
-
getPosition
public long getPosition()
Returns the current position in thisNodeIterator
.- Specified by:
getPosition
in interfaceRangeIterator
- Returns:
- the current position in this
NodeIterator
. - See Also:
RangeIterator.getPosition()
-
next
public Object next() throws NoSuchElementException
Returns the nextNode
in the result set.- Specified by:
next
in interfaceIterator
- Returns:
- the next
Node
in the result set. - Throws:
NoSuchElementException
- if iteration has no moreNode
s.- See Also:
Iterator.next()
-
hasNext
public boolean hasNext()
Returnstrue
if there is anotherNode
available;false
otherwise.- Specified by:
hasNext
in interfaceIterator
- Returns:
true
if there is anotherNode
available;false
otherwise.- See Also:
Iterator.hasNext()
-
remove
public void remove()
- Specified by:
remove
in interfaceIterator
- Throws:
UnsupportedOperationException
- always.- See Also:
Iterator.remove()
-
-