org.omegahat.Environment.Databases
Class ObjectDatabase

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

public class ObjectDatabase
extends java.lang.Object
implements Database, MergableInt, DatabaseNotifier, Named, java.io.Serializable, DynamicFieldAccessInt, Subsettable

The basic implementation of Database for storing omegahat variables, providing the methods for managing the objects and being an element in the SearchPath.

See Also:
Serialized Form

Field Summary
protected  java.util.Vector[] listeners
           
protected  java.lang.String name
           
protected  int permissions
           
protected  int state
           
protected  java.util.Hashtable table
          The hash table actually used to store objects.
protected  java.util.Vector 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
ObjectDatabase()
           
ObjectDatabase(java.util.Hashtable table)
           
ObjectDatabase(java.util.Hashtable table, java.lang.String name)
           
ObjectDatabase(int size)
           
ObjectDatabase(java.lang.String name)
           
ObjectDatabase(java.lang.String name, int size)
           
 
Method Summary
 boolean addAssignListener(DatabaseAssignListener obj)
           
 boolean addAttachListener(DatabaseAttachListener obj)
           
 boolean addDetachListener(DatabaseDetachListener obj)
           
 boolean addListener(int which, java.lang.Object src)
           
 boolean addRemoveListener(DatabaseRemoveListener obj)
           
 boolean assign(java.lang.String name, java.lang.Object obj)
          assigns obj to the database under name.
 boolean assign(java.lang.String name, java.lang.Object obj, boolean notify)
           
 boolean attach(DatabaseCustomer src)
           
 void clear()
          remove all the objects from the database.
 boolean detach(DatabaseCustomer src)
          The opposite end of the transaction to the attach() method.
 boolean exists(java.lang.String name)
          does the object exist in the database?
 java.lang.Object get(java.lang.String name)
          returns the object in the database assigned under the name.
 java.lang.Object getDynamicField(java.lang.String name)
           
 java.lang.String getName()
           
 int getState()
           
 java.util.Hashtable getTable()
          Accessor for table field
 int merge(Database db, boolean override)
           
 int merge(java.util.Hashtable db, boolean override)
           
 void notify(DatabaseEvent ev, int who)
           
 java.lang.String[] objects()
          the array of object names.
 java.lang.Object put(java.lang.Object name, java.lang.Object value)
           
 boolean readOnly()
           
 boolean readOnly(boolean val)
           
static ObjectDatabase readSerialized(java.io.File f)
           
static ObjectDatabase readSerialized(java.io.InputStream stream)
           
static ObjectDatabase readSerialized(java.lang.String f)
           
 java.lang.Object remove(java.lang.String name)
          remove the object from the database
 java.lang.Object remove(java.lang.String name, boolean notify)
           
 java.lang.Object setDynamicField(java.lang.String name, java.lang.Object value)
           
 java.lang.String setName(java.lang.String n)
           
 int setState(int state)
           
 java.util.Hashtable setTable(java.util.Hashtable value)
          Accessor for setting table field
 int size()
          what is the size (in bytes?) of the database.
 java.lang.Object subset(java.lang.Object index, boolean keepStructure)
           
 java.util.Hashtable table()
           
 java.util.Hashtable table(java.util.Hashtable t)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

table

protected java.util.Hashtable table
The hash table actually used to store objects.

name

protected java.lang.String name

listeners

protected java.util.Vector[] listeners

state

protected int state

permissions

protected int permissions

user

protected java.util.Vector user
Constructor Detail

ObjectDatabase

public ObjectDatabase(java.lang.String name)

ObjectDatabase

public ObjectDatabase(int size)

ObjectDatabase

public ObjectDatabase(java.lang.String name,
                      int size)

ObjectDatabase

public ObjectDatabase()

ObjectDatabase

public ObjectDatabase(java.util.Hashtable table)

ObjectDatabase

public ObjectDatabase(java.util.Hashtable table,
                      java.lang.String name)
Method Detail

exists

public boolean exists(java.lang.String name)
Description copied from interface: Database
does the object exist in the database?
Specified by:
exists in interface Database

objects

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

remove

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

remove

public java.lang.Object remove(java.lang.String name,
                               boolean notify)
Specified by:
remove in interface DatabaseNotifier

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.
Specified by:
get in interface Database

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.
Specified by:
assign in interface Database
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.

assign

public boolean assign(java.lang.String name,
                      java.lang.Object obj,
                      boolean notify)
               throws java.lang.Exception
Specified by:
assign in interface DatabaseNotifier

put

public java.lang.Object put(java.lang.Object name,
                            java.lang.Object value)

addListener

public boolean addListener(int which,
                           java.lang.Object src)
Specified by:
addListener in interface DatabaseNotifier

addAssignListener

public boolean addAssignListener(DatabaseAssignListener obj)
Specified by:
addAssignListener in interface DatabaseNotifier

addRemoveListener

public boolean addRemoveListener(DatabaseRemoveListener obj)
Specified by:
addRemoveListener in interface DatabaseNotifier

addDetachListener

public boolean addDetachListener(DatabaseDetachListener obj)

addAttachListener

public boolean addAttachListener(DatabaseAttachListener obj)

notify

public void notify(DatabaseEvent ev,
                   int who)

getName

public java.lang.String getName()
Specified by:
getName in interface Database

setName

public java.lang.String setName(java.lang.String n)
Specified by:
setName in interface Database

attach

public boolean attach(DatabaseCustomer src)
Specified by:
attach in interface Database

detach

public boolean detach(DatabaseCustomer src)
The opposite end of the transaction to the attach() method.
Specified by:
detach in interface Database

setState

public int setState(int state)
Specified by:
setState in interface Activable

getState

public int getState()
Specified by:
getState in interface Activable

readOnly

public boolean readOnly()

readOnly

public boolean readOnly(boolean val)

merge

public int merge(Database db,
                 boolean override)
Specified by:
merge in interface MergableInt

merge

public int merge(java.util.Hashtable db,
                 boolean override)
Specified by:
merge in interface MergableInt

clear

public void clear()
Description copied from interface: Database
remove all the objects from the database.
Specified by:
clear in interface Database

size

public int size()
Description copied from interface: Database
what is the size (in bytes?) of the database.
Specified by:
size in interface Database

getTable

public java.util.Hashtable getTable()
Accessor for table field

setTable

public java.util.Hashtable setTable(java.util.Hashtable value)
Accessor for setting table field

table

public java.util.Hashtable table()

table

public java.util.Hashtable table(java.util.Hashtable t)

getDynamicField

public java.lang.Object getDynamicField(java.lang.String name)
                                 throws java.lang.Throwable
Specified by:
getDynamicField in interface DynamicFieldAccessInt

setDynamicField

public java.lang.Object setDynamicField(java.lang.String name,
                                        java.lang.Object value)
                                 throws java.lang.Throwable
Specified by:
setDynamicField in interface DynamicFieldAccessInt

subset

public java.lang.Object subset(java.lang.Object index,
                               boolean keepStructure)
                        throws java.lang.Throwable
Specified by:
subset in interface Subsettable

readSerialized

public static ObjectDatabase readSerialized(java.io.File f)
                                     throws java.io.FileNotFoundException,
                                            java.io.StreamCorruptedException,
                                            java.lang.ClassNotFoundException,
                                            java.io.OptionalDataException,
                                            java.io.IOException

readSerialized

public static ObjectDatabase readSerialized(java.io.InputStream stream)
                                     throws java.io.StreamCorruptedException,
                                            java.lang.ClassNotFoundException,
                                            java.io.OptionalDataException,
                                            java.io.IOException

readSerialized

public static ObjectDatabase readSerialized(java.lang.String f)
                                     throws java.io.FileNotFoundException,
                                            java.io.StreamCorruptedException,
                                            java.lang.ClassNotFoundException,
                                            java.io.OptionalDataException,
                                            java.io.IOException