/* * ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). * Version: 1.3.19 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. * ----------------------------------------------------------------------------- */ package com.sleepycat.db; /** * The Dbc object is the handle for a cursor into a Berkeley DB * database. The handle is not free-threaded. Cursor handles may be * used by multiple threads, but only serially, that is, the * application must serialize access to the Dbc handle.

* * If the cursor is to be used to perform operations on behalf of a * transaction, the cursor must be opened and closed within the * context of that single transaction. Once {@link * com.sleepycat.db.Dbc#close Dbc.close} has been called, the handle * may not be accessed again, regardless of the method's return.

*/ public class Dbc { private long swigCPtr; protected boolean swigCMemOwn; protected Dbc(long cPtr, boolean cMemoryOwn) { swigCMemOwn = cMemoryOwn; swigCPtr = cPtr; } protected Dbc() { this(0, false); } protected void delete() { if (swigCPtr != 0 && swigCMemOwn) { swigCMemOwn = false; } swigCPtr = 0; } protected static long getCPtr(Dbc obj) { return (obj == null) ? 0 : obj.swigCPtr; } /** * The Dbc.close method discards the cursor.

* * It is possible for the Dbc.close method to return * Db.DB_LOCK_DEADLOCK , signaling that any enclosing * transaction should be aborted. If the application is already * intending to abort the transaction, this error should be * ignored, and the application should proceed.

* * After Dbc.close has been called, regardless of its return, the * cursor handle may not be used again.

* * @throws DbDeadlockException If a transactional database * environment operation was selected to resolve a deadlock, * the Dbc.close method will fail and throw a {@link * com.sleepycat.db.DbDeadlockException DbDeadlockException} * exception. * @throws DbLockNotGrantedException If a Berkeley DB Concurrent * Data Store database environment configured for lock * timeouts was unable to grant a lock in the allowed time, * the Dbc.close method will fail and throw a {@link * com.sleepycat.db.DbLockNotGrantedException * DbLockNotGrantedException} exception. * @throws IllegalArgumentException The Dbc.close method will * fail and throw a IllegalArgumentException exception if the * cursor is already closed; or if an invalid flag value or * parameter was specified. */ public synchronized void close() throws DbException { try { close0(); } finally { swigCPtr = 0; } } /** * @deprecated Replaced in Berkeley DB 4.2 by {@link * #get(Dbt,Dbt,Dbt,int)} */ public int pget(Dbt key, Dbt pkey, Dbt data, int flags) throws DbException { return get(key, pkey, data, flags); } void close0() { db_javaJNI.Dbc_close0(swigCPtr); } /** * The Dbc.count method returns a count of the number of data * items for the key to which the cursor refers.

* * @param flags currently unused, and must * be set to 0. * @throws DbException The Dbc.count method may * fail and throw {@link com.sleepycat.db.DbException * DbException}, encapsulating one of the following non-zero * errors: * @throws IllegalArgumentException The Dbc.count method will * fail and throw a IllegalArgumentException exception if the * cursor has not been initialized; or if an invalid flag * value or parameter was specified. * @return The Dbc.count method throws * an exception that encapsulates a non-zero error value on * failure.

*/ public int count(int flags) throws DbException { return db_javaJNI.Dbc_count(swigCPtr, flags); } /** * @deprecated As of Berkeley DB 4.2, replaced by {@link * #delete(int)} */ public int del(int flags) throws DbException { return delete(flags); } /** * The Dbc.delete method deletes the key/data pair to which the * cursor refers.

* * When called on a cursor opened on a database that has been * made into a secondary index using the {@link * com.sleepycat.db.Db#associate Db.associate} method, the {@link * com.sleepycat.db.Db#delete Db.delete} method deletes the * key/data pair from the primary database and all secondary * indices.

* * The cursor position is unchanged after a delete, and * subsequent calls to cursor functions expecting the cursor to * refer to an existing key will fail.

* * @param flags currently unused, and must * be set to 0. * @throws DbException The Dbc.delete method may * fail and throw {@link com.sleepycat.db.DbException * DbException}, encapsulating one of the following non-zero * errors: An attempt was made to modify a read-only * database. *
  • Write attempted on read-only cursor when the {@link * com.sleepycat.db.Db#DB_INIT_CDB Db.DB_INIT_CDB} flag was * specified to {@link com.sleepycat.db.DbEnv#open * DbEnv.open}. * @throws DbDeadlockException If a transactional database * environment operation was selected to resolve a deadlock, * the Dbc.delete method will fail and throw a {@link * com.sleepycat.db.DbDeadlockException DbDeadlockException} * exception. * @throws DbLockNotGrantedException If a Berkeley DB Concurrent * Data Store database environment configured for lock * timeouts was unable to grant a lock in the allowed time, * the Dbc.delete method will fail and throw a {@link * com.sleepycat.db.DbLockNotGrantedException * DbLockNotGrantedException} exception. * @throws IllegalArgumentException The Dbc.delete method will * fail and throw a IllegalArgumentException exception if the * cursor has not been initialized; or if an invalid flag * value or parameter was specified. * @return * * Unless otherwise specified, the Dbc.delete method throws * an exception that encapsulates a non-zero error value on * failure.

    */ public int delete(int flags) throws DbException { return db_javaJNI.Dbc_del(swigCPtr, flags); } /** * The Dbc.dup method creates a new cursor that uses the same * transaction and locker ID as the original cursor. This is * useful when an application is using locking and requires two * or more cursors in the same thread of control.

    * * @param flags must be set to 0 or by * bitwise inclusively OR 'ing together one or more of * the following values: * * * @throws DbException The Dbc.dup method may fail * and throw {@link com.sleepycat.db.DbException * DbException}, encapsulating one of the following non-zero * errors: * @throws IllegalArgumentException The Dbc.dup method will fail * and throw a IllegalArgumentException exception if the * cursor has not been initialized; or if an invalid flag * value or parameter was specified. * @return The Dbc.dup method throws an * exception that encapsulates a non-zero error value on * failure.

    */ public Dbc dup(int flags) throws DbException { long cPtr = db_javaJNI.Dbc_dup(swigCPtr, flags); return (cPtr == 0) ? null : new Dbc(cPtr, true); } /** * The Dbc.get method retrieves key/data pairs from the database. * The byte array and length of the key are returned in the * object to which key refers (except for the case of the * Db.DB_SET flag, in which the key object is unchanged), * and the byte array and length of the data are returned in the * object to which data refers.

    * * When called on a cursor opened on a database that has been * made into a secondary index using the {@link * com.sleepycat.db.Db#associate Db.associate} method, the * Dbc.get and Dbc.get methods return the key from the secondary * index and the data item from the primary database. In * addition, the second method signature returns the key from the * primary database. In databases that are not secondary indices, * the second method signature will always fail.

    * * Modifications to the database during a sequential scan will be * reflected in the scan; that is, records inserted behind a * cursor will not be returned while records inserted in front of * a cursor will be returned.

    * * In Queue and Recno databases, missing entries (that is, * entries that were never explicitly created or that were * created and then deleted) will be skipped during a sequential * scan.

    If Dbc.get fails for any reason, the state of the * cursor will be unchanged.

    * * @param data The data {@link * com.sleepycat.db.Dbt Dbt} operated on. * @param flags must be set to one of the * following values: * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * In addition, the following flags may be set by bitwise * inclusively OR 'ing them into the flags * parameter: * * * * * * * * * @param key The key {@link * com.sleepycat.db.Dbt Dbt} operated on. * @throws DbException The Dbc.get method may fail * and throw {@link com.sleepycat.db.DbException * DbException}, encapsulating one of the following non-zero * errors: * @throws DbDeadlockException If a transactional database * environment operation was selected to resolve a deadlock, * the Dbc.get method will fail and throw a {@link * com.sleepycat.db.DbDeadlockException DbDeadlockException} * exception. * @throws DbLockNotGrantedException If a Berkeley DB Concurrent * Data Store database environment configured for lock * timeouts was unable to grant a lock in the allowed time, * the Dbc.get method will fail and throw a {@link * com.sleepycat.db.DbLockNotGrantedException * DbLockNotGrantedException} exception. * @throws IllegalArgumentException The Dbc.get method will * fail and throw a IllegalArgumentException exception if the * Db.DB_CURRENT or Db.DB_NEXT_DUP flags were specified and * the cursor has not been initialized; the second method * signature was called with a cursor that does not refer to * a secondary index; or if an invalid flag value or * parameter was specified. * @throws DbMemoryException If the requested item could * not be returned due to insufficient memory, the Dbc.get * method will fail and throw a {@link * com.sleepycat.db.DbMemoryException DbMemoryException} * exception. * @return Unless otherwise specified, * the Dbc.get method throws an exception that encapsulates a * non-zero error value on failure.

    * *

    * *

    * *

    * *

    * *

    * *

    * *

    * *

    * * * * In the presence of duplicate key values, Dbc.get will * return the first data item for the given key.

    */ public int get(Dbt key, Dbt data, int flags) throws DbException { return db_javaJNI.Dbc_get__SWIG_0(swigCPtr, key, data, flags); } /** * The Dbc.get method retrieves key/data pairs from the database. * The byte array and length of the key are returned in the * object to which key refers (except for the case of the * Db.DB_SET flag, in which the key object is unchanged), * and the byte array and length of the data are returned in the * object to which data refers.

    * * When called on a cursor opened on a database that has been * made into a secondary index using the {@link * com.sleepycat.db.Db#associate Db.associate} method, the * Dbc.get and Dbc.get methods return the key from the secondary * index and the data item from the primary database. In * addition, the second method signature returns the key from the * primary database. In databases that are not secondary indices, * the second method signature will always fail.

    * * Modifications to the database during a sequential scan will be * reflected in the scan; that is, records inserted behind a * cursor will not be returned while records inserted in front of * a cursor will be returned.

    * * In Queue and Recno databases, missing entries (that is, * entries that were never explicitly created or that were * created and then deleted) will be skipped during a sequential * scan.

    If Dbc.get fails for any reason, the state of the * cursor will be unchanged.

    * * @param data The data {@link * com.sleepycat.db.Dbt Dbt} operated on. * @param flags must be set to one of the * following values: * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * In addition, the following flags may be set by bitwise * inclusively OR 'ing them into the flags * parameter: * * * * * * * * * @param key The key {@link * com.sleepycat.db.Dbt Dbt} operated on. * @param pkey The secondary index key * {@link com.sleepycat.db.Dbt Dbt} operated on. * @throws DbException The Dbc.get method may fail * and throw {@link com.sleepycat.db.DbException * DbException}, encapsulating one of the following non-zero * errors: * @throws DbDeadlockException If a transactional database * environment operation was selected to resolve a deadlock, * the Dbc.get method will fail and throw a {@link * com.sleepycat.db.DbDeadlockException DbDeadlockException} * exception. * @throws DbLockNotGrantedException If a Berkeley DB Concurrent * Data Store database environment configured for lock * timeouts was unable to grant a lock in the allowed time, * the Dbc.get method will fail and throw a {@link * com.sleepycat.db.DbLockNotGrantedException * DbLockNotGrantedException} exception. * @throws IllegalArgumentException The Dbc.get method will * fail and throw a IllegalArgumentException exception if the * Db.DB_CURRENT or Db.DB_NEXT_DUP flags were specified and * the cursor has not been initialized; the second method * signature was called with a cursor that does not refer to * a secondary index; or if an invalid flag value or * parameter was specified. * @throws DbMemoryException If the requested item could * not be returned due to insufficient memory, the Dbc.get * method will fail and throw a {@link * com.sleepycat.db.DbMemoryException DbMemoryException} * exception. * @return Unless otherwise specified, * the Dbc.get method throws an exception that encapsulates a * non-zero error value on failure.

    * *

    * *

    * *

    * *

    * *

    * *

    * *

    * *

    * * * * In the presence of duplicate key values, Dbc.get will * return the first data item for the given key.

    */ public int get(Dbt key, Dbt pkey, Dbt data, int flags) throws DbException { return db_javaJNI.Dbc_get__SWIG_1(swigCPtr, key, pkey, data, flags); } /** * The Dbc.put method stores key/data pairs into the database. *

    If Dbc.put fails for any reason, the state of the cursor * will be unchanged. If Dbc.put succeeds and an item is inserted * into the database, the cursor is always positioned to refer to * the newly inserted item.

    * * @param data The data {@link * com.sleepycat.db.Dbt Dbt} operated on. * @param flags must be set to one of the * following values: * * * * * * * * * * * * * @param key The key {@link * com.sleepycat.db.Dbt Dbt} operated on. * @throws DbException The Dbc.put method may fail * and throw {@link com.sleepycat.db.DbException * DbException}, encapsulating one of the following non-zero * errors: *
  • An attempt was made to modify a read-only database. * Write attempted on read-only cursor when the {@link * com.sleepycat.db.Db#DB_INIT_CDB Db.DB_INIT_CDB} flag was * specified to {@link com.sleepycat.db.DbEnv#open * DbEnv.open}. * @throws DbDeadlockException If a transactional database * environment operation was selected to resolve a deadlock, * the Dbc.put method will fail and throw a {@link * com.sleepycat.db.DbDeadlockException DbDeadlockException} * exception. * @throws DbLockNotGrantedException If a Berkeley DB Concurrent * Data Store database environment configured for lock * timeouts was unable to grant a lock in the allowed time, * the Dbc.put method will fail and throw a {@link * com.sleepycat.db.DbLockNotGrantedException * DbLockNotGrantedException} exception. * @throws IllegalArgumentException The Dbc.put method will * fail and throw a IllegalArgumentException exception if the * Db.DB_AFTER, Db.DB_BEFORE or Db.DB_CURRENT flags were * specified and the cursor has not been initialized; the * Db.DB_AFTER or Db.DB_BEFORE flags were specified and a * duplicate sort function has been specified; the * Db.DB_CURRENT flag was specified, a duplicate sort * function has been specified, and the data item of the * referenced key/data pair does not compare equally to the * data parameter; the Db.DB_AFTER or Db.DB_BEFORE * flags were specified, and the underlying access method is * Queue; an attempt was made to add a record to a * fixed-length database that was too large to fit; an * attempt was made to add a record to a secondary index; or * if an invalid flag value or parameter was specified. * @return Unless otherwise specified, * the Dbc.put method throws an exception that encapsulates a * non-zero error value on failure.

    * *

    * *

    * *

    */ public int put(Dbt key, Dbt data, int flags) throws DbException { return db_javaJNI.Dbc_put(swigCPtr, key, data, flags); } }