Berkeley DB version 4.2.52

## com.sleepycat.bdb
Class DataCursor

    java.lang.Object
      |
      +--com.sleepycat.bdb.DataCursor

public final class DataCursor
extends Object

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

NOTE: This classes is internal and may be changed incompatibly or deleted in the future. It is public only so it may be used by subpackages.

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

Constructor Summary
`DataCursor(DataCursor other)` Clones a cursor preserving the current position.
`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.

Method Summary
`void` `close()` Closes a cursor.
`int` `count()` Return the number of duplicates for the current key.
`int` `delete()` Perform an arbitrary database 'delete' operation.
`int` `find(Object value, boolean findFirst)` Find the given value, using DB_GET_BOTH if possible, or a sequential search otherwise.
`int` `get(Object key, Object value, int flag, boolean lockForWrite)` Perform a database 'get' using the given key and value.
`Object` `getCurrentKey()` Returns the key object for the last record read.
`int` `getCurrentRecordNumber()` Returns the record number for the last record read.
`Object` `getCurrentValue()` Returns the value object for the last record read.
`DataView` `getView()` Returns the view for this cursor, as specified to the constructor.
`boolean` `hasRecNumAccess()` Returns whether record number access is allowed.
`boolean` `isWriteAllowed()` Returns whether write is allowed for this cursor, as specified to the constructor.
`int` `put(Object key, Object value, int flag, Object[] oldValue)` Perform an arbitrary database 'put' operation, optionally returning the previous value.
`int` `put(Object key, Object value, int flag, Object[] oldValue, boolean useCurrentKey)` Perform an arbitrary database 'put' operation, optionally using the current key instead of the key parameter.

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### DataCursor

    public DataCursor(DataView view,
                      boolean writeAllowed)
               throws DbException,
                      IOException

  Creates a cursor for a given view.

Parameters:
  `view` - the database view traversed by the cursor.
  `writeAllowed` - whether the cursor can be used for writing.
Throws:
  `DbException` - if a database problem occurs.
  `IOException` - if an IO problem occurs.

### DataCursor

    public DataCursor(DataView view,
                      boolean writeAllowed,
                      Object singleKey)
               throws DbException,
                      IOException

  Creates a cursor for a given view and single key range.

Parameters:
  `view` - the database view traversed by the cursor.
  `writeAllowed` - whether the cursor can be used for writing.
  `singleKey` - the single key value.
Throws:
  `DbException` - if a database problem occurs.
  `IOException` - if an IO problem occurs.

### DataCursor

    public DataCursor(DataView view,
                      boolean writeAllowed,
                      Object beginKey,
                      boolean beginInclusive,
                      Object endKey,
                      boolean endInclusive)
               throws DbException,
                      IOException

  Creates a cursor for a given view and key range.

Parameters:
  `view` - the database view traversed by the cursor.
  `writeAllowed` - whether the cursor can be used for writing.
  `beginKey` - the lower bound.
  `beginInclusive` - whether the lower bound is inclusive.
  `endKey` - the upper bound.
  `endInclusive` - whether the upper bound is inclusive.
Throws:
  `DbException` - if a database problem occurs.
  `IOException` - if an IO problem occurs.

### DataCursor

    public DataCursor(DataCursor other)
               throws DbException,
                      IOException

  Clones a cursor preserving the current position.

Parameters:
  `other` - the cursor to clone.
Throws:
  `DbException` - if a database problem occurs.
  `IOException` - if an IO problem occurs.

Method Detail

### close

    public void close()
               throws DbException,
                      IOException

  Closes a cursor.

  Throws:
    `DbException` - if a database problem occurs.
    `IOException` - if an IO problem occurs.

### getView

    public DataView getView()

  Returns the view for this cursor, as specified to the constructor.

  Returns:
    the view.

### isWriteAllowed

    public boolean isWriteAllowed()

  Returns whether write is allowed for this cursor, as specified to the constructor.

  Returns:
    whether write is allowed.

### getCurrentKey

    public Object getCurrentKey()
                         throws DbException,
                                IOException

  Returns the key object for the last record read.

  Returns:
    the current key object.
  Throws:
    `DbException` - if a database problem occurs.
    `IOException` - if an IO problem occurs.

### getCurrentValue

    public Object getCurrentValue()
                           throws DbException,
                                  IOException

  Returns the value object for the last record read.

  Returns:
    the current value object.
  Throws:
    `DbException` - if a database problem occurs.
    `IOException` - if an IO problem occurs.

### hasRecNumAccess

    public boolean hasRecNumAccess()

  Returns whether record number access is allowed.

  Returns:
    whether record number access is allowed.

### getCurrentRecordNumber

    public int getCurrentRecordNumber()
                               throws DbException,
                                      IOException

  Returns the record number for the last record read.

  Returns:
    the last read record number.
  Throws:
    `DbException` - if a database problem occurs.
    `IOException` - if an IO problem occurs.

### get

    public int get(Object key,
                   Object value,
                   int flag,
                   boolean lockForWrite)
            throws DbException,
                   IOException

  Perform a database 'get' using the given key and value.

  Parameters:
    `key` - the key or null if none is required by the flag.
    `value` - the value or null if none is required by the flag.
    `flag` - a single flag value appropriate for cursor get.
    `lockForWrite` - whether to set the RMW flag.
  Returns:
    an error or zero for success.
  Throws:
    `DbException` - if a database problem occurs.
    `IOException` - if an IO problem occurs.

### find

    public int find(Object value,
                    boolean findFirst)
             throws DbException,
                    IOException

  Find the given value, using DB_GET_BOTH if possible, or a sequential search otherwise.

  Parameters:
    `value` - the value to search for among duplicates at the current position.
    `findFirst` - whether to find the first or last value.
  Returns:
    an error or zero for success.
  Throws:
    `DbException` - if a database problem occurs.
    `IOException` - if an IO problem occurs.

### count

    public int count()
              throws DbException,
                     IOException

  Return the number of duplicates for the current key.

  Returns:
    the number of duplicates.
  Throws:
    `DbException` - if a database problem occurs.
    `IOException` - if an IO problem occurs.

### put

    public int put(Object key,
                   Object value,
                   int flag,
                   Object[] oldValue)
            throws DbException,
                   IOException

  Perform an arbitrary database 'put' operation, optionally returning the previous value.

  Parameters:
    `key` - the key to put.
    `value` - the value to put.
    `flag` - a single flag value appropriate for cursor put.
    `oldValue` - holds the old value, or null if the old value should not be returned.
  Returns:
    an error or zero for success.
  Throws:
    `DbException` - if a database problem occurs.
    `IOException` - if an IO problem occurs.

### put

    public int put(Object key,
                   Object value,
                   int flag,
                   Object[] oldValue,
                   boolean useCurrentKey)
            throws DbException,
                   IOException

  Perform an arbitrary database 'put' operation, optionally using the current key instead of the key parameter.

  Parameters:
    `key` - the key to put.
    `value` - the value to put.
    `flag` - a single flag value appropriate for cursor put.
    `oldValue` - holds the old value, or null if the old value should not be returned.
    `useCurrentKey` - is true to use the current key rather than the key parameter.
  Returns:
    an error or zero for success.
  Throws:
    `DbException` - if a database problem occurs.
    `IOException` - if an IO problem occurs.

### delete

    public int delete()
               throws DbException,
                      IOException

  Perform an arbitrary database 'delete' operation.

  Returns:
    an error or zero for success.
  Throws:
    `DbException` - if a database problem occurs.
    `IOException` - if an IO problem occurs.

Berkeley DB version 4.2.52

Copyright (c) 1996-2003 Sleepycat Software, Inc. - All rights reserved.