Berkeley DB
version 4.2.52

com.sleepycat.bdb
Class DataDb

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

public class DataDb
extends Object

(internal) Wraps a Berkeley DB database (Db) object and adds normalization of certain flags and environment modes.

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.


Field Summary
static int EINVAL
           
static int ENOMEM
           
static int FLAGS_MOD_MASK
           
static int FLAGS_POS_MASK
           
 
Constructor Summary
DataDb(Db db)
          Creates a database wrapper.
 
Method Summary
 boolean areDuplicatesAllowed()
          Returns whether duplicates are allowed for the database.
 boolean areDuplicatesOrdered()
          Returns whether duplicates are ordered for the database.
 boolean areKeysRenumbered()
          Returns whether keys (record numbers) are renumbered for the database.
 void close()
          Closes the database.
 void closeCursor(Dbc cursor)
          Closes a cursor for this database.
 int delete(DataThang key, int flags)
          Performs a general database 'delete' operation.
 Dbc dupCursor(Dbc cursor, boolean writeCursor, int flags)
          Duplicates a cursor for this database.
 int get(DataThang key, DataThang data, int flags)
          Performs a general database 'get' operation.
 int get(Dbc cursor, DataThang key, DataThang val, int flags)
          Performs a general database 'get' operation via a cursor.
 Db getDb()
          Returns the underlying database.
 com.sleepycat.bdb.DataEnvironment getEnv()
          Returns the environment.
 boolean hasRecNumAccess()
          Returns whether record number access is allowed.
 boolean isDirtyReadAllowed()
          Returns whether dirty-read is allowed for the database.
 boolean isOrdered()
          Returns whether keys are ordered for the database.
 boolean isTransactional()
          Returns whether the database was opened in a transaction and therefore must be written in a transaction.
 Dbc openCursor(boolean writeCursor)
          Opens a cursor for this database.
 int put(DataThang key, DataThang data, int flags)
          Performs a general database 'put' operation.
 int put(Dbc cursor, DataThang key, DataThang data, int flags)
          Performs a general database 'put' operation via a cursor.
 String toString()
          Returns a debugging string containing the database name.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ENOMEM

public static final int ENOMEM
See Also:
Constant Field Values

EINVAL

public static final int EINVAL
See Also:
Constant Field Values

FLAGS_POS_MASK

public static final int FLAGS_POS_MASK
See Also:
Constant Field Values

FLAGS_MOD_MASK

public static final int FLAGS_MOD_MASK
See Also:
Constant Field Values
Constructor Detail

DataDb

public DataDb(Db db)
Creates a database wrapper.

Parameters:
db - is the underlying database.
Method Detail

close

public void close()
           throws DbException
Closes the database.

DbException

getEnv

public final com.sleepycat.bdb.DataEnvironment getEnv()
Returns the environment.

Returns:
the environment.

getDb

public final Db getDb()
Returns the underlying database.

Returns:
the underlying database.

isOrdered

public final boolean isOrdered()
Returns whether keys are ordered for the database.

Returns:
whether keys are ordered.

areDuplicatesAllowed

public final boolean areDuplicatesAllowed()
Returns whether duplicates are allowed for the database.

Returns:
whether duplicates are allowed.

areDuplicatesOrdered

public final boolean areDuplicatesOrdered()
Returns whether duplicates are ordered for the database.

Returns:
whether duplicates are ordered.

areKeysRenumbered

public final boolean areKeysRenumbered()
Returns whether keys (record numbers) are renumbered for the database.

Returns:
whether keys are renumbered.

hasRecNumAccess

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

Returns:
whether record number access is allowed.

isTransactional

public final boolean isTransactional()
Returns whether the database was opened in a transaction and therefore must be written in a transaction.

Returns:
whether the database is transactional.

isDirtyReadAllowed

public final boolean isDirtyReadAllowed()
Returns whether dirty-read is allowed for the database.

Returns:
whether dirty-read is allowed.

get

public int get(DataThang key,
               DataThang data,
               int flags)
        throws DbException
Performs a general database 'get' operation.

Parameters:
key - the key thang.
data - the data thang.
flags - the low-level get flags.
Returns:
an error or zero for success.
Throws:
DbException - if a database problem occurs.

get

public int get(Dbc cursor,
               DataThang key,
               DataThang val,
               int flags)
        throws DbException
Performs a general database 'get' operation via a cursor.

Parameters:
cursor - the cursor to read.
key - the key thang.
val - the data thang.
flags - the low-level get flags.
Returns:
an error or zero for success.
Throws:
DbException - if a database problem occurs.

put

public int put(DataThang key,
               DataThang data,
               int flags)
        throws DbException
Performs a general database 'put' operation.

Parameters:
key - the key to put.
data - the data to put.
flags - the low-level put flags.
Returns:
an error or zero for success.
Throws:
DbException - if a database problem occurs.

put

public int put(Dbc cursor,
               DataThang key,
               DataThang data,
               int flags)
        throws DbException
Performs a general database 'put' operation via a cursor. This method works for HASH/BTREE types and all flags, or with all types and DB_CURRENT only.

Parameters:
cursor - the cursor to write.
key - the key to put.
data - the data to put.
flags - the low-level put flags.
Returns:
an error or zero for success.
Throws:
DbException - if a database problem occurs.

delete

public int delete(DataThang key,
                  int flags)
           throws DbException
Performs a general database 'delete' operation.

Parameters:
key - the key to delete.
flags - the low-level delete flags.
Returns:
an error or zero for success.
Throws:
DbException - if a database problem occurs.

openCursor

public Dbc openCursor(boolean writeCursor)
               throws DbException
Opens a cursor for this database.

Parameters:
writeCursor - true to open a write cursor in a CDB environment, and ignored for other environments.
Returns:
the open cursor.
Throws:
DbException - if a database problem occurs.

dupCursor

public Dbc dupCursor(Dbc cursor,
                     boolean writeCursor,
                     int flags)
              throws DbException
Duplicates a cursor for this database.

Parameters:
writeCursor - true to open a write cursor in a CDB environment, and ignored for other environments.
flags - the low-level dup() flags.
Returns:
the open cursor.
Throws:
DbException - if a database problem occurs.

closeCursor

public void closeCursor(Dbc cursor)
                 throws DbException
Closes a cursor for this database.

Parameters:
cursor - the cursor to close.
Throws:
DbException - if a database problem occurs.

toString

public String toString()
Returns a debugging string containing the database name.

Overrides:
toString in class Object
Returns:
a debugging string.

Berkeley DB
version 4.2.52

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