com.sleepycat.util.keyrange

Class RangeCursor

public class RangeCursor extends Object implements Cloneable

A cursor-like interface that enforces a key range. The method signatures are actually those of SecondaryCursor, but the pKey parameter may be null. It was done this way to avoid doubling the number of methods.

This is not a fully general implementation of a range cursor and should not be used directly by applications; however, it may evolve into a generally useful range cursor some day.

Constructor Summary
RangeCursor(KeyRange range, Cursor cursor)
Creates a range cursor.
RangeCursor(KeyRange range, KeyRange pkRange, Cursor cursor)
Creates a range cursor with a duplicate range.
Method Summary
protected booleancheckRecordNumber()
If the database is a RECNO or QUEUE database, we know its keys are record numbers.
voidclose()
protected voidcloseCursor(Cursor cursor)
Closes the given cursor.
intcount()
OperationStatusdelete()
RangeCursordup(boolean samePosition)
Create a cloned range cursor.
protected CursordupCursor(Cursor cursor, boolean samePosition)
Dups the given cursor.
OperationStatusgetCurrent(DatabaseEntry key, DatabaseEntry pKey, DatabaseEntry data, LockMode lockMode)
CursorgetCursor()
Returns the underlying cursor.
OperationStatusgetFirst(DatabaseEntry key, DatabaseEntry pKey, DatabaseEntry data, LockMode lockMode)
OperationStatusgetLast(DatabaseEntry key, DatabaseEntry pKey, DatabaseEntry data, LockMode lockMode)
OperationStatusgetNext(DatabaseEntry key, DatabaseEntry pKey, DatabaseEntry data, LockMode lockMode)
OperationStatusgetNextDup(DatabaseEntry key, DatabaseEntry pKey, DatabaseEntry data, LockMode lockMode)
OperationStatusgetNextNoDup(DatabaseEntry key, DatabaseEntry pKey, DatabaseEntry data, LockMode lockMode)
OperationStatusgetPrev(DatabaseEntry key, DatabaseEntry pKey, DatabaseEntry data, LockMode lockMode)
OperationStatusgetPrevDup(DatabaseEntry key, DatabaseEntry pKey, DatabaseEntry data, LockMode lockMode)
OperationStatusgetPrevNoDup(DatabaseEntry key, DatabaseEntry pKey, DatabaseEntry data, LockMode lockMode)
OperationStatusgetSearchBoth(DatabaseEntry key, DatabaseEntry pKey, DatabaseEntry data, LockMode lockMode)
OperationStatusgetSearchBothRange(DatabaseEntry key, DatabaseEntry pKey, DatabaseEntry data, LockMode lockMode)
OperationStatusgetSearchKey(DatabaseEntry key, DatabaseEntry pKey, DatabaseEntry data, LockMode lockMode)
OperationStatusgetSearchKeyRange(DatabaseEntry key, DatabaseEntry pKey, DatabaseEntry data, LockMode lockMode)
OperationStatusgetSearchRecordNumber(DatabaseEntry key, DatabaseEntry pKey, DatabaseEntry data, LockMode lockMode)
booleanisInitialized()
Returns whether the cursor is initialized at a valid position.
OperationStatusput(DatabaseEntry key, DatabaseEntry data)
OperationStatusputAfter(DatabaseEntry key, DatabaseEntry data)
OperationStatusputBefore(DatabaseEntry key, DatabaseEntry data)
OperationStatusputCurrent(DatabaseEntry data)
OperationStatusputNoDupData(DatabaseEntry key, DatabaseEntry data)
OperationStatusputNoOverwrite(DatabaseEntry key, DatabaseEntry data)

Constructor Detail

RangeCursor

public RangeCursor(KeyRange range, Cursor cursor)
Creates a range cursor.

RangeCursor

public RangeCursor(KeyRange range, KeyRange pkRange, Cursor cursor)
Creates a range cursor with a duplicate range.

Method Detail

checkRecordNumber

protected boolean checkRecordNumber()
If the database is a RECNO or QUEUE database, we know its keys are record numbers. We treat a non-positive record number as out of bounds, that is, we return NOTFOUND rather than throwing IllegalArgumentException as would happen if we passed a non-positive record number into the DB cursor. This behavior is required by the collections interface.

close

public void close()

closeCursor

protected void closeCursor(Cursor cursor)
Closes the given cursor.

count

public int count()

delete

public OperationStatus delete()

dup

public RangeCursor dup(boolean samePosition)
Create a cloned range cursor. The caller must clone the underlying cursor before using this constructor, because cursor open/close is handled specially for CDS cursors outside this class.

dupCursor

protected Cursor dupCursor(Cursor cursor, boolean samePosition)
Dups the given cursor.

getCurrent

public OperationStatus getCurrent(DatabaseEntry key, DatabaseEntry pKey, DatabaseEntry data, LockMode lockMode)

getCursor

public Cursor getCursor()
Returns the underlying cursor. Used for cloning.

getFirst

public OperationStatus getFirst(DatabaseEntry key, DatabaseEntry pKey, DatabaseEntry data, LockMode lockMode)

getLast

public OperationStatus getLast(DatabaseEntry key, DatabaseEntry pKey, DatabaseEntry data, LockMode lockMode)

getNext

public OperationStatus getNext(DatabaseEntry key, DatabaseEntry pKey, DatabaseEntry data, LockMode lockMode)

getNextDup

public OperationStatus getNextDup(DatabaseEntry key, DatabaseEntry pKey, DatabaseEntry data, LockMode lockMode)

getNextNoDup

public OperationStatus getNextNoDup(DatabaseEntry key, DatabaseEntry pKey, DatabaseEntry data, LockMode lockMode)

getPrev

public OperationStatus getPrev(DatabaseEntry key, DatabaseEntry pKey, DatabaseEntry data, LockMode lockMode)

getPrevDup

public OperationStatus getPrevDup(DatabaseEntry key, DatabaseEntry pKey, DatabaseEntry data, LockMode lockMode)

getPrevNoDup

public OperationStatus getPrevNoDup(DatabaseEntry key, DatabaseEntry pKey, DatabaseEntry data, LockMode lockMode)

getSearchBoth

public OperationStatus getSearchBoth(DatabaseEntry key, DatabaseEntry pKey, DatabaseEntry data, LockMode lockMode)

getSearchBothRange

public OperationStatus getSearchBothRange(DatabaseEntry key, DatabaseEntry pKey, DatabaseEntry data, LockMode lockMode)

getSearchKey

public OperationStatus getSearchKey(DatabaseEntry key, DatabaseEntry pKey, DatabaseEntry data, LockMode lockMode)

getSearchKeyRange

public OperationStatus getSearchKeyRange(DatabaseEntry key, DatabaseEntry pKey, DatabaseEntry data, LockMode lockMode)

getSearchRecordNumber

public OperationStatus getSearchRecordNumber(DatabaseEntry key, DatabaseEntry pKey, DatabaseEntry data, LockMode lockMode)

isInitialized

public boolean isInitialized()
Returns whether the cursor is initialized at a valid position.

put

public OperationStatus put(DatabaseEntry key, DatabaseEntry data)

putAfter

public OperationStatus putAfter(DatabaseEntry key, DatabaseEntry data)

putBefore

public OperationStatus putBefore(DatabaseEntry key, DatabaseEntry data)

putCurrent

public OperationStatus putCurrent(DatabaseEntry data)

putNoDupData

public OperationStatus putNoDupData(DatabaseEntry key, DatabaseEntry data)

putNoOverwrite

public OperationStatus putNoOverwrite(DatabaseEntry key, DatabaseEntry data)