All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class jdbm.Database

java.lang.Object
   |
   +----jdbm.Database

public class Database
extends Object
implements Serializable
This is the Java adapter for GDBM database files. It basically mirrors GDBM's functionality. To learn more about GDBM see gdbm(3).

Version:
$Revision: 1.4 $ $Date: 1998/05/22 19:52:52 $
Author:
Gunther Schadow

Variable Index

 o O_CREATE
Opens database file as a writer and creates a new database file if it does not already exist.
 o O_FAST
Opens database file in fast update mode.
 o O_NEWDB
Opens database file as a writer and creates a new database file regardless whether or not it already exists.
 o O_READER
Opens database file as a reader
 o O_WRITER
Opens database file as a writer
 o S_INSERT
Raises KeyExistsException if a data is attempted to be stored by a key that already exists.
 o S_REPLACE
Overwrites the data of a key if the key exists.

Constructor Index

 o Database(File, int)
Opens a database file in the specified O_ mode.
 o Database(String, int)
Opens a database file in the specified O_ mode.

Method Index

 o close()
Closes a data base
 o delete(byte[])
Deletes a key data pair from the database.
 o disableFastUpdateMode()
Disables the fast mode for updates.
 o enableFastUpdateMode()
Enables the fast mode for updates.
 o exists(byte[])
Checks whether the given key exists in the data base
 o exists(String)
Checks whether the given key exists in the data base
 o fetch(byte[])
Fetch the data if the given key exists in the data base
 o fetch(String)
Fetch the data if the given key exists in the data base
 o fetchBytes(String)
Fetch the data if the given key exists in the data base
 o fetchString(byte[])
Fetch the data if the given key exists in the data base
 o finalize()
 o firstkey()
For iteration: get first key in database.
 o nextkey(byte[])
For iteration: get next key in database following the given key.
 o reorganize()
Frees space in the data base after data has been deleted.
 o setCacheSize(int)
Sets the bucket cache size.
 o store(byte[], byte[], int)
Store the data for the given key in the specified S_ mode.
 o store(String, byte[], int)
Store the data for the given key in the specified S_ mode.
 o store(String, String, int)
Store the data for the given key in the specified S_ mode.
 o sync()
Synchronizes the data base on disk with recent updates in memory if database is in fast update mode.

Variables

 o O_READER
 public static final int O_READER
Opens database file as a reader

 o O_WRITER
 public static final int O_WRITER
Opens database file as a writer

 o O_CREATE
 public static final int O_CREATE
Opens database file as a writer and creates a new database file if it does not already exist.

 o O_NEWDB
 public static final int O_NEWDB
Opens database file as a writer and creates a new database file regardless whether or not it already exists.

 o O_FAST
 public static final int O_FAST
Opens database file in fast update mode.

 o S_INSERT
 public static final int S_INSERT
Raises KeyExistsException if a data is attempted to be stored by a key that already exists.

 o S_REPLACE
 public static final int S_REPLACE
Overwrites the data of a key if the key exists.

Constructors

 o Database
 public Database(File file,
                 int mode) throws IOException
Opens a database file in the specified O_ mode.

Parameters:
file - the database file.
mode - the O_ mode.
Throws: IOException
if a problem with the file occurs
 o Database
 public Database(String filename,
                 int mode) throws IOException
Opens a database file in the specified O_ mode.

Parameters:
filename - the database file name.
mode - the O_ mode.
Throws: IOException
if a problem with the file occurs

Methods

 o close
 public native synchronized void close()
Closes a data base

 o exists
 public native synchronized boolean exists(byte key[])
Checks whether the given key exists in the data base

Parameters:
key - the bytes of the key.
Returns:
true if key exists, false otherwise.
 o exists
 public boolean exists(String key)
Checks whether the given key exists in the data base

Parameters:
key - the bytes of the key.
Returns:
true if key exists, false otherwise.
 o fetch
 public native synchronized byte[] fetch(byte key[]) throws NoSuchKeyException
Fetch the data if the given key exists in the data base

Parameters:
key - the bytes of the key.
Returns:
the data bytes stored for the key.
Throws: NoSuchKeyException
if key was not in data base.
 o fetch
 public String fetch(String key) throws NoSuchKeyException
Fetch the data if the given key exists in the data base

Parameters:
key - the bytes of the key.
Returns:
the data bytes stored for the key.
Throws: NoSuchKeyException
if key was not in data base.
 o fetchBytes
 public byte[] fetchBytes(String key) throws NoSuchKeyException
Fetch the data if the given key exists in the data base

Parameters:
key - the bytes of the key.
Returns:
the data bytes stored for the key.
Throws: NoSuchKeyException
if key was not in data base.
 o fetchString
 public String fetchString(byte key[]) throws NoSuchKeyException
Fetch the data if the given key exists in the data base

Parameters:
key - the bytes of the key.
Returns:
the data bytes stored for the key.
Throws: NoSuchKeyException
if key was not in data base.
 o store
 public native synchronized void store(byte key[],
                                       byte data[],
                                       int mode) throws KeyExistsException, IllegalOperationError
Store the data for the given key in the specified S_ mode.

Parameters:
key - the bytes of the key.
data - the bytes of the key.
mode - the S_ mode.
Returns:
the data bytes stored for the key.
Throws: KeyExistsException
if key is already in data base and an S_INSERT store has been attempted.
Throws: IllegalOperationError
if database is in read mode.
 o store
 public void store(String key,
                   byte data[],
                   int mode) throws KeyExistsException, IllegalOperationError
Store the data for the given key in the specified S_ mode.

Parameters:
key - the bytes of the key.
data - the bytes of the key.
mode - the S_ mode.
Returns:
the data bytes stored for the key.
Throws: KeyExistsException
if key is already in data base and an S_INSERT store has been attempted.
Throws: IllegalOperationError
if database is in read mode.
 o store
 public void store(String key,
                   String data,
                   int mode) throws KeyExistsException, IllegalOperationError
Store the data for the given key in the specified S_ mode.

Parameters:
key - the bytes of the key.
data - the bytes of the key.
mode - the S_ mode.
Returns:
the data bytes stored for the key.
Throws: KeyExistsException
if key is already in data base and an S_INSERT store has been attempted.
Throws: IllegalOperationError
if database is in read mode.
 o delete
 public native synchronized void delete(byte key[]) throws IllegalOperationError
Deletes a key data pair from the database. No exception is raised if key does not exist. The purpose is that after calling this method the key will not exist, regardless of whether or not it existed before.

Parameters:
key - the bytes of the key.
Throws: IllegalOperationError
if database is in read mode.
 o firstkey
 public native synchronized byte[] firstkey()
For iteration: get first key in database.

Returns:
the bytes of the first key or null if database is empty.
 o nextkey
 public native synchronized byte[] nextkey(byte key[])
For iteration: get next key in database following the given key.

Returns:
the bytes of the next key or null if database is exhausted.
 o reorganize
 public native synchronized void reorganize() throws IllegalOperationError
Frees space in the data base after data has been deleted.

Throws: IllegalOperationError
if database is in read mode.
 o sync
 public native synchronized void sync()
Synchronizes the data base on disk with recent updates in memory if database is in fast update mode. Otherwise sync does nothing.

 o enableFastUpdateMode
 public native synchronized void enableFastUpdateMode()
Enables the fast mode for updates.

 o disableFastUpdateMode
 public native synchronized void disableFastUpdateMode()
Disables the fast mode for updates.

 o setCacheSize
 public native synchronized void setCacheSize(int cachesize)
Sets the bucket cache size. This may only be done once.

Parameters:
cachesize - the cache size (default is 100).
Throws: IllegalOperationError
if cache size is set a second time.
 o finalize
 public void finalize()
Overrides:
finalize in class Object

All Packages  Class Hierarchy  This Package  Previous  Next  Index