com.amazon.carbonado.cursor
Class MultiTransformedCursor<S,T>

java.lang.Object
  extended by com.amazon.carbonado.cursor.AbstractCursor<T>
      extended by com.amazon.carbonado.cursor.MultiTransformedCursor<S,T>
Type Parameters:
S - source type, can be anything
T - target type, can be anything
All Implemented Interfaces:
Cursor<T>

public abstract class MultiTransformedCursor<S,T>
extends AbstractCursor<T>

Abstract cursor which wraps another cursor and transforms each storable result into a set of target storables. This class can be used for implementing one-to-many joins. Use TransformedCursor for one-to-one joins.

Author:
Brian S O'Neill

Constructor Summary
protected MultiTransformedCursor(Cursor<S> cursor)
           
 
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.
 T next()
          Returns the next element from this cursor.
 int skipNext(int amount)
          Skips forward by the specified amount of elements, returning the actual amount skipped.
protected abstract  Cursor<T> transform(S storable)
          This method must be implemented to transform storables.
 
Methods inherited from class com.amazon.carbonado.cursor.AbstractCursor
copyInto, copyInto, toList, toList
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MultiTransformedCursor

protected MultiTransformedCursor(Cursor<S> cursor)
Method Detail

transform

protected abstract Cursor<T> transform(S storable)
                                throws FetchException
This method must be implemented to transform storables. If the storable cannot be transformed, either throw a FetchException or return null. If null is returned, the storable is simply filtered out.

Returns:
transformed storables, or null to filter it out
Throws:
FetchException

close

public void close()
           throws FetchException
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.

Throws:
FetchException

hasNext

public boolean hasNext()
                throws FetchException
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.

Throws:
FetchException - if storage layer throws an exception

next

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

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<T>
Overrides:
skipNext in class AbstractCursor<T>
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.