com.strangegizmo.cdb
Class Cdb

java.lang.Object
  |
  +--com.strangegizmo.cdb.Cdb

public class Cdb
extends java.lang.Object

Cdb implements a Java interface to D. J. Bernstein's CDB database.


Constructor Summary
Cdb(java.lang.String filepath)
          Creates an instance of the Cdb class and loads the given CDB file.
 
Method Summary
 void close()
          Closes the CDB database.
static java.util.Enumeration elements(java.lang.String filepath)
          Returns an Enumeration containing a CdbElement for each entry in the constant database.
 byte[] find(byte[] key)
          Finds the first record stored under the given key.
 byte[] findnext(byte[] key)
          Finds the next record stored under the given key.
 void findstart(byte[] key)
          Prepares the class to search for the given key.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Cdb

public Cdb(java.lang.String filepath)
    throws java.io.IOException
Creates an instance of the Cdb class and loads the given CDB file.
Parameters:
filepath - The path to the CDB file to open.
Throws:
java.io.IOException - if the CDB file could not be opened.
Method Detail

close

public final void close()
Closes the CDB database.

findstart

public final void findstart(byte[] key)
Prepares the class to search for the given key.
Parameters:
key - The key to search for.

find

public final byte[] find(byte[] key)
Finds the first record stored under the given key.
Parameters:
key - The key to search for.
Returns:
The record store under the given key, or null if no record with that key could be found.

findnext

public final byte[] findnext(byte[] key)
Finds the next record stored under the given key.
Parameters:
key - The key to search for.
Returns:
The next record store under the given key, or null if no record with that key could be found.

elements

public static java.util.Enumeration elements(java.lang.String filepath)
                                      throws java.io.IOException
Returns an Enumeration containing a CdbElement for each entry in the constant database.
Parameters:
filepath - The CDB file to read.
Returns:
An Enumeration containing a CdbElement for each entry in the constant database.
Throws:
java.io.IOException - if an error occurs reading the constant database.