Class w3c.tools.dbm.jdbm
All Packages Class Hierarchy This Package Previous Next Index
Class w3c.tools.dbm.jdbm
java.lang.Object
|
+----w3c.tools.dbm.jdbm
- public class jdbm
- extends Object
An dbm like database in Java.
This database is a transcription of what I have understood of gdbm into
Java. Some of the code here I don't understand, but it looks like it works.
-
BLOCK_SIZE
-
-
CACHE_SIZE
- Default cache size.
-
DIR_BITS
- Default directory bits for this database.
-
STORE_INSERT
- Mode for store - Only insert this element if it is not already defined.
-
STORE_REPLACE
- Mode for store - Replace any existing entry with the new provided one.
-
jdbm(File)
-
-
allocateSpace(int)
- Allocate space in the file.
-
delete(byte[])
- Delete the association for the provided key.
-
delete(String)
- Delete the association for the provided String key.
-
getBytes(String)
-
-
loadBucket(int)
- Load the bucket whose file pointer is given.
-
lookup(byte[])
- Lookup the value associated with the provided key.
-
lookup(String)
- Lookup the value associated to the given String key.
-
main(String[])
-
-
printAvail(PrintStream)
- Print the list of available blocks:
-
printHeader(PrintStream)
- Print various database options to the given stream.
-
save()
- Save thisdatabase to disk.
-
store(byte[], byte[], int)
- Store the given association of key/value.
-
trace(String)
-
-
unloadBucket()
- Select a bucket to be removed from the cache, unload it.
-
write(jdbmBucket, byte[], byte[])
- Allocate and write the provided key/value.
STORE_REPLACE
public final static int STORE_REPLACE
- Mode for store - Replace any existing entry with the new provided one.
STORE_INSERT
public final static int STORE_INSERT
- Mode for store - Only insert this element if it is not already defined.
BLOCK_SIZE
protected final static int BLOCK_SIZE
DIR_BITS
protected final static int DIR_BITS
- Default directory bits for this database.
CACHE_SIZE
protected final static int CACHE_SIZE
- Default cache size.
jdbm
public jdbm(File file) throws IOException
trace
protected void trace(String msg)
printHeader
public void printHeader(PrintStream out)
- Print various database options to the given stream.
- Parameters:
- out - The PrintStream to display info to.
printAvail
public void printAvail(PrintStream out)
- Print the list of available blocks:
- Parameters:
- out - The print stream to print to.
allocateSpace
protected int allocateSpace(int size)
- Allocate space in the file.
- Parameters:
- size - The size of the file block we want.
- Returns:
- The file pointer to the allocated block.
write
protected int write(jdbmBucket bucket,
byte key[],
byte data[]) throws IOException
- Allocate and write the provided key/value.
This is a short end for writing new associations to the file.
- Parameters:
- bucket - Suggested bucket to allocate data from.
- key - The key part of the item to write.
- data - The data part of the item to write.
- Returns:
- The file position of the written element.
unloadBucket
protected synchronized jdbmBucket unloadBucket() throws IOException
- Select a bucket to be removed from the cache, unload it.
- Returns:
- A bucket ready to be reused.
loadBucket
protected synchronized LRUEntry loadBucket(int fileptr) throws IOException
- Load the bucket whose file pointer is given.
- Parameters:
- fileptr - The file pointer of the bucket to be loaded.
- into - The bucket to resue (or null).
store
public void store(byte key[],
byte value[],
int mode) throws IOException
- Store the given association of key/value.
- Parameters:
- key - The bytes that makes the key.
- value - The bytes that makes the value.
- mode - The mode of the storing, can be...
lookup
public byte[] lookup(byte key[]) throws IOException
- Lookup the value associated with the provided key.
- Parameters:
- key - The bits of the key to look for.
- Returns:
- The bits that makes the associated value, or
null if not found.
lookup
public byte[] lookup(String key) throws IOException
- Lookup the value associated to the given String key.
- Parameters:
- key - The string that we are looking for.
- Returns:
- The bits that makes the associated value, or
null if not found.
delete
public boolean delete(byte key[]) throws IOException
- Delete the association for the provided key.
- Parameters:
- key - The key of the element to remove.
- Returns:
- A boolean true if deletion was succesfull.
delete
public boolean delete(String key) throws IOException
- Delete the association for the provided String key.
- Parameters:
- key - The key of the element to remove.
- Returns:
- A boolean true if deletion was succesfull.
save
public void save() throws IOException
- Save thisdatabase to disk.
getBytes
public static byte[] getBytes(String str)
main
public static void main(String args[]) throws Exception
All Packages Class Hierarchy This Package Previous Next Index