com.amazon.carbonado.cursor
Class IteratorCursor<S>

java.lang.Object
  extended by com.amazon.carbonado.cursor.AbstractCursor<S>
      extended by com.amazon.carbonado.cursor.IteratorCursor<S>
All Implemented Interfaces:
Cursor<S>

public class IteratorCursor<S>
extends AbstractCursor<S>

Adapts an Iterator into a Cursor.

Author:
Brian S O'Neill

Constructor Summary
IteratorCursor(Iterable<S> iterable)
           
IteratorCursor(Iterable<S> iterable, Lock lock)
           
IteratorCursor(Iterator<S> iterator)
           
 
Method Summary
 void close()
          Call close to release any resources being held by this cursor.
 boolean hasNext()
          Returns true if this cursor has more elements.
 S next()
          Returns the next element from this cursor.
 
Methods inherited from class com.amazon.carbonado.cursor.AbstractCursor
copyInto, copyInto, skipNext, toList, toList
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IteratorCursor

public IteratorCursor(Iterable<S> iterable)
Parameters:
iterable - collection to iterate over, or null for empty cursor

IteratorCursor

public IteratorCursor(Iterable<S> iterable,
                      Lock lock)
Parameters:
iterable - collection to iterate over, or null for empty cursor
lock - optional lock to hold while cursor is open

IteratorCursor

public IteratorCursor(Iterator<S> iterator)
Parameters:
iterator - iterator to wrap, or null for empty cursor
Method Detail

close

public void close()
Description copied from interface: Cursor
Call close to release any resources being held by this cursor. Further operations on this cursor will behave as if there are no results.


hasNext

public boolean hasNext()
Description copied from interface: Cursor
Returns true if this cursor has more elements. In other words, returns true if next would return an element rather than throwing an exception.


next

public S next()
Description copied from interface: Cursor
Returns the next element from this cursor. This method may be called repeatedly to iterate through the results.



Copyright © 2006-2009 Amazon Technologies, Inc.. All Rights Reserved.