|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.amazon.carbonado.cursor.SingletonCursor<S>
public class SingletonCursor<S>
Special cursor implementation that returns only one element.
EmptyCursor| Constructor Summary | |
|---|---|
SingletonCursor(S object)
|
|
| Method Summary | |
|---|---|
void |
close()
Call close to release any resources being held by this cursor. |
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. |
boolean |
hasNext()
Returns true if this cursor has more elements. |
S |
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. |
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 |
| Constructor Detail |
|---|
public SingletonCursor(S object)
object - single object to return from cursor, must not be null
IllegalArgumentException - if object is null| Method Detail |
|---|
public void close()
Cursor
close in interface Cursor<S>public boolean hasNext()
Cursornext would return an element rather than throwing
an exception.
hasNext in interface Cursor<S>public S next()
Cursor
next in interface Cursor<S>public int skipNext(int amount)
Cursor
skipNext in interface Cursor<S>amount - maximum amount of elements to skip
public int copyInto(Collection<? super S> c)
Cursor
Cursor cursor;
...
while (cursor.hasNext()) {
c.add(cursor.next());
}
As a side-effect of calling this method, the cursor is closed.
copyInto in interface Cursor<S>
public int copyInto(Collection<? super S> c,
int limit)
Cursor
Cursor cursor;
...
while (--limit >= 0 && cursor.hasNext()) {
c.add(cursor.next());
}
copyInto in interface Cursor<S>limit - maximum amount of elements to copy
public List<S> toList()
CursorCursor<S> cursor; ... List<S> list = new ... cursor.copyInto(list);
As a side-effect of calling this method, the cursor is closed.
toList in interface Cursor<S>public List<S> toList(int limit)
CursorCursor<S> cursor; ... List<S> list = new ... cursor.copyInto(list, limit);
toList in interface Cursor<S>limit - maximum amount of elements to copy
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||