org.basex.query.iter
Class ValueIter

java.lang.Object
  extended by org.basex.query.iter.Iter
      extended by org.basex.query.iter.ValueIter
All Implemented Interfaces:
java.lang.Iterable<Item>
Direct Known Subclasses:
ValueBuilder

public abstract class ValueIter
extends Iter
implements java.lang.Iterable<Item>

Value iterator interface, throwing no exceptions. This class also implements the Iterable interface, which is why all of its values can also be retrieved via enhanced for (for-each) loops. Note, however, that using the next() method will give you better performance.

Author:
BaseX Team 2005-12, BSD License, Christian Gruen

Constructor Summary
ValueIter()
           
 
Method Summary
abstract  Item get(long i)
          Returns the specified item, or an arbitrary item if the index is invalid.
 java.util.Iterator<Item> iterator()
           
abstract  Item next()
          Returns the next item or null if no other items are found.
abstract  boolean reset()
          Resets the iterator and returns true if operation was successful.
abstract  long size()
          Returns the iterator size.
 Value value()
          Returns a sequence with all iterator values.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ValueIter

public ValueIter()
Method Detail

next

public abstract Item next()
Description copied from class: Iter
Returns the next item or null if no other items are found.

Specified by:
next in class Iter
Returns:
resulting item or null

get

public abstract Item get(long i)
Description copied from class: Iter
Returns the specified item, or an arbitrary item if the index is invalid. This method needs to be implemented - and should only be called - if Iter.size() returns the correct number of results. A calling method should call Iter.reset() after the last items has been retrieved.

Overrides:
get in class Iter
Parameters:
i - value offset
Returns:
specified item

size

public abstract long size()
Description copied from class: Iter
Returns the iterator size. Note: -1 is returned if the result size is unknown. If this method is implemented by an iterator, Iter.get(long) needs to be implemented as well.

Overrides:
size in class Iter
Returns:
number of entries

reset

public abstract boolean reset()
Description copied from class: Iter
Resets the iterator and returns true if operation was successful. false is returned if the iterator cannot be reset.

Overrides:
reset in class Iter
Returns:
true if operator could be reset

value

public Value value()
Description copied from class: Iter
Returns a sequence with all iterator values. Must only be called if Iter.next() has not been called before.

Overrides:
value in class Iter
Returns:
sequence

iterator

public final java.util.Iterator<Item> iterator()
Specified by:
iterator in interface java.lang.Iterable<Item>