com.steptools.stdev.p21
Class EntityIDTable

java.lang.Object
  extended by java.util.AbstractMap
      extended by com.steptools.stdev.p21.EntityIDTable
All Implemented Interfaces:
RemoveListener, java.util.Map

public class EntityIDTable
extends java.util.AbstractMap
implements RemoveListener

Holds the mapping between Part 21 Entity instance id and EntityInstance objects on memory.


Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
java.util.Map.Entry<K,V>
 
Constructor Summary
EntityIDTable()
           
 
Method Summary
 java.util.Set entrySet()
           
static EntityIDTable forModel(Model mod, boolean populate)
          Retreive or create an EntityID table for a model.
 java.math.BigInteger getId(EntityInstance inst, boolean create)
          Gets the id for a EntityInstance, optionally assigning a new ID if one does not already exist
 EntityInstance getInstance(java.math.BigInteger id)
          Gets the EntityInstance for a specified ID
 EntityInstance getInstance(java.lang.String strid)
          Gets the EntityInstance for a specified ID
 void populate(Model mod)
          Assign identifiers to all the user objects in a model
 void populate(PopulationBase pop)
          Assign identifiers to all the objects in a population
 void populate(java.util.Set objs)
          Assign identifiers to a set of objects
 void removeInstance(EntityInstance inst)
          Remove an instance from the table
 void removeNotify(EntityInstance inst)
          Called when an EntityInstance is removed.
 void setId(java.math.BigInteger id, EntityInstance inst)
          Set the identifier for a specified entity instance
 
Methods inherited from class java.util.AbstractMap
clear, containsKey, containsValue, equals, get, hashCode, isEmpty, keySet, put, putAll, remove, size, toString, values
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

EntityIDTable

public EntityIDTable()
Method Detail

getId

public java.math.BigInteger getId(EntityInstance inst,
                                  boolean create)
Gets the id for a EntityInstance, optionally assigning a new ID if one does not already exist

Parameters:
inst - The instance to get the ID from.
create - If true, create and assign an ID if one does not already exist
Returns:
The ID of the object, or null if create is false, and the object does not have an ID assigned.

getInstance

public EntityInstance getInstance(java.math.BigInteger id)
Gets the EntityInstance for a specified ID

Parameters:
id - The identifier to search
Returns:
The requested entity instance, or null if it could not be found

getInstance

public EntityInstance getInstance(java.lang.String strid)
Gets the EntityInstance for a specified ID

Parameters:
id - The identifier to search
Returns:
The requested entity instance, or null if it could not be found

setId

public void setId(java.math.BigInteger id,
                  EntityInstance inst)
           throws DuplicateEIDException,
                  DuplicateInstanceException
Set the identifier for a specified entity instance

Parameters:
id - The requested id.
inst - The instance to be identified.
Throws:
DuplicateEIDException - The ID already exists in this table.
DuplicateInstanceException - The entity instance already has an identifier in this table

removeInstance

public void removeInstance(EntityInstance inst)
Remove an instance from the table

Parameters:
inst - The instance to remove

removeNotify

public void removeNotify(EntityInstance inst)
Description copied from interface: RemoveListener
Called when an EntityInstance is removed. This is invoked when the population.removeInstance method is called, and this object is registered as a property of the Model by the Model.addProperty method.

Specified by:
removeNotify in interface RemoveListener

populate

public void populate(java.util.Set objs)
Assign identifiers to a set of objects

Parameters:
objs - The instances to be added to the table

populate

public void populate(PopulationBase pop)
Assign identifiers to all the objects in a population

Parameters:
pop - The population

populate

public void populate(Model mod)
Assign identifiers to all the user objects in a model

Parameters:
model - mod

forModel

public static EntityIDTable forModel(Model mod,
                                     boolean populate)
Retreive or create an EntityID table for a model. The table is stored as a property of the model, so furure calls to this method for the same model will return the same table.

Parameters:
model - mod The mode to get the table for.
populate - If true, populate this table.

entrySet

public java.util.Set entrySet()
Specified by:
entrySet in interface java.util.Map
Specified by:
entrySet in class java.util.AbstractMap