com.sleepycat.collections
Class DataCursor

java.lang.Object
  extended by com.sleepycat.collections.DataCursor
All Implemented Interfaces:
Cloneable

final class DataCursor
extends Object
implements Cloneable

Represents a Berkeley DB cursor and adds support for indices, bindings and key ranges.

This class operates on a view and takes care of reading and updating indices, calling bindings, constraining access to a key range, etc.

Author:
Mark Hayes

Constructor Summary
DataCursor(DataView view, boolean writeAllowed)
          Creates a cursor for a given view.
DataCursor(DataView view, boolean writeAllowed, Object singleKey)
          Creates a cursor for a given view and single key range.
DataCursor(DataView view, boolean writeAllowed, Object beginKey, boolean beginInclusive, Object endKey, boolean endInclusive)
          Creates a cursor for a given view and key range.
DataCursor(DataView view, DataCursor[] indexCursors, JoinConfig joinConfig, boolean closeIndexCursors)
          Creates a join cursor.
 
Method Summary
(package private)  DataCursor cloneCursor()
          Clones a cursor preserving the current position.
(package private)  void close()
          Closes the associated cursor.
(package private)  int count()
          Calls Cursor.count(), no join cursor allowed.
(package private)  OperationStatus delete()
          Perform an arbitrary database 'delete' operation.
(package private)  OperationStatus find(Object value, boolean findFirst)
          Find the given value using getSearchBoth if possible or a sequential scan otherwise, no join cursor allowed.
(package private)  OperationStatus getCurrent(boolean lockForWrite)
          Binding version of Cursor.getCurrent(), no join cursor allowed.
(package private)  Object getCurrentKey()
          Returns the key object for the last record read.
(package private)  int getCurrentRecordNumber()
          Returns the record number for the last record read.
(package private)  Object getCurrentValue()
          Returns the value object for the last record read.
(package private)  RangeCursor getCursor()
          Returns the internal range cursor.
(package private)  OperationStatus getFirst(boolean lockForWrite)
          Binding version of Cursor.getFirst(), join cursor is allowed.
(package private)  OperationStatus getLast(boolean lockForWrite)
          Binding version of Cursor.getLast(), no join cursor allowed.
(package private)  LockMode getLockMode(boolean lockForWrite)
          Returns the lock mode to use for a getXxx() operation.
(package private)  OperationStatus getNext(boolean lockForWrite)
          Binding version of Cursor.getNext(), join cursor is allowed.
(package private)  OperationStatus getNextDup(boolean lockForWrite)
          Binding version of Cursor.getNextDup(), no join cursor allowed.
(package private)  OperationStatus getNextNoDup(boolean lockForWrite)
          Binding version of Cursor.getNext(), join cursor is allowed.
(package private)  OperationStatus getPrev(boolean lockForWrite)
          Binding version of Cursor.getPrev(), no join cursor allowed.
(package private)  OperationStatus getPrevDup(boolean lockForWrite)
          Binding version of Cursor.getPrevDup(), no join cursor allowed.
(package private)  OperationStatus getPrevNoDup(boolean lockForWrite)
          Binding version of Cursor.getPrevNoDup(), no join cursor allowed.
(package private)  KeyRange getRange()
          Returns the range for this cursor.
(package private)  OperationStatus getSearchBoth(Object key, Object value, boolean lockForWrite)
          Binding version of Cursor.getSearchBoth(), no join cursor allowed.
(package private)  OperationStatus getSearchKey(Object key, Object value, boolean lockForWrite)
          Binding version of Cursor.getSearchKey(), no join cursor allowed.
(package private)  OperationStatus getSearchKeyRange(Object key, Object value, boolean lockForWrite)
          Binding version of Cursor.getSearchKeyRange(), no join cursor allowed.
(package private)  DataView getView()
          Returns the view for this cursor.
(package private)  boolean hasRecNumAccess()
          Returns whether record number access is allowed.
(package private)  boolean isWriteAllowed()
          Returns whether write is allowed for this cursor, as specified to the constructor.
(package private)  OperationStatus put(Object key, Object value, Object[] oldValue, boolean useCurrentKey)
          Binding version of Cursor.put(), optionally returning the old value and optionally using the current key instead of the key parameter.
(package private)  OperationStatus putAfter(Object value)
          Binding version of Cursor.putAfter().
(package private)  OperationStatus putBefore(Object value)
          Binding version of Cursor.putBefore().
(package private)  OperationStatus putCurrent(Object value)
          Binding version of Cursor.putCurrent().
(package private)  OperationStatus putNoDupData(Object key, Object value, Object[] oldValue, boolean useCurrentKey)
          Binding version of Cursor.putNoDupData(), optionally returning the old value and optionally using the current key instead of the key parameter.
(package private)  OperationStatus putNoOverwrite(Object key, Object value, boolean useCurrentKey)
          Binding version of Cursor.putNoOverwrite(), optionally using the current key instead of the key parameter.
(package private)  void useRangeKey()
          Sets the key entry to the begin key of a single key range, so the next time a putXxx() method is called that key will be used.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataCursor

DataCursor(DataView view,
           boolean writeAllowed)
     throws DatabaseException
Creates a cursor for a given view.

Throws:
DatabaseException

DataCursor

DataCursor(DataView view,
           boolean writeAllowed,
           Object singleKey)
     throws DatabaseException
Creates a cursor for a given view and single key range.

Throws:
DatabaseException

DataCursor

DataCursor(DataView view,
           boolean writeAllowed,
           Object beginKey,
           boolean beginInclusive,
           Object endKey,
           boolean endInclusive)
     throws DatabaseException
Creates a cursor for a given view and key range.

Throws:
DatabaseException

DataCursor

DataCursor(DataView view,
           DataCursor[] indexCursors,
           JoinConfig joinConfig,
           boolean closeIndexCursors)
     throws DatabaseException
Creates a join cursor.

Throws:
DatabaseException
Method Detail

cloneCursor

DataCursor cloneCursor()
                 throws DatabaseException
Clones a cursor preserving the current position.

Throws:
DatabaseException

getCursor

RangeCursor getCursor()
Returns the internal range cursor.


close

void close()
     throws DatabaseException
Closes the associated cursor.

Throws:
DatabaseException

getView

DataView getView()
Returns the view for this cursor.


getRange

KeyRange getRange()
Returns the range for this cursor.


isWriteAllowed

boolean isWriteAllowed()
Returns whether write is allowed for this cursor, as specified to the constructor.


getCurrentKey

Object getCurrentKey()
               throws DatabaseException
Returns the key object for the last record read.

Throws:
DatabaseException

getCurrentValue

Object getCurrentValue()
                 throws DatabaseException
Returns the value object for the last record read.

Throws:
DatabaseException

hasRecNumAccess

boolean hasRecNumAccess()
Returns whether record number access is allowed.


getCurrentRecordNumber

int getCurrentRecordNumber()
                     throws DatabaseException
Returns the record number for the last record read.

Throws:
DatabaseException

getCurrent

OperationStatus getCurrent(boolean lockForWrite)
                     throws DatabaseException
Binding version of Cursor.getCurrent(), no join cursor allowed.

Throws:
DatabaseException

getFirst

OperationStatus getFirst(boolean lockForWrite)
                   throws DatabaseException
Binding version of Cursor.getFirst(), join cursor is allowed.

Throws:
DatabaseException

getNext

OperationStatus getNext(boolean lockForWrite)
                  throws DatabaseException
Binding version of Cursor.getNext(), join cursor is allowed.

Throws:
DatabaseException

getNextNoDup

OperationStatus getNextNoDup(boolean lockForWrite)
                       throws DatabaseException
Binding version of Cursor.getNext(), join cursor is allowed.

Throws:
DatabaseException

getNextDup

OperationStatus getNextDup(boolean lockForWrite)
                     throws DatabaseException
Binding version of Cursor.getNextDup(), no join cursor allowed.

Throws:
DatabaseException

getLast

OperationStatus getLast(boolean lockForWrite)
                  throws DatabaseException
Binding version of Cursor.getLast(), no join cursor allowed.

Throws:
DatabaseException

getPrev

OperationStatus getPrev(boolean lockForWrite)
                  throws DatabaseException
Binding version of Cursor.getPrev(), no join cursor allowed.

Throws:
DatabaseException

getPrevNoDup

OperationStatus getPrevNoDup(boolean lockForWrite)
                       throws DatabaseException
Binding version of Cursor.getPrevNoDup(), no join cursor allowed.

Throws:
DatabaseException

getPrevDup

OperationStatus getPrevDup(boolean lockForWrite)
                     throws DatabaseException
Binding version of Cursor.getPrevDup(), no join cursor allowed.

Throws:
DatabaseException

getSearchKey

OperationStatus getSearchKey(Object key,
                             Object value,
                             boolean lockForWrite)
                       throws DatabaseException
Binding version of Cursor.getSearchKey(), no join cursor allowed. Searches by record number in a BTREE-RECNO db with RECNO access.

Throws:
DatabaseException

getSearchKeyRange

OperationStatus getSearchKeyRange(Object key,
                                  Object value,
                                  boolean lockForWrite)
                            throws DatabaseException
Binding version of Cursor.getSearchKeyRange(), no join cursor allowed.

Throws:
DatabaseException

getSearchBoth

OperationStatus getSearchBoth(Object key,
                              Object value,
                              boolean lockForWrite)
                        throws DatabaseException
Binding version of Cursor.getSearchBoth(), no join cursor allowed. Unlike SecondaryCursor.getSearchBoth, for a secondary this searches for the primary value not the primary key.

Throws:
DatabaseException

find

OperationStatus find(Object value,
                     boolean findFirst)
               throws DatabaseException
Find the given value using getSearchBoth if possible or a sequential scan otherwise, no join cursor allowed.

Throws:
DatabaseException

count

int count()
    throws DatabaseException
Calls Cursor.count(), no join cursor allowed.

Throws:
DatabaseException

putCurrent

OperationStatus putCurrent(Object value)
                     throws DatabaseException
Binding version of Cursor.putCurrent().

Throws:
DatabaseException

putAfter

OperationStatus putAfter(Object value)
                   throws DatabaseException
Binding version of Cursor.putAfter().

Throws:
DatabaseException

putBefore

OperationStatus putBefore(Object value)
                    throws DatabaseException
Binding version of Cursor.putBefore().

Throws:
DatabaseException

put

OperationStatus put(Object key,
                    Object value,
                    Object[] oldValue,
                    boolean useCurrentKey)
              throws DatabaseException
Binding version of Cursor.put(), optionally returning the old value and optionally using the current key instead of the key parameter.

Throws:
DatabaseException

putNoOverwrite

OperationStatus putNoOverwrite(Object key,
                               Object value,
                               boolean useCurrentKey)
                         throws DatabaseException
Binding version of Cursor.putNoOverwrite(), optionally using the current key instead of the key parameter.

Throws:
DatabaseException

putNoDupData

OperationStatus putNoDupData(Object key,
                             Object value,
                             Object[] oldValue,
                             boolean useCurrentKey)
                       throws DatabaseException
Binding version of Cursor.putNoDupData(), optionally returning the old value and optionally using the current key instead of the key parameter.

Throws:
DatabaseException

useRangeKey

void useRangeKey()
Sets the key entry to the begin key of a single key range, so the next time a putXxx() method is called that key will be used.


delete

OperationStatus delete()
                 throws DatabaseException
Perform an arbitrary database 'delete' operation.

Throws:
DatabaseException

getLockMode

LockMode getLockMode(boolean lockForWrite)
Returns the lock mode to use for a getXxx() operation.



Copyright 2004-2005 Sleepycat, Inc. All Rights Reserved.