org.gjt.universe
Class DBTable

java.lang.Object
  |
  +--org.gjt.universe.DBTable
All Implemented Interfaces:
java.io.Serializable

class DBTable
extends java.lang.Object
implements java.io.Serializable

This class is used to implement a searchable and enumerable table of objects that can be accessed and modified in a synchronized manner. Currently this is internally implemented using a hash table. However, future implementations may utilize a more sophisticated database mechanism which allows persistence of objects outside of virtual memory when not being directly accessed, thus allowing the game to operate more efficiently.


Field Summary
private  java.util.Hashtable hiddenTable
           
private  java.lang.Object undefinedObject
           
 
Constructor Summary
DBTable()
          The designated constructor for instances of this class.
 
Method Summary
 void addElement(Index id, java.lang.Object obj)
          This method adds the given element to the table, under the given unique ID.
 java.util.Enumeration elements()
          This method returns an enumeration of all of the elements in the table.
 java.lang.Object elementWithID(Index id)
          This method returns the object with the given ID.
 java.lang.Object removeElementWithID(Index id)
          This method removes the object with the given ID from the table.
 void setUndefinedObject(java.lang.Object newValue)
          This method sets the object which should be returned by the elementWithID method when a search is made for a non-existent id.
 int size()
          This method returns the number of elements currently stored in the table.
 java.lang.Object undefinedObject()
          This method returns the object which should be returend by the elementWithID method when a search is made for a non-existent id.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

hiddenTable

private java.util.Hashtable hiddenTable

undefinedObject

private java.lang.Object undefinedObject
Constructor Detail

DBTable

public DBTable()
The designated constructor for instances of this class. An empty table is returned.

Method Detail

addElement

public final void addElement(Index id,
                             java.lang.Object obj)
This method adds the given element to the table, under the given unique ID. If an object was already stored in the table under the given ID, the new object will replace it.

Parameters:
id - The unique ID of the object.
obj - The object to be stored in the table.

removeElementWithID

public final java.lang.Object removeElementWithID(Index id)
This method removes the object with the given ID from the table. If there is no object stored under the given ID, the method has no effect.

Parameters:
id - The unique ID of the object to be removed.

elementWithID

public final java.lang.Object elementWithID(Index id)
This method returns the object with the given ID. If no such object exists, this method returns the designated undefined object.

Parameters:
id - The unique ID of the desired object.
See Also:
setUndefinedObject( Object newValue )

size

public final int size()
This method returns the number of elements currently stored in the table.


elements

public final java.util.Enumeration elements()
This method returns an enumeration of all of the elements in the table.


setUndefinedObject

public final void setUndefinedObject(java.lang.Object newValue)
This method sets the object which should be returned by the elementWithID method when a search is made for a non-existent id.

See Also:
elementWithID( Index anID )

undefinedObject

public final java.lang.Object undefinedObject()
This method returns the object which should be returend by the elementWithID method when a search is made for a non-existent id. Unless the setUndefinedObject method was called to set a specific undefined object, this method will returned the default value of null.



Copyright © 2001 Universe Dev Team All Rights Reserved.