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

java.lang.Object
  extended by com.amazon.carbonado.cursor.AbstractCursor<S>
All Implemented Interfaces:
Cursor<S>
Direct Known Subclasses:
DifferenceCursor, FilteredCursor, GroupedCursor, IntersectionCursor, IteratorCursor, LimitCursor, MultiTransformedCursor, RawCursor, SkipCursor, SortedCursor, SymmetricDifferenceCursor, ThrottledCursor, TransformedCursor, UnionCursor

public abstract class AbstractCursor<S>
extends Object
implements Cursor<S>

AbstractCursor implements a small set of common Cursor methods.

Author:
Brian S O'Neill

Constructor Summary
protected AbstractCursor()
           
 
Method Summary
 int copyInto(Collection<? super S> c)
          Copies all remaining next elements into the given collection.
 int copyInto(Collection<? super S> c, int limit)
          Copies a limited amount of remaining next elements into the given collection.
 int skipNext(int amount)
          Skips forward by the specified amount of elements, returning the actual amount skipped.
 List<S> toList()
          Copies all remaining next elements into a new modifiable list.
 List<S> toList(int limit)
          Copies a limited amount of remaining next elements into a new modifiable list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.amazon.carbonado.Cursor
close, hasNext, next
 

Constructor Detail

AbstractCursor

protected AbstractCursor()
Method Detail

copyInto

public int copyInto(Collection<? super S> c)
             throws FetchException
Description copied from interface: Cursor
Copies all remaining next elements into the given collection. This method is roughly equivalent to the following:
 Cursor cursor;
 ...
 while (cursor.hasNext()) {
     c.add(cursor.next());
 }
 

As a side-effect of calling this method, the cursor is closed.

Specified by:
copyInto in interface Cursor<S>
Returns:
actual amount of results added
Throws:
FetchException - if storage layer throws an exception

copyInto

public int copyInto(Collection<? super S> c,
                    int limit)
             throws FetchException
Description copied from interface: Cursor
Copies a limited amount of remaining next elements into the given collection. This method is roughly equivalent to the following:
 Cursor cursor;
 ...
 while (--limit >= 0 && cursor.hasNext()) {
     c.add(cursor.next());
 }
 

Specified by:
copyInto in interface Cursor<S>
limit - maximum amount of elements to copy
Returns:
actual amount of results added
Throws:
FetchException - if storage layer throws an exception

toList

public List<S> toList()
               throws FetchException
Description copied from interface: Cursor
Copies all remaining next elements into a new modifiable list. This method is roughly equivalent to the following:
 Cursor<S> cursor;
 ...
 List<S> list = new ...
 cursor.copyInto(list);
 

As a side-effect of calling this method, the cursor is closed.

Specified by:
toList in interface Cursor<S>
Returns:
a new modifiable list
Throws:
FetchException - if storage layer throws an exception

toList

public List<S> toList(int limit)
               throws FetchException
Description copied from interface: Cursor
Copies a limited amount of remaining next elements into a new modifiable list. This method is roughly equivalent to the following:
 Cursor<S> cursor;
 ...
 List<S> list = new ...
 cursor.copyInto(list, limit);
 

Specified by:
toList in interface Cursor<S>
Parameters:
limit - maximum amount of elements to copy
Returns:
a new modifiable list
Throws:
FetchException - if storage layer throws an exception

skipNext

public int skipNext(int amount)
             throws FetchException
Description copied from interface: Cursor
Skips forward by the specified amount of elements, returning the actual amount skipped. The actual amount is less than the requested amount only if the end of the results was reached.

Specified by:
skipNext in interface Cursor<S>
Parameters:
amount - maximum amount of elements to skip
Returns:
actual amount skipped
Throws:
FetchException - if storage layer throws an exception


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