public class SingletonCursor<S> extends java.lang.Object implements Cursor<S>
EmptyCursor
Constructor and Description |
---|
SingletonCursor(S object) |
Modifier and Type | Method and Description |
---|---|
void |
close()
Call close to release any resources being held by this cursor.
|
int |
copyInto(java.util.Collection<? super S> c)
Copies all remaining next elements into the given collection.
|
int |
copyInto(java.util.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.
|
java.util.List<S> |
toList()
Copies all remaining next elements into a new modifiable list.
|
java.util.List<S> |
toList(int limit)
Copies a limited amount of remaining next elements into a new modifiable
list.
|
public SingletonCursor(S object)
object
- single object to return from cursor, must not be nulljava.lang.IllegalArgumentException
- if object is nullpublic void close()
Cursor
public boolean hasNext()
Cursor
next
would return an element rather than throwing
an exception.public S next()
Cursor
public int skipNext(int amount)
Cursor
public int copyInto(java.util.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.
public int copyInto(java.util.Collection<? super S> c, int limit)
Cursor
Cursor cursor; ... while (--limit >= 0 && cursor.hasNext()) { c.add(cursor.next()); }
public java.util.List<S> toList()
Cursor
Cursor<S> cursor; ... List<S> list = new ... cursor.copyInto(list);
As a side-effect of calling this method, the cursor is closed.
Copyright © 2006-2013 Amazon Technologies, Inc.. All Rights Reserved.