3.1.5.1. Bi-directional RangeIterator

QueryResult.getNodes() will return bi-directional NodeIterator implementation.

Note

Bi-directional NodeIterator is not supported in two following cases:

  • SQL query: select * from nt:base.

  • XPath query: //*.

TwoWayRangeIterator interface:

/**

 * Skip a number of elements in the iterator.
 * 
 * @param skipNum the non-negative number of elements to skip
 * @throws java.util.NoSuchElementException if skipped past the first element
 *           in the iterator.
 */
public void skipBack(long skipNum);

Usage:

NodeIterator iter = queryResult.getNodes();

while (iter.hasNext()) {
  if (skipForward) {
    iter.skip(10); // Skip 10 nodes in forward direction
  } else if (skipBack) {
    TwoWayRangeIterator backIter = (TwoWayRangeIterator) iter; 
    backIter.skipBack(10); // Skip 10 nodes back 
  }
  .......
}
Copyright ©. All rights reserved. eXo Platform SAS
blog comments powered byDisqus