class BasicCursor<V> extends java.lang.Object implements EntityCursor<V>
| Modifier and Type | Field and Description |
|---|---|
(package private) ValueAdapter<V> |
adapter |
(package private) RangeCursor |
cursor |
(package private) DatabaseEntry |
data |
(package private) DatabaseEntry |
key |
(package private) DatabaseEntry |
pkey |
(package private) boolean |
updateAllowed |
| Constructor and Description |
|---|
BasicCursor(RangeCursor cursor,
ValueAdapter<V> adapter,
boolean updateAllowed) |
| Modifier and Type | Method and Description |
|---|---|
(package private) void |
checkInitialized() |
void |
close()
Closes the cursor.
|
int |
count()
Returns the number of values (duplicates) for the key at the cursor
position, or returns zero if all values for the key have been deleted.
|
long |
countEstimate()
Returns a rough estimate of the number of values (duplicates) for the
key at the cursor position, or returns zero if all values for the key
have been deleted.
|
V |
current()
Returns the value at the cursor position, or null if the value at the
cursor position has been deleted.
|
V |
current(LockMode lockMode)
Returns the value at the cursor position, or null if the value at the
cursor position has been deleted.
|
boolean |
delete()
Deletes the entity at the cursor position.
|
EntityCursor<V> |
dup()
Duplicates the cursor at the cursor position.
|
V |
first()
Moves the cursor to the first value and returns it, or returns null if
the cursor range is empty.
|
V |
first(LockMode lockMode)
Moves the cursor to the first value and returns it, or returns null if
the cursor range is empty.
|
CacheMode |
getCacheMode()
Returns the
CacheMode used for operations performed using this
cursor. |
java.util.Iterator<V> |
iterator()
Returns an iterator over the key range, starting with the value
following the current position or at the first value if the cursor is
uninitialized.
|
java.util.Iterator<V> |
iterator(LockMode lockMode)
Returns an iterator over the key range, starting with the value
following the current position or at the first value if the cursor is
uninitialized.
|
V |
last()
Moves the cursor to the last value and returns it, or returns null if
the cursor range is empty.
|
V |
last(LockMode lockMode)
Moves the cursor to the last value and returns it, or returns null if
the cursor range is empty.
|
V |
next()
Moves the cursor to the next value and returns it, or returns null
if there are no more values in the cursor range.
|
V |
next(LockMode lockMode)
Moves the cursor to the next value and returns it, or returns null
if there are no more values in the cursor range.
|
V |
nextDup()
Moves the cursor to the next value with the same key (duplicate) and
returns it, or returns null if no more values are present for the key at
the current position.
|
V |
nextDup(LockMode lockMode)
Moves the cursor to the next value with the same key (duplicate) and
returns it, or returns null if no more values are present for the key at
the current position.
|
V |
nextNoDup()
Moves the cursor to the next value with a different key and returns it,
or returns null if there are no more unique keys in the cursor range.
|
V |
nextNoDup(LockMode lockMode)
Moves the cursor to the next value with a different key and returns it,
or returns null if there are no more unique keys in the cursor range.
|
V |
prev()
Moves the cursor to the previous value and returns it, or returns null
if there are no preceding values in the cursor range.
|
V |
prev(LockMode lockMode)
Moves the cursor to the previous value and returns it, or returns null
if there are no preceding values in the cursor range.
|
V |
prevDup()
Moves the cursor to the previous value with the same key (duplicate) and
returns it, or returns null if no preceding values are present for the
key at the current position.
|
V |
prevDup(LockMode lockMode)
Moves the cursor to the previous value with the same key (duplicate) and
returns it, or returns null if no preceding values are present for the
key at the current position.
|
V |
prevNoDup()
Moves the cursor to the preceding value with a different key and returns
it, or returns null if there are no preceding unique keys in the cursor
range.
|
V |
prevNoDup(LockMode lockMode)
Moves the cursor to the preceding value with a different key and returns
it, or returns null if there are no preceding unique keys in the cursor
range.
|
(package private) V |
returnValue(OperationStatus status) |
void |
setCacheMode(CacheMode cacheMode)
Changes the
CacheMode used for operations performed using this
cursor. |
boolean |
update(V entity)
Replaces the entity at the cursor position with the given entity.
|
RangeCursor cursor
ValueAdapter<V> adapter
boolean updateAllowed
DatabaseEntry key
DatabaseEntry pkey
DatabaseEntry data
BasicCursor(RangeCursor cursor, ValueAdapter<V> adapter, boolean updateAllowed)
public V first() throws DatabaseException
EntityCursorLockMode.DEFAULT is used implicitly.
first in interface EntityCursor<V>OperationFailureException - if one of the Read Operation
Failures occurs.EnvironmentFailureException - if an unexpected, internal or
environment-wide failure occurs.
DatabaseException - the base class for all BDB exceptions.public V first(LockMode lockMode) throws DatabaseException
EntityCursorfirst in interface EntityCursor<V>lockMode - the lock mode to use for this operation, or null to
use LockMode.DEFAULT.OperationFailureException - if one of the Read Operation
Failures occurs.EnvironmentFailureException - if an unexpected, internal or
environment-wide failure occurs.
DatabaseException - the base class for all BDB exceptions.public V last() throws DatabaseException
EntityCursorLockMode.DEFAULT is used implicitly.
last in interface EntityCursor<V>OperationFailureException - if one of the Read Operation
Failures occurs.EnvironmentFailureException - if an unexpected, internal or
environment-wide failure occurs.
DatabaseException - the base class for all BDB exceptions.public V last(LockMode lockMode) throws DatabaseException
EntityCursorlast in interface EntityCursor<V>lockMode - the lock mode to use for this operation, or null to
use LockMode.DEFAULT.OperationFailureException - if one of the Read Operation
Failures occurs.EnvironmentFailureException - if an unexpected, internal or
environment-wide failure occurs.
DatabaseException - the base class for all BDB exceptions.public V next() throws DatabaseException
EntityCursorEntityCursor.first().
LockMode.DEFAULT is used implicitly.
next in interface EntityCursor<V>next in interface ForwardCursor<V>OperationFailureException - if one of the Read Operation
Failures occurs.EnvironmentFailureException - if an unexpected, internal or
environment-wide failure occurs.
DatabaseException - the base class for all BDB exceptions.public V next(LockMode lockMode) throws DatabaseException
EntityCursorEntityCursor.first().next in interface EntityCursor<V>next in interface ForwardCursor<V>lockMode - the lock mode to use for this operation, or null to
use LockMode.DEFAULT.OperationFailureException - if one of the Read Operation
Failures occurs.EnvironmentFailureException - if an unexpected, internal or
environment-wide failure occurs.
DatabaseException - the base class for all BDB exceptions.public V nextDup() throws DatabaseException
EntityCursorLockMode.DEFAULT is used implicitly.
nextDup in interface EntityCursor<V>OperationFailureException - if one of the Read Operation
Failures occurs.EnvironmentFailureException - if an unexpected, internal or
environment-wide failure occurs.
DatabaseException - the base class for all BDB exceptions.public V nextDup(LockMode lockMode) throws DatabaseException
EntityCursornextDup in interface EntityCursor<V>lockMode - the lock mode to use for this operation, or null to
use LockMode.DEFAULT.OperationFailureException - if one of the Read Operation
Failures occurs.EnvironmentFailureException - if an unexpected, internal or
environment-wide failure occurs.
DatabaseException - the base class for all BDB exceptions.public V nextNoDup() throws DatabaseException
EntityCursorEntityCursor.first().
LockMode.DEFAULT is used implicitly.
nextNoDup in interface EntityCursor<V>OperationFailureException - if one of the Read Operation
Failures occurs.EnvironmentFailureException - if an unexpected, internal or
environment-wide failure occurs.
DatabaseException - the base class for all BDB exceptions.public V nextNoDup(LockMode lockMode) throws DatabaseException
EntityCursorEntityCursor.first().nextNoDup in interface EntityCursor<V>lockMode - the lock mode to use for this operation, or null to
use LockMode.DEFAULT.OperationFailureException - if one of the Read Operation
Failures occurs.EnvironmentFailureException - if an unexpected, internal or
environment-wide failure occurs.
DatabaseException - the base class for all BDB exceptions.public V prev() throws DatabaseException
EntityCursorEntityCursor.last().
LockMode.DEFAULT is used implicitly.
prev in interface EntityCursor<V>OperationFailureException - if one of the Read Operation
Failures occurs.EnvironmentFailureException - if an unexpected, internal or
environment-wide failure occurs.
DatabaseException - the base class for all BDB exceptions.public V prev(LockMode lockMode) throws DatabaseException
EntityCursorEntityCursor.last().prev in interface EntityCursor<V>lockMode - the lock mode to use for this operation, or null to
use LockMode.DEFAULT.OperationFailureException - if one of the Read Operation
Failures occurs.EnvironmentFailureException - if an unexpected, internal or
environment-wide failure occurs.
DatabaseException - the base class for all BDB exceptions.public V prevDup() throws DatabaseException
EntityCursorLockMode.DEFAULT is used implicitly.
prevDup in interface EntityCursor<V>OperationFailureException - if one of the Read Operation
Failures occurs.EnvironmentFailureException - if an unexpected, internal or
environment-wide failure occurs.
DatabaseException - the base class for all BDB exceptions.public V prevDup(LockMode lockMode) throws DatabaseException
EntityCursorprevDup in interface EntityCursor<V>lockMode - the lock mode to use for this operation, or null to
use LockMode.DEFAULT.OperationFailureException - if one of the Read Operation
Failures occurs.EnvironmentFailureException - if an unexpected, internal or
environment-wide failure occurs.
DatabaseException - the base class for all BDB exceptions.public V prevNoDup() throws DatabaseException
EntityCursorEntityCursor.last().
LockMode.DEFAULT is used implicitly.
prevNoDup in interface EntityCursor<V>OperationFailureException - if one of the Read Operation
Failures occurs.EnvironmentFailureException - if an unexpected, internal or
environment-wide failure occurs.
DatabaseException - the base class for all BDB exceptions.public V prevNoDup(LockMode lockMode) throws DatabaseException
EntityCursorEntityCursor.last().prevNoDup in interface EntityCursor<V>lockMode - the lock mode to use for this operation, or null to
use LockMode.DEFAULT.OperationFailureException - if one of the Read Operation
Failures occurs.EnvironmentFailureException - if an unexpected, internal or
environment-wide failure occurs.
DatabaseException - the base class for all BDB exceptions.public V current() throws DatabaseException
EntityCursorLockMode.DEFAULT is used implicitly.
current in interface EntityCursor<V>OperationFailureException - if one of the Read Operation
Failures occurs.EnvironmentFailureException - if an unexpected, internal or
environment-wide failure occurs.
DatabaseException - the base class for all BDB exceptions.public V current(LockMode lockMode) throws DatabaseException
EntityCursorcurrent in interface EntityCursor<V>lockMode - the lock mode to use for this operation, or null to
use LockMode.DEFAULT.OperationFailureException - if one of the Read Operation
Failures occurs.EnvironmentFailureException - if an unexpected, internal or
environment-wide failure occurs.
DatabaseException - the base class for all BDB exceptions.public int count()
throws DatabaseException
EntityCursorThe cost of this method is directly proportional to the number of values.
LockMode.DEFAULT is used implicitly.
count in interface EntityCursor<V>OperationFailureException - if one of the Read Operation
Failures occurs.EnvironmentFailureException - if an unexpected, internal or
environment-wide failure occurs.
DatabaseException - the base class for all BDB exceptions.public long countEstimate()
throws DatabaseException
EntityCursorIf the underlying index has non-unique keys, a quick estimate of the
number of values is computed using information in the Btree. Because
the Btree is unbalanced, in some cases the estimate may be off by a
factor of two or more. The estimate is accurate when the number of
records is less than the configured NodeMaxEntries.
The cost of this method is fixed, rather than being proportional to
the number of values. Because its accuracy is variable, this method
should normally be used when accuracy is not required, such as for query
optimization, and a fixed cost operation is needed. For example, this
method is used internally for determining the index processing order in
an EntityJoin.
countEstimate in interface EntityCursor<V>OperationFailureException - if one of the Read Operation
Failures occurs.EnvironmentFailureException - if an unexpected, internal or
environment-wide failure occurs.DatabaseException - the base class for all BDB exceptions.public java.util.Iterator<V> iterator()
EntityCursorLockMode.DEFAULT is used implicitly.
iterator in interface EntityCursor<V>iterator in interface ForwardCursor<V>iterator in interface java.lang.Iterable<V>public java.util.Iterator<V> iterator(LockMode lockMode)
EntityCursoriterator in interface EntityCursor<V>iterator in interface ForwardCursor<V>lockMode - the lock mode to use for all operations performed
using the iterator, or null to use LockMode.DEFAULT.public boolean update(V entity) throws DatabaseException
EntityCursorupdate in interface EntityCursor<V>entity - the entity to replace the entity at the current position.OperationFailureException - if one of the Write
Operation Failures occurs.EnvironmentFailureException - if an unexpected, internal or
environment-wide failure occurs.
DatabaseException - the base class for all BDB exceptions.public boolean delete()
throws DatabaseException
EntityCursordelete in interface EntityCursor<V>OperationFailureException - if one of the Write
Operation Failures occurs.EnvironmentFailureException - if an unexpected, internal or
environment-wide failure occurs.
DatabaseException - the base class for all BDB exceptions.public EntityCursor<V> dup() throws DatabaseException
EntityCursorTransaction and CursorConfig.dup in interface EntityCursor<V>DatabaseException - the base class for all BDB exceptions.public void close()
throws DatabaseException
EntityCursorclose in interface EntityCursor<V>close in interface ForwardCursor<V>close in interface java.io.Closeableclose in interface java.lang.AutoCloseableDatabaseException - the base class for all BDB exceptions.public void setCacheMode(CacheMode cacheMode)
EntityCursorCacheMode used for operations performed using this
cursor. For a newly opened cursor, the default is CacheMode.DEFAULT.setCacheMode in interface EntityCursor<V>cacheMode - is the CacheMode to use for subsequent
operations using this cursor.CacheModepublic CacheMode getCacheMode()
EntityCursorCacheMode used for operations performed using this
cursor. For a newly opened cursor, the default is CacheMode.DEFAULT.getCacheMode in interface EntityCursor<V>CacheModevoid checkInitialized()
throws java.lang.IllegalStateException
java.lang.IllegalStateExceptionV returnValue(OperationStatus status)
Copyright (c) 2004-2012 Oracle. All rights reserved.