ST-Developer Java Reference

com.steptools.stdev.p21
Class EntityIDTable

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

public class EntityIDTable
extends AbstractMap<Integer,EntityInstance>
implements RemoveListener

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


Nested Class Summary
 
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Method Summary
 Set<Map.Entry<Integer,EntityInstance>> entrySet()
           
static EntityIDTable forModel(Model mod)
          Retreive or create an EntityID table for a model.
static EntityIDTable forModel(Model mod, boolean populate)
          Retreive or create an EntityID table for a model.
 Integer getId(EntityInstance inst)
          Gets the id for a EntityInstance.
 Integer getId(EntityInstance inst, boolean create)
          Gets the id for a EntityInstance, optionally assigning a new ID if one does not already exist
 EntityInstance getInstance(Integer id)
          Gets the EntityInstance for a specified ID
 EntityInstance getInstance(String strid)
          Gets the EntityInstance for a specified ID is a string form.
 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(Set<EntityInstance> 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 removeTable()
          Remove this table from the Model, and remove all the instances from it.
 void setId(Integer id, EntityInstance inst)
          Set the identifier for a specified entity instance
 
Methods inherited from class java.util.AbstractMap
clear, clone, containsKey, containsValue, equals, get, hashCode, isEmpty, keySet, put, putAll, remove, size, toString, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

getId

public Integer getId(EntityInstance inst,
                     boolean create)
              throws NotInModelException
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.
Throws:
NotInModelException - The instance is not contained in the Model assiciated with this EntityIDTable.

getId

public Integer getId(EntityInstance inst)
Gets the id for a EntityInstance. Returns 0 if the instant does not already have an ID. This has the same effect as calling getId(inst, false).

Parameters:
inst - The instance to get the ID from.
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(Integer 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(String strid)
Gets the EntityInstance for a specified ID is a string form.

Parameters:
strid - The identifier to search as a string. This consists of an optional # followed by a sequence of digits.
Returns:
The requested entity instance, or null if it could not be found

setId

public void setId(Integer 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(Set<EntityInstance> 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:
mod - The model whose instances are added to the EntityIDTable.

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 future calls to this method for the same model will return the same table.

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

forModel

public static EntityIDTable forModel(Model mod)
Retreive or create an EntityID table for a model. The table is stored as a property of the model, so future calls to this method for the same model will return the same table. This method does not populate the table. It has the same effect as calling for forModel(mod, false);

Parameters:
mod - The mode to get the table for.

removeTable

public void removeTable()
Remove this table from the Model, and remove all the instances from it. The table can be removed to save memory, or to force a renumbering of the instances the next time the Model is saved.


entrySet

public Set<Map.Entry<Integer,EntityInstance>> entrySet()
Specified by:
entrySet in interface Map<Integer,EntityInstance>
Specified by:
entrySet in class AbstractMap<Integer,EntityInstance>

ST-Developer Java Reference