org.omegahat.Environment.Databases
Class PersistentObjectDatabase

java.lang.Object
  |
  +--org.omegahat.Environment.Databases.ObjectDatabase
        |
        +--org.omegahat.Environment.Databases.PersistentObjectDatabase
All Implemented Interfaces:
Activable, Database, DatabaseNotifier, DynamicFieldAccessInt, MergableInt, Named, java.io.Serializable, Subsettable

public class PersistentObjectDatabase
extends ObjectDatabase

Database that supports serializing the individual entries directly to disk as separate objects, in the S fashion, rather than holding everything in memory with references between the objects, etc.

See Also:
Serialized Form

Field Summary
static java.lang.String COMPRESS_EXTENSION
           
protected  boolean compressed
           
static boolean Compressed
           
protected  java.io.File dir
           
protected  java.io.FilenameFilter filter
           
protected static java.lang.Integer readFromDisk
           
protected  java.net.URL url
           
 
Fields inherited from class org.omegahat.Environment.Databases.ObjectDatabase
listeners, name, permissions, state, table, user
 
Fields inherited from interface org.omegahat.Environment.Databases.Database
ALL, ASSIGN, ATTACH, DETACH, NULL_ENTRY, READ, READ_WRITE, REMOVE
 
Fields inherited from interface org.omegahat.Environment.Databases.Activable
ACTIVE, INACTIVE
 
Constructor Summary
PersistentObjectDatabase(java.io.File dir)
           
PersistentObjectDatabase(java.io.File dir, boolean create)
           
PersistentObjectDatabase(java.io.File dir, boolean create, boolean comp)
           
PersistentObjectDatabase(java.lang.String name)
           
 
Method Summary
 java.io.File asFile(java.lang.String name)
           
 boolean assign(java.lang.String name, java.lang.Object obj)
          assigns obj to the database under name.
 java.io.File directory()
           
 java.io.File directory(java.io.File d)
           
 java.io.File directory(java.io.File d, boolean create)
           
 java.io.FilenameFilter filter()
           
 java.io.FilenameFilter filter(java.io.FilenameFilter f)
           
 java.lang.Object get(java.lang.String name)
          returns the object in the database assigned under the name.
 java.lang.String[] objects()
          the array of object names.
 java.lang.String[] objects(boolean local)
           
 java.lang.Object read(java.lang.String obj_name)
           
 int readEntries(java.io.File directory)
           
 int readEntries(java.io.File directory, java.io.FilenameFilter filter)
           
 java.lang.Object remove(java.lang.String name)
          remove the object from the database
 int synchronize()
           
 int synchronize(boolean force)
           
 java.lang.Object write(java.lang.String name, java.lang.Object obj)
           
 
Methods inherited from class org.omegahat.Environment.Databases.ObjectDatabase
addAssignListener, addAttachListener, addDetachListener, addListener, addRemoveListener, assign, attach, clear, detach, exists, getDynamicField, getName, getState, getTable, merge, merge, notify, put, readOnly, readOnly, readSerialized, readSerialized, readSerialized, remove, setDynamicField, setName, setState, setTable, size, subset, table, table
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COMPRESS_EXTENSION

public static java.lang.String COMPRESS_EXTENSION

Compressed

public static boolean Compressed

readFromDisk

protected static final java.lang.Integer readFromDisk

compressed

protected boolean compressed

url

protected java.net.URL url

dir

protected java.io.File dir

filter

protected java.io.FilenameFilter filter
Constructor Detail

PersistentObjectDatabase

public PersistentObjectDatabase(java.lang.String name)

PersistentObjectDatabase

public PersistentObjectDatabase(java.io.File dir)

PersistentObjectDatabase

public PersistentObjectDatabase(java.io.File dir,
                                boolean create)

PersistentObjectDatabase

public PersistentObjectDatabase(java.io.File dir,
                                boolean create,
                                boolean comp)
Method Detail

filter

public java.io.FilenameFilter filter()

filter

public java.io.FilenameFilter filter(java.io.FilenameFilter f)

readEntries

public int readEntries(java.io.File directory)

readEntries

public int readEntries(java.io.File directory,
                       java.io.FilenameFilter filter)

read

public java.lang.Object read(java.lang.String obj_name)

synchronize

public int synchronize()

synchronize

public int synchronize(boolean force)

remove

public java.lang.Object remove(java.lang.String name)
Description copied from interface: Database
remove the object from the database
Overrides:
remove in class ObjectDatabase
Following copied from interface: org.omegahat.Environment.Databases.Database
Parameters:
name - any string, matching the one used in a previous assignment.

assign

public boolean assign(java.lang.String name,
                      java.lang.Object obj)
               throws java.lang.Exception
Description copied from interface: Database
assigns obj to the database under name.
Overrides:
assign in class ObjectDatabase
Following copied from interface: org.omegahat.Environment.Databases.Database
Parameters:
obj - any object, including null
name - a string (preferably non-empty) to locate the object in the database.

write

public java.lang.Object write(java.lang.String name,
                              java.lang.Object obj)

asFile

public java.io.File asFile(java.lang.String name)

get

public java.lang.Object get(java.lang.String name)
Description copied from interface: Database
returns the object in the database assigned under the name. or null if none.
Overrides:
get in class ObjectDatabase

objects

public java.lang.String[] objects(boolean local)

objects

public java.lang.String[] objects()
Description copied from interface: Database
the array of object names.
Overrides:
objects in class ObjectDatabase

directory

public java.io.File directory()

directory

public java.io.File directory(java.io.File d)

directory

public java.io.File directory(java.io.File d,
                              boolean create)