org.apache.commons.scxml.semantics
Class SCXMLSemanticsImpl

java.lang.Object
  extended by org.apache.commons.scxml.semantics.SCXMLSemanticsImpl
All Implemented Interfaces:
Serializable, SCXMLSemantics

public class SCXMLSemanticsImpl
extends Object
implements SCXMLSemantics, Serializable

This class encapsulates a particular SCXML semantics, that is, a particular semantic interpretation of Harel Statecharts, which aligns mostly with W3C SCXML July 5 public draft (that is, UML 1.5). However, certain aspects are taken from STATEMATE.

Specific semantics can be created by subclassing this class.

See Also:
Serialized Form

Constructor Summary
SCXMLSemanticsImpl()
           
 
Method Summary
 void determineInitialStates(SCXML input, Set targets, List entryList, ErrorReporter errRep, SCInstance scInstance)
          Determining the initial state(s) for this state machine.
 void determineTargetStates(Set states, ErrorReporter errRep, SCInstance scInstance)
           
 void enumerateReachableTransitions(SCXML stateMachine, Step step, ErrorReporter errRep)
          Enumerate all the reachable transitions.
protected  boolean eventMatch(String transEvent, Set eventOccurrences)
          Implements prefix match, that is, if, for example, "mouse.click" is a member of eventOccurrences and a transition is triggered by "mouse", the method returns true.
 void executeActions(Step step, SCXML stateMachine, EventDispatcher evtDispatcher, ErrorReporter errRep, SCInstance scInstance)
          Executes all OnExit/Transition/OnEntry transitional actions.
 void filterTransitionsSet(Step step, EventDispatcher evtDispatcher, ErrorReporter errRep, SCInstance scInstance)
          Filter the transitions set, eliminate those whose guard conditions are not satisfied.
protected  boolean finalizeMatch(String parentStateId, Set eventOccurrences)
          Implements event prefix match to ascertain <finalize> execution.
 void followTransitions(Step step, ErrorReporter errorReporter, SCInstance scInstance)
          Follow the candidate transitions for this execution Step, and update the lists of entered and exited states accordingly.
protected  org.apache.commons.logging.Log getLog()
          Get the log used by this SCXMLSemantics instance.
protected  Comparator getTTComparator()
          TransitionTargetComparator factory method.
 void initiateInvokes(Step step, ErrorReporter errRep, SCInstance scInstance)
          Initiate any new invokes.
 SCXML normalizeStateMachine(SCXML input, ErrorReporter errRep)
          Optional post processing immediately following Digester.
 void processInvokes(TriggerEvent[] events, ErrorReporter errRep, SCInstance scInstance)
          Process any existing invokes, includes forwarding external events, and executing any finalize handlers.
 Set seedTargetSet(Set residual, List transitList, ErrorReporter errRep)
          Populate the target set.
protected  void setLog(org.apache.commons.logging.Log log)
          Set the log used by this SCXMLSemantics instance.
 void updateHistoryStates(Step step, ErrorReporter errRep, SCInstance scInstance)
          Go over the exit list and update history information for relevant states.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SCXMLSemanticsImpl

public SCXMLSemanticsImpl()
Method Detail

normalizeStateMachine

public SCXML normalizeStateMachine(SCXML input,
                                   ErrorReporter errRep)
Description copied from interface: SCXMLSemantics
Optional post processing immediately following Digester. May be used for removing pseudo-states etc.

Specified by:
normalizeStateMachine in interface SCXMLSemantics
Parameters:
input - SCXML state machine
errRep - ErrorReporter callback
Returns:
normalized SCXML state machine, pseudo states are removed, etc.

determineInitialStates

public void determineInitialStates(SCXML input,
                                   Set targets,
                                   List entryList,
                                   ErrorReporter errRep,
                                   SCInstance scInstance)
                            throws ModelException
Description copied from interface: SCXMLSemantics
Determining the initial state(s) for this state machine.

Specified by:
determineInitialStates in interface SCXMLSemantics
Parameters:
input - SCXML state machine [in]
targets - a set of initial targets to populate [out]
entryList - a list of States and Parallels to enter [out]
errRep - ErrorReporter callback [inout]
scInstance - The state chart instance [in]
Throws:
ModelException - in case there is a fatal SCXML object model problem.

executeActions

public void executeActions(Step step,
                           SCXML stateMachine,
                           EventDispatcher evtDispatcher,
                           ErrorReporter errRep,
                           SCInstance scInstance)
                    throws ModelException
Executes all OnExit/Transition/OnEntry transitional actions.

Specified by:
executeActions in interface SCXMLSemantics
Parameters:
step - provides EntryList, TransitList, ExitList gets updated its AfterStatus/Events
stateMachine - state machine - SCXML instance
evtDispatcher - the event dispatcher - EventDispatcher instance
errRep - error reporter
scInstance - The state chart instance
Throws:
ModelException - in case there is a fatal SCXML object model problem.

enumerateReachableTransitions

public void enumerateReachableTransitions(SCXML stateMachine,
                                          Step step,
                                          ErrorReporter errRep)
Description copied from interface: SCXMLSemantics
Enumerate all the reachable transitions.

Specified by:
enumerateReachableTransitions in interface SCXMLSemantics
Parameters:
stateMachine - a SM to traverse [in]
step - with current status and list of transitions to populate [inout]
errRep - ErrorReporter callback [inout]

filterTransitionsSet

public void filterTransitionsSet(Step step,
                                 EventDispatcher evtDispatcher,
                                 ErrorReporter errRep,
                                 SCInstance scInstance)
                          throws ModelException
Description copied from interface: SCXMLSemantics
Filter the transitions set, eliminate those whose guard conditions are not satisfied.

Specified by:
filterTransitionsSet in interface SCXMLSemantics
Parameters:
step - [inout]
evtDispatcher - The EventDispatcher [in]
errRep - ErrorReporter callback [inout]
scInstance - The state chart instance [in]
Throws:
ModelException - in case there is a fatal SCXML object model problem.

seedTargetSet

public Set seedTargetSet(Set residual,
                         List transitList,
                         ErrorReporter errRep)
Populate the target set.

Parameters:
residual - [in]
transitList - [in]
errRep - ErrorReporter callback [inout]
Returns:
Set The target set

determineTargetStates

public void determineTargetStates(Set states,
                                  ErrorReporter errRep,
                                  SCInstance scInstance)
                           throws ModelException
Parameters:
states - a set seeded in previous step [inout]
errRep - ErrorReporter callback [inout]
scInstance - The state chart instance [in]
Throws:
ModelException - On illegal configuration
See Also:
seedTargetSet(Set, List, ErrorReporter)

updateHistoryStates

public void updateHistoryStates(Step step,
                                ErrorReporter errRep,
                                SCInstance scInstance)
Go over the exit list and update history information for relevant states.

Specified by:
updateHistoryStates in interface SCXMLSemantics
Parameters:
step - [inout]
errRep - ErrorReporter callback [inout]
scInstance - The state chart instance [inout]

followTransitions

public void followTransitions(Step step,
                              ErrorReporter errorReporter,
                              SCInstance scInstance)
                       throws ModelException
Follow the candidate transitions for this execution Step, and update the lists of entered and exited states accordingly.

Specified by:
followTransitions in interface SCXMLSemantics
Parameters:
step - The current Step
errorReporter - The ErrorReporter for the current environment
scInstance - The state chart instance
Throws:
ModelException - in case there is a fatal SCXML object model problem.

processInvokes

public void processInvokes(TriggerEvent[] events,
                           ErrorReporter errRep,
                           SCInstance scInstance)
                    throws ModelException
Process any existing invokes, includes forwarding external events, and executing any finalize handlers.

Specified by:
processInvokes in interface SCXMLSemantics
Parameters:
events - The events to be forwarded
errRep - ErrorReporter callback
scInstance - The state chart instance
Throws:
ModelException - in case there is a fatal SCXML object model problem.

initiateInvokes

public void initiateInvokes(Step step,
                            ErrorReporter errRep,
                            SCInstance scInstance)
Initiate any new invokes.

Specified by:
initiateInvokes in interface SCXMLSemantics
Parameters:
step - The current Step
errRep - ErrorReporter callback
scInstance - The state chart instance

eventMatch

protected boolean eventMatch(String transEvent,
                             Set eventOccurrences)
Implements prefix match, that is, if, for example, "mouse.click" is a member of eventOccurrences and a transition is triggered by "mouse", the method returns true.

Parameters:
transEvent - a trigger event of a transition
eventOccurrences - current events
Returns:
true/false

finalizeMatch

protected boolean finalizeMatch(String parentStateId,
                                Set eventOccurrences)
Implements event prefix match to ascertain <finalize> execution.

Parameters:
parentStateId - the ID of the parent state of the <invoke> holding the <finalize>
eventOccurrences - current events
Returns:
true/false

getTTComparator

protected Comparator getTTComparator()
TransitionTargetComparator factory method.

Returns:
Comparator The TransitionTarget comparator

setLog

protected void setLog(org.apache.commons.logging.Log log)
Set the log used by this SCXMLSemantics instance.

Parameters:
log - The new log.

getLog

protected org.apache.commons.logging.Log getLog()
Get the log used by this SCXMLSemantics instance.

Returns:
Log The log being used.


Copyright © 2005-2008 The Apache Software Foundation. All Rights Reserved.