simpledb
Class AbstractDbIterator

java.lang.Object
  extended by simpledb.AbstractDbIterator
All Implemented Interfaces:
DbIterator

public abstract class AbstractDbIterator
extends java.lang.Object
implements DbIterator

Helper for implementing DbIterators. Handles hasNext()/next() logic and throwing exceptions if open()/close() are abused.


Field Summary
private  Tuple next
           
 
Constructor Summary
AbstractDbIterator()
           
 
Method Summary
 void close()
          If subclasses override this, they should call super.close().
 boolean hasNext()
           
 Tuple next()
          Gets the next tuple from the operator (typically implementing by reading from a child operator or an access method).
protected abstract  Tuple readNext()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface simpledb.DbIterator
getTupleDesc, open, rewind
 

Field Detail

next

private Tuple next
Constructor Detail

AbstractDbIterator

public AbstractDbIterator()
Method Detail

hasNext

public boolean hasNext()
                throws DbException,
                       TransactionAbortedException
Specified by:
hasNext in interface DbIterator
Returns:
true if the iterator has more items.
Throws:
DbException
TransactionAbortedException

next

public Tuple next()
           throws DbException,
                  TransactionAbortedException,
                  java.util.NoSuchElementException
Description copied from interface: DbIterator
Gets the next tuple from the operator (typically implementing by reading from a child operator or an access method).

Specified by:
next in interface DbIterator
Returns:
The next tuple in the iterator, or null if there are no more tuples.
Throws:
DbException
TransactionAbortedException
java.util.NoSuchElementException

readNext

protected abstract Tuple readNext()
                           throws DbException,
                                  TransactionAbortedException
Returns:
the next Tuple in the iterator, null if the iteration is finished.
Throws:
DbException
TransactionAbortedException

close

public void close()
If subclasses override this, they should call super.close().

Specified by:
close in interface DbIterator