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
-
O_CREATE
- Opens database file as a writer and creates a new database file
if it does not already exist.
-
O_FAST
- Opens database file in fast update mode.
-
O_NEWDB
- Opens database file as a writer and creates a new database file
regardless whether or not it already exists.
-
O_READER
- Opens database file as a reader
-
O_WRITER
- Opens database file as a writer
-
S_INSERT
- Raises KeyExistsException if a data is attempted to be stored by
a key that already exists.
-
S_REPLACE
- Overwrites the data of a key if the key exists.
-
Database(File, int)
- Opens a database file in the specified
O_
mode.
-
Database(String, int)
- Opens a database file in the specified
O_
mode.
-
close()
- Closes a data base
-
delete(byte[])
- Deletes a key data pair from the database.
-
disableFastUpdateMode()
- Disables the fast mode for updates.
-
enableFastUpdateMode()
- Enables the fast mode for updates.
-
exists(byte[])
- Checks whether the given key exists in the data base
-
exists(String)
- Checks whether the given key exists in the data base
-
fetch(byte[])
- Fetch the data if the given key exists in the data base
-
fetch(String)
- Fetch the data if the given key exists in the data base
-
fetchBytes(String)
- Fetch the data if the given key exists in the data base
-
fetchString(byte[])
- Fetch the data if the given key exists in the data base
-
finalize()
-
-
firstkey()
- For iteration: get first key in database.
-
nextkey(byte[])
- For iteration: get next key in database following the given key.
-
reorganize()
- Frees space in the data base after data has been deleted.
-
setCacheSize(int)
- Sets the bucket cache size.
-
store(byte[], byte[], int)
- Store the data for the given key in the specified
S_
mode.
-
store(String, byte[], int)
- Store the data for the given key in the specified
S_
mode.
-
store(String, String, int)
- Store the data for the given key in the specified
S_
mode.
-
sync()
- Synchronizes the data base on disk with recent updates in memory
if database is in fast update mode.
O_READER
public static final int O_READER
- Opens database file as a reader
O_WRITER
public static final int O_WRITER
- Opens database file as a writer
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_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_FAST
public static final int O_FAST
- Opens database file in fast update mode.
S_INSERT
public static final int S_INSERT
- Raises KeyExistsException if a data is attempted to be stored by
a key that already exists.
S_REPLACE
public static final int S_REPLACE
- Overwrites the data of a key if the key exists.
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
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
close
public native synchronized void close()
- Closes a data base
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
enableFastUpdateMode
public native synchronized void enableFastUpdateMode()
- Enables the fast mode for updates.
disableFastUpdateMode
public native synchronized void disableFastUpdateMode()
- Disables the fast mode for updates.
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.
finalize
public void finalize()
- Overrides:
- finalize in class Object
All Packages Class Hierarchy This Package Previous Next Index