org.jscience.engineering.eventdriven
Class AbsEntity

java.lang.Object
  extended by org.jscience.engineering.eventdriven.AbsEntity

public abstract class AbsEntity
extends java.lang.Object

The abstract superclass of all Entity classes. Entity objects are what the state engine tracks through the state models in response to events. The action methods associated with states are also defined in the Entity - this may seem strange but in practice the state code almost always manipulates Entity data, so making the methods members of the Entity class removes the need to cast the entity references in every state action.

Entities are created by calling Engine.createEntity(). An entity can delete itself from the system at the end of its lifecycle by calling delete() in the termination state method.


Field Summary
protected  org.jscience.engineering.eventdriven.State currentState
          

The current state of the entity (references a State object in the state model).

protected  java.lang.String id
          

Identifier of the entity.

protected  Engine ownerEngine
          

The state engine within which this entity exists.

protected  Model ownerModel
          

The state model that the entity is associated with.

 
Constructor Summary
AbsEntity()
           
 
Method Summary
protected  void delete()
          

Deletes this entity from the state engine (usually called from the termination state code in the state model).

protected  void generateEvent(AbsEntity entity, org.jscience.engineering.eventdriven.EventSpec eventSpec, java.lang.Object[] args)
          

Generate a normal event.

protected  void generateEvent(AbsEntity entity, java.lang.String eventSpecId, java.lang.Object[] args)
          

Generate a normal event.

protected  void generateEvent(java.lang.String entityId, java.lang.String eventSpecId, java.lang.Object[] args)
          

Generate a normal event.

protected  void generateInternalEvent(org.jscience.engineering.eventdriven.EventSpec eventSpec, java.lang.Object[] args)
          

Generate an internal event.

protected  void generateInternalEvent(java.lang.String eventSpecId)
          

Generate an internal event with no arguments.

protected  void generateInternalEvent(java.lang.String eventSpecId, java.lang.Object[] args)
          

Generate an internal event.

 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

id

protected java.lang.String id

Identifier of the entity. Each entity associated with a state engine must have an id unique to that entity (the id is used to direct events to the correct entity).


currentState

protected org.jscience.engineering.eventdriven.State currentState

The current state of the entity (references a State object in the state model).


ownerEngine

protected Engine ownerEngine

The state engine within which this entity exists.


ownerModel

protected Model ownerModel

The state model that the entity is associated with.

Constructor Detail

AbsEntity

public AbsEntity()
Method Detail

delete

protected final void delete()

Deletes this entity from the state engine (usually called from the termination state code in the state model).


generateEvent

protected final void generateEvent(AbsEntity entity,
                                   org.jscience.engineering.eventdriven.EventSpec eventSpec,
                                   java.lang.Object[] args)
                            throws StateProcessingException

Generate a normal event.

Parameters:
entity - The target entity.
eventSpec - The event type specifier.
args - The arguments to the target state code.
Throws:
StateProcessingException - if any arguments are null.

generateEvent

protected final void generateEvent(AbsEntity entity,
                                   java.lang.String eventSpecId,
                                   java.lang.Object[] args)
                            throws StateProcessingException

Generate a normal event.

Parameters:
entity - The target entity.
eventSpecId - The name of the event type specifier.
args - The arguments to the target state code.
Throws:
StateProcessingException - if any arguments are null or the event spec name is not recognized.

generateEvent

protected final void generateEvent(java.lang.String entityId,
                                   java.lang.String eventSpecId,
                                   java.lang.Object[] args)
                            throws StateProcessingException

Generate a normal event.

Parameters:
entityId - The target entity id.
eventSpecId - The name of the event type specifier.
args - The arguments to the target state code.
Throws:
StateProcessingException - if any arguments are null or the entity or event spec name is not recognized..

generateInternalEvent

protected final void generateInternalEvent(java.lang.String eventSpecId,
                                           java.lang.Object[] args)
                                    throws StateProcessingException

Generate an internal event.

Parameters:
eventSpecId - The name of the event type specifier.
args - The arguments to the target state code.
Throws:
StateProcessingException - if any arguments are null or the event spec name is not recognized.

generateInternalEvent

protected final void generateInternalEvent(java.lang.String eventSpecId)
                                    throws StateProcessingException

Generate an internal event with no arguments.

Parameters:
eventSpecId - The name of the event type specifier.
Throws:
StateProcessingException - if any arguments are null or the event spec name is not recognized.

generateInternalEvent

protected final void generateInternalEvent(org.jscience.engineering.eventdriven.EventSpec eventSpec,
                                           java.lang.Object[] args)
                                    throws StateProcessingException

Generate an internal event.

Parameters:
eventSpec - The event type specifier.
args - The arguments to the target state code.
Throws:
StateProcessingException - if any arguments are null or the event spec name is not recognized.