com.steptools.stdev
Class PopulationBase

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractSet
          extended by com.steptools.stdev.PopulationBase
All Implemented Interfaces:
EntityInstanceSet, java.lang.Iterable, java.util.Collection, java.util.Set

public abstract class PopulationBase
extends java.util.AbstractSet
implements EntityInstanceSet

Provides a persistent collection of EntityInstances within a Model. The PopulationBase class is extended by a class named Population in the namespace of the schema.

Populations can only be created by the Model.newPopulation(SchemaBase, Object) method.

To access the EntityInstance in a populatrion, use either the getFolder or getExtent method. These methods return a set of all instance of a given entity type. The getFolders method returns the set of instances whose type exactly matches the requested type, while the getExtent method returns the instances in the folder, plus all the subtypes of the specified entity.

Population implements the EntityInstanceSet inteface, to provide convientent access to all of the entity instances contained within. This enable an entiry population to be passed pased as a parameter to EntityInstance.usedin.


Method Summary
 void addInstance(EntityInstance inst)
          Adds an EntityInstance to this population.
 boolean contains(EntityInstance inst)
          Determines if this population contains a specified instance.
 EntityExtent getExtent(EntityDomain dom)
          Get the entity extent for a specified type.
 EntityExtent getFolder(EntityDomain dom)
          Get the folder for a specified type.
 java.util.Collection getFolders()
          Get all the folders in this population.
 java.lang.Object getIdentifier()
          Gets the identifier for the section
 Model getModel()
          Gets the model for the population
abstract  SchemaBase getSchema()
          Gets the schema for the population
 boolean isUser()
          Determines if this is a user population.
 java.util.Iterator iterator()
          Get all the instances in this population.
 EntityInstance newInstance(EntityDomain dom)
          Create a new instance of the specified instance
 EntityInstance newInstance(EntityDomain[] sups)
          Create a new complex instance within this population
 EntityInstance newInstance(java.util.List sups)
          Create a new complex instance within this population
 void removeInstance(EntityInstance inst)
          Remove an instance from the population.
 int size()
          Get the number of instances in this population.
 
Methods inherited from class java.util.AbstractSet
equals, hashCode, removeAll
 
Methods inherited from class java.util.AbstractCollection
add, addAll, clear, contains, containsAll, isEmpty, remove, retainAll, toArray, toArray, toString
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Set
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, remove, removeAll, retainAll, toArray, toArray
 

Method Detail

getSchema

public abstract SchemaBase getSchema()
Gets the schema for the population


getModel

public final Model getModel()
Gets the model for the population


getIdentifier

public final java.lang.Object getIdentifier()
Gets the identifier for the section


isUser

public boolean isUser()
Determines if this is a user population. A user population is one that contains persistent instance data, as opposed to headers or annotations.


addInstance

public final void addInstance(EntityInstance inst)
                       throws TypeException
Adds an EntityInstance to this population. contains persistent instance data, as oppodes to headers or annotations.

Parameters:
inst - The instance to add.
Throws:
TypeException - The instance is not of an entity in this population's schema

removeInstance

public final void removeInstance(EntityInstance inst)
                          throws ModelMemberException
Remove an instance from the population.

Parameters:
inst - The instance to remove.
Throws:
ModelMemberException - The requested instance was not in this population

contains

public final boolean contains(EntityInstance inst)
Determines if this population contains a specified instance.

Parameters:
inst - The instance
Returns:
true if the specified instance is contained in this model.

getExtent

public final EntityExtent getExtent(EntityDomain dom)
Get the entity extent for a specified type. The extent the instances of the specified entity, and all of its subtypes.

Parameters:
dom - The requested type.
Returns:
The extent.

getFolder

public final EntityExtent getFolder(EntityDomain dom)
Get the folder for a specified type. The folder is set of instance instances whose type exactly matches the specified entity, that is, without any subtypes.

Parameters:
dom - The requested type.
Returns:
The extent.

getFolders

public final java.util.Collection getFolders()
Get all the folders in this population. This method can be used to

Returns:
A collection of EntityExtent, each element of thich corresponds to a single folder.

iterator

public final java.util.Iterator iterator()
Get all the instances in this population.

Specified by:
iterator in interface java.lang.Iterable
Specified by:
iterator in interface java.util.Collection
Specified by:
iterator in interface java.util.Set
Specified by:
iterator in class java.util.AbstractCollection
Returns:
A collection of EntityInstance.

size

public final int size()
Get the number of instances in this population.

Specified by:
size in interface java.util.Collection
Specified by:
size in interface java.util.Set
Specified by:
size in class java.util.AbstractCollection
Returns:
The number of instances in the population.

newInstance

public final EntityInstance newInstance(java.util.List sups)
Create a new complex instance within this population

Parameters:
sups - List of supertypes.
Returns:
The newly created complex instance. null if the instance could not be created
Throws:
TypeException - The domain is not in the schema of this population.

newInstance

public final EntityInstance newInstance(EntityDomain[] sups)
Create a new complex instance within this population

Parameters:
sups - Array of supertypes.
Returns:
The newly created complex instance. null if the instance could not be created
Throws:
TypeException - The domain is not in the schema of this population.

newInstance

public final EntityInstance newInstance(EntityDomain dom)
Create a new instance of the specified instance

Parameters:
dom - The domain of the instance.
Returns:
The newly created instance.
Throws:
TypeException - The domain is not in the schema of this population.