org.apache.jackrabbit.jcr2spi.query
Class NodeIteratorImpl

java.lang.Object
  extended by org.apache.jackrabbit.jcr2spi.query.NodeIteratorImpl
All Implemented Interfaces:
Iterator, NodeIterator, RangeIterator, ScoreNodeIterator

public class NodeIteratorImpl
extends Object
implements ScoreNodeIterator

Implements a NodeIterator returned by QueryResult.getNodes().


Constructor Summary
NodeIteratorImpl(ItemManager itemMgr, HierarchyManager hierarchyMgr, QueryInfo queryInfo)
          Creates a new NodeIteratorImpl instance.
 
Method Summary
 long getPosition()
          Returns the current position in this NodeIterator.
 double getScore()
          Returns the score of the node returned by nextNode().
 long getSize()
          Returns the number of nodes in this iterator.
 boolean hasNext()
          Returns true if there is another Node available; false otherwise.
 Object next()
          Returns the next Node in the result set.
 Node nextNode()
          Returns the next Node in the result set.
 void remove()
           
 void skip(long skipNum)
          Skip a number of Nodes in this iterator.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NodeIteratorImpl

public NodeIteratorImpl(ItemManager itemMgr,
                        HierarchyManager hierarchyMgr,
                        QueryInfo queryInfo)
Creates a new NodeIteratorImpl instance.

Parameters:
itemMgr - The ItemManager to build Node instances.
hierarchyMgr - The HierarchyManager 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 by nextNode(). In other words, this method returns the score value of the next Node.

Specified by:
getScore in interface ScoreNodeIterator
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 next Node in the result set.

Specified by:
nextNode in interface NodeIterator
Returns:
the next Node in the result set.
Throws:
NoSuchElementException - if iteration has no more Nodes.
See Also:
NodeIterator.nextNode()

skip

public void skip(long skipNum)
          throws NoSuchElementException
Skip a number of Nodes in this iterator.

Specified by:
skip in interface RangeIterator
Parameters:
skipNum - the non-negative number of Nodes to skip
Throws:
NoSuchElementException - if skipped past the last Node 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 interface RangeIterator
Returns:
the number of node in this iterator.
See Also:
RangeIterator.getSize()

getPosition

public long getPosition()
Returns the current position in this NodeIterator.

Specified by:
getPosition in interface RangeIterator
Returns:
the current position in this NodeIterator.
See Also:
RangeIterator.getPosition()

next

public Object next()
            throws NoSuchElementException
Returns the next Node in the result set.

Specified by:
next in interface Iterator
Returns:
the next Node in the result set.
Throws:
NoSuchElementException - if iteration has no more Nodes.
See Also:
Iterator.next()

hasNext

public boolean hasNext()
Returns true if there is another Node available; false otherwise.

Specified by:
hasNext in interface Iterator
Returns:
true if there is another Node available; false otherwise.
See Also:
Iterator.hasNext()

remove

public void remove()
Specified by:
remove in interface Iterator
Throws:
UnsupportedOperationException - always.
See Also:
Iterator.remove()


Copyright © 2004-2010 The Apache Software Foundation. All Rights Reserved.