|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Cursor<K,V>
A cursor is used for navigating through the records of a database. (Unlike ordinary database cursors that are used for navigating through result sets from queries, HeliDB cursors are used for navigating through the entire database.)
The order of the database records that a cursor navigates through is determined by the database backend's search order and if an index is added to the database backend.
The cursor interface extends Iterable
. The Iterator
returned
from the Iterable.iterator()
method starts at the current record and iterates
forward through the database. There is also a backwardsIterator()
method that returns an iterator that iterates backwards in the database (if
the database backend supports backwards iteration). The iterators do not
modify the state of their parent cursors.
When a client is done with a cursor, it should close it by calling its
close()
method.
Method Summary | |
---|---|
Iterator<Record<K,V>> |
backwardsIterator()
Get an Iterator that iterates backwards through the database
records starting with the currently referenced record. |
void |
close()
Close and invalidate the cursor. |
Record<K,V> |
get()
Get the record that the cursor is currently referencing. |
K |
getKey()
Get the key of the record that the cursor is currently referencing. |
V |
getValue()
Get the value of the record that the cursor is currently referencing. |
boolean |
hasNext()
Is there a record after the currently referenced record that the cursor can navigate to? |
boolean |
hasPrevious()
Is there a record before the currently referenced record that the cursor can navigate to? |
K |
next()
Navigate to the next record in the database. |
K |
previous()
Navigate to the previous record in the database. |
Methods inherited from interface java.lang.Iterable |
---|
iterator |
Method Detail |
---|
K getKey() throws IllegalStateException, ConcurrentModificationException
IllegalStateException
- If the cursor has been closed.
ConcurrentModificationException
- If the database has been modified
after the cursor was created.V getValue() throws IllegalStateException, ConcurrentModificationException
IllegalStateException
- If the cursor has been closed.
ConcurrentModificationException
- If the database has been modified
after the cursor was created.Record<K,V> get() throws IllegalStateException, ConcurrentModificationException
IllegalStateException
- If the cursor has been closed.
ConcurrentModificationException
- If the database has been modified
after the cursor was created.boolean hasNext() throws IllegalStateException, ConcurrentModificationException
true
if there is another record after the currently
referenced record.
IllegalStateException
- If the cursor has been closed.
ConcurrentModificationException
- If the database has been modified
after the cursor was created.K next() throws IllegalStateException, NoSuchElementException, ConcurrentModificationException
IllegalStateException
- If the cursor has been closed.
ConcurrentModificationException
- If the database has been modified
after the cursor was created.
NoSuchElementException
- If there is no record after the currently
referenced record.boolean hasPrevious() throws IllegalStateException, UnsupportedOperationException, ConcurrentModificationException
true
if there is a record before the currently referenced
record.
IllegalStateException
- If the cursor has been closed.
ConcurrentModificationException
- If the database has been modified
after the cursor was created.
UnsupportedOperationException
- If the database backend does not
support backwards navigation.K previous() throws IllegalStateException, UnsupportedOperationException, ConcurrentModificationException, NoSuchElementException
IllegalStateException
- If the cursor has been closed.
ConcurrentModificationException
- If the database has been modified
after the cursor was created.
UnsupportedOperationException
- If the database backend does not
support backwards navigation.
NoSuchElementException
- If there is no record before the currently
referenced record.Iterator<Record<K,V>> backwardsIterator() throws IllegalStateException, UnsupportedOperationException, ConcurrentModificationException
Iterator
that iterates backwards through the database
records starting with the currently referenced record.
The state of this cursor is not modified by using the iterator.
IllegalStateException
- If the cursor has been closed.
ConcurrentModificationException
- If the database has been modified
after the cursor was created.
UnsupportedOperationException
- If the database backend does not
support backwards iteration.void close()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |