org.omegahat.Environment.Databases
Class SearchPath

java.lang.Object
  |
  +--java.util.Dictionary
        |
        +--java.util.Hashtable
              |
              +--org.omegahat.Environment.Utils.OrderedTable
                    |
                    +--org.omegahat.Environment.Databases.SearchPath
All Implemented Interfaces:
Activable, AssignableSubset, java.lang.Cloneable, Database, java.util.Map, java.io.Serializable, ShallowCopyable, Subsettable
Direct Known Subclasses:
AttachableSearchPath

public class SearchPath
extends OrderedTable

This class is used to represent a collection of databases that has an order in which to search for objects, etc. This is used by the evaluator to hold the attached databases and provides a stronger formalization than a simple Vector under the control of the different Evaluators. Additionally, these can be easily inserted into an Evaluator temporarily to change the evaluation context. Also, this implementation provides an order and easy access to individual elements via the name of the database.

See Also:
Serialized Form

Inner classes inherited from class java.util.Map
java.util.Map.Entry
 
Field Summary
protected  java.util.Vector pathListeners
           
 
Fields inherited from class org.omegahat.Environment.Utils.OrderedTable
listeners, name, orderedElements, orderedKeys, state
 
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
SearchPath()
           
SearchPath(Database db)
           
SearchPath(int size)
           
SearchPath(SearchPath src)
           
SearchPath(java.util.Vector v)
           
 
Method Summary
 int addAssignListener(DatabaseAssignListener l)
           
 int addPathListener(SearchPathListener l)
           
 boolean assign(java.lang.String name, java.lang.Object value)
          assigns obj to the database under name.
 AttachedDatabase attach(Database db)
           
 AttachedDatabase attach(Database db, int position)
           
 AttachedDatabase attach(Database db, java.lang.String name)
           
 AttachedDatabase attach(Database db, java.lang.String name, int position)
           
 int detach(Database db)
           
 int detach(int which)
           
 java.lang.Object elementAt(int which)
           
 boolean exists(java.lang.String name)
          does the object exist in the database?
 Database[] find(java.lang.String name, boolean all)
           
 java.lang.Object get(java.lang.String name)
          returns the object in the database assigned under the name.
 Database getDatabase(java.lang.String name)
           
 void notifyListeners(SearchPathEvent ev)
           
 java.lang.String[] objects()
          the array of object names.
 java.util.Vector pathListeners()
           
 java.util.Vector pathListeners(java.util.Vector v)
           
 java.lang.Object remove(java.lang.String name)
          remove the object from the database
 void removePathListener(SearchPathListener l)
           
 
Methods inherited from class org.omegahat.Environment.Utils.OrderedTable
add, add, addListListener, assignSubset, attach, clear, copy, copy, detach, getName, getState, keys, listeners, listeners, notifyListeners, ordered, orderedKeys, put, put, put, remove, removeElement, removeElement, removeElementAt, removeElementAt, removeListListener, setElementAt, setName, setState, subset, subset, subset
 
Methods inherited from class java.util.Hashtable
clone, contains, containsKey, containsValue, elements, entrySet, equals, get, hashCode, isEmpty, keySet, putAll, rehash, size, toString, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.omegahat.Environment.Databases.Database
size
 

Field Detail

pathListeners

protected java.util.Vector pathListeners
Constructor Detail

SearchPath

public SearchPath()

SearchPath

public SearchPath(int size)

SearchPath

public SearchPath(Database db)

SearchPath

public SearchPath(java.util.Vector v)

SearchPath

public SearchPath(SearchPath src)
Method Detail

attach

public AttachedDatabase attach(Database db)

attach

public AttachedDatabase attach(Database db,
                               int position)

attach

public AttachedDatabase attach(Database db,
                               java.lang.String name)

attach

public AttachedDatabase attach(Database db,
                               java.lang.String name,
                               int position)

detach

public int detach(Database db)

detach

public int detach(int which)

elementAt

public java.lang.Object elementAt(int which)
Overrides:
elementAt in class OrderedTable

addAssignListener

public int addAssignListener(DatabaseAssignListener l)

addPathListener

public int addPathListener(SearchPathListener l)

removePathListener

public void removePathListener(SearchPathListener l)

notifyListeners

public void notifyListeners(SearchPathEvent ev)

find

public Database[] find(java.lang.String name,
                       boolean all)

getDatabase

public Database getDatabase(java.lang.String name)

exists

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

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 OrderedTable
Following copied from interface: org.omegahat.Environment.Databases.Database
Parameters:
name - any string, matching the one used in a previous assignment.

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 OrderedTable

objects

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

assign

public boolean assign(java.lang.String name,
                      java.lang.Object value)
               throws java.lang.Exception
Description copied from interface: Database
assigns obj to the database under name.
Overrides:
assign in class OrderedTable
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.

pathListeners

public java.util.Vector pathListeners()

pathListeners

public java.util.Vector pathListeners(java.util.Vector v)