|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
|
+--database.Database
|
+--database.HashDB
Concrete Database implementation that uses hashtables at the bottom. This concrete Database implementation is horribly slow on writes, uses incredible amounts of memory if the dataset is large, but has very fast lookups. All in all it is the archtypical bad speed/size tradeoff. Use this on very small datasets, or if there are no JDBC based implementations available.
This class will only handle datums with unique keys.
The database equalivent of bubble-sort (or perhaps bogo-sort?).
As of version 0.2, the data contents of the database is stored as S-Expression lists. The file itself is a list:
TODO: After this.close(), using get/put/etc should be an error.
| Field Summary | |
private static String |
__me
|
private boolean |
db_dirty
|
private File |
db_file
|
private Hashtable |
db_ht
|
private Properties |
db_prop
|
boolean |
debug
|
protected static String |
listname_s
|
private SList |
slist
|
protected static String |
version_s
|
| Fields inherited from class database.Database |
_registeredDB_ht |
| Constructor Summary | |
HashDB()
|
|
| Method Summary | |
(package private) static void |
|
private void |
assertOpen(String method)
Check to see if the database is open, and throw an exception if it isn't. |
void |
close()
Close database, after commiting changes. |
void |
closeNoCommit()
Close database, without commiting changes. |
void |
commit()
Explicitly commit changes to stable storage. |
Enumeration |
enumerate()
Returns an enumeration of the keys/values in the database, at the time this method was called. |
boolean |
exists(Object key)
Test to see if an object exists in database. |
Result |
get(Object key)
Retrieve a stored object by key. |
Connection |
getConnection()
If possible, return the java.sql.Connection object representing this database connection. |
Properties |
getProperties()
Return Database's properties. |
boolean |
isJDBC()
Test to see if the implementing class is JDBC-compliant. |
void |
open(Object ref)
Open database by file name. |
void |
put(Object key,
Object value)
Store object in database. |
void |
remove(Object key)
Removes an object from the database |
Object |
search(Object criterium)
Search database for data matching a criterium. |
Enumeration |
search(gnu.regexp.RE regexp)
Overloaded method that takes a regular expression as search criterium. |
void |
setProperties(Properties prop)
Set Database's properties. |
int |
size()
Returns the number of entries in the database. |
Object[] |
toArray()
Returns an array of the values in the database. |
| Methods inherited from class database.Database |
getInstance,
registerDatabase,
unRegister |
| Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
registerNatives,
toString,
wait,
wait,
wait |
| Field Detail |
private static String __me
protected static String listname_s
protected static String version_s
public boolean debug
private Hashtable db_ht
private Properties db_prop
private boolean db_dirty
private File db_file
private SList slist
| Constructor Detail |
public HashDB()
| Method Detail |
static void()
public Properties getProperties()
throws DatabaseException
public void setProperties(Properties prop)
throws DatabaseException
prop - this database's properties.public boolean isJDBC()
public void put(Object key,
Object value)
throws DatabaseException
key - the Object used to reference the stored object by.value - the Object to store.
public Result get(Object key)
throws DatabaseException,
NotFoundException
key - the Object used to reference the stored object by.
public boolean exists(Object key)
throws DatabaseException
key - the Object used to reference the stored object by.
public void remove(Object key)
throws DatabaseException
key - the Object used to reference the stored object by.
public void open(Object ref)
throws DatabaseException
TODO: Read/Write this.db_prop too?
ref - String containing file name of database.
public void close()
throws DatabaseException
public void closeNoCommit()
throws DatabaseException
public void commit()
throws DatabaseException
TODO: Robustness: It should write to a temporal file first, then rename to the "real" file.
public Enumeration enumerate()
public Object[] toArray()
public int size()
public Object search(Object criterium)
throws DatabaseException,
NotFoundException
criterium - object to search for.
public Enumeration search(gnu.regexp.RE regexp)
throws DatabaseException,
NotFoundException
criterium - gnu.regexp.RE regular expression object that a stored
datum must match exactly.
private void assertOpen(String method)
throws DatabaseException
method - String containing name of calling method (for
prettyprinting).public Connection getConnection()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||