|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object | +--uwcse.location.objects.PhysicalObjectDatabase
A class to store and manage PhysicalObjects and Trackers in such as way that they may be grouped into a hierarchical forest of compound objects with only one Tracker stored per tree.
PhysicalObject,
Tracker| Nested Class Summary | |
static class |
PhysicalObjectDatabase.PersistentDescriptor
The PersistentDescriptor contains constants written along with persistent snapshots to identify the version and other pertinant information. |
static class |
PhysicalObjectDatabase.PersistentObjectData
The PersistentObjectData class contains the information written about PhysicalObjects in persistent database snapshots. |
| Field Summary | |
protected MultiReadSingleWriteLock |
m_lock
|
protected Map |
m_nameToNodeMap
|
protected Random |
m_random
|
protected DefaultMutableTreeNode |
m_rootNode
|
protected String |
m_rootNodeName
|
protected DefaultTreeModel |
m_treeModel
|
protected WorldMap |
m_worldMap
|
| Constructor Summary | |
protected |
PhysicalObjectDatabase()
Internal constructor to create an unitialized physical object database with no map or objects. |
|
PhysicalObjectDatabase(File directory)
Create a physical object database by initializing from the given filesystem database snapshot directory using the load() method. |
|
PhysicalObjectDatabase(WorldMap worldMap)
Create an empty physical object database for the given map. |
| Method Summary | |
void |
add(PhysicalObject obj)
Add the given physical object to the database and allocate a new Tracker for this object. |
void |
add(PhysicalObject obj,
String parentObjectName)
Add the given physical object to the database as a child of the named physical object using the existing Tracker of the parent for this object. |
PhysicalObject |
getObject(String objectName)
Get a physical object by name. |
Tracker |
getRandomTracker()
Get a random tracker. |
PhysicalObject |
getRootObject(String objectName)
Lookup the object at the root of the given object's grouping tree. |
Tracker |
getTracker(String objectName)
Get the tracker for the physical object with the given name. |
WorldMap |
getWorldMap()
Get the world map. |
void |
link(String childObjectName,
String parentObjectName)
Hierarchically link the existing physical objects as child and parent. |
void |
load(File directory)
Load a database summary snapshot from persistent storage anchored at the given filesystem directory. |
static void |
main(String[] args)
Regression tests for the database not used during normal operation. |
Collection |
queryNames()
Perform a query to return a Collection of all object name Strings. |
Collection |
queryNamesByGroup(String inObjectName)
Perform a query to return a Collection of object name Strings. |
Collection |
queryNamesByType(Class typeClass)
Perform a query to return a Collection of object name Strings. |
Collection |
queryNamesByType(String typeName)
Perform a query to return a Collection of object name Strings. |
Collection |
queryNamesByTypeAndGroup(String typeName,
String inObjectName)
Perform a conjunctive query to return a Collection of object name Strings. |
void |
remove(String objectName)
Remove the named physical object from the database. |
void |
removeGroup(String objectName)
Remove the named physical object and all child objects from the database. |
void |
save(File directory)
Save a database summary snapshot to persistent storage anchored at the given filesystem directory. |
String |
toString()
Overridden to print the internal tree structure, database hash index, and world map. |
void |
unlink(String objectName)
Logically unlink the given existing physical object from its parent. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
protected MultiReadSingleWriteLock m_lock
protected Map m_nameToNodeMap
protected DefaultMutableTreeNode m_rootNode
protected DefaultTreeModel m_treeModel
protected WorldMap m_worldMap
protected Random m_random
protected String m_rootNodeName
| Constructor Detail |
public PhysicalObjectDatabase(File directory)
throws PhysicalObjectDatabaseException
PhysicalObjectDatabaseExceptionload(File)public PhysicalObjectDatabase(WorldMap worldMap)
protected PhysicalObjectDatabase()
| Method Detail |
public void save(File directory)
throws PhysicalObjectDatabaseException
directory - the directory to which to save. Must not be null.
DatabaseSaveException - if the save is unsuccessful
PhysicalObjectDatabaseExceptionload(File),
PhysicalObjectDatabase(File)
public void load(File directory)
throws PhysicalObjectDatabaseException
directory - the directory from which to load. Must not be null.
PhysicalObjectDatabaseExceptionsave(File),
PhysicalObjectDatabase(File)
public void add(PhysicalObject obj)
throws DuplicatePhysicalObjectException
link(obj.getName(), parentName), consider using the
add(obj, parentName) method to avoid the overhead of
allocating a tracker to this object and then immediately merging it into
the parent.
DuplicatePhysicalObjectException - if an object with the same name
as the given object already exists in the databaseadd(PhysicalObject,String),
link(String,String),
Tracker
public void add(PhysicalObject obj,
String parentObjectName)
throws DuplicatePhysicalObjectException,
NoSuchPhysicalObjectException
add(obj) followed immediately by
link(obj.getName(), parentName) because it avoids allocating
a tracker to this object only to immediately merge it with the parent.
NoSuchPhysicalObjectException - if the named parent object does not
exist in the database
DuplicatePhysicalObjectException - if an object with the same name
as the given object already exists in the databaseadd(PhysicalObject),
link(String,String),
Tracker
public void remove(String objectName)
throws NoSuchPhysicalObjectException
NoSuchPhysicalObjectException - if the named object does not exist
in the databaseTracker
public void removeGroup(String objectName)
throws NoSuchPhysicalObjectException
NoSuchPhysicalObjectException - if the named object does not exist
in the databaseremove(String),
Tracker
public void link(String childObjectName,
String parentObjectName)
throws NoSuchPhysicalObjectException
NoSuchPhysicalObjectException - if either the named parent or child
object do not exist in the databaseTracker.merge(Tracker)
public void unlink(String objectName)
throws NoSuchPhysicalObjectException
NoSuchPhysicalObjectException - if the object do not exist in the
databaseTracker
public Tracker getTracker(String objectName)
throws NoSuchPhysicalObjectException
O(h) where h is the height of the object
grouping tree.
NoSuchPhysicalObjectException - if the named object does not exist
in the databasegetObject(String)
public Tracker getRandomTracker()
throws NoSuchPhysicalObjectException
O(1).
NoSuchPhysicalObjectException - if no trackers exist (i.e. the
database is empty)public WorldMap getWorldMap()
public PhysicalObject getObject(String objectName)
throws NoSuchPhysicalObjectException
O(1) time.
NoSuchPhysicalObjectException - if the named object does not exist
in the databasegetTracker(String)
public PhysicalObject getRootObject(String objectName)
throws NoSuchPhysicalObjectException
NoSuchPhysicalObjectExceptionpublic Collection queryNames()
public Collection queryNamesByType(String typeName)
public Collection queryNamesByType(Class typeClass)
public Collection queryNamesByGroup(String inObjectName)
public Collection queryNamesByTypeAndGroup(String typeName,
String inObjectName)
public String toString()
toString in class Objectpublic static void main(String[] args)
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||