org.opencyc.uml.interpreter
Class StateInterpreter

java.lang.Object
  |
  +--java.lang.Thread
        |
        +--org.opencyc.uml.interpreter.StateInterpreter
All Implemented Interfaces:
java.lang.Runnable

public class StateInterpreter
extends java.lang.Thread

Interprets an active state of a UML StateMachine.

Author:
Stephen L. Reed

Copyright 2001 Cycorp, Inc., license is open source GNU LGPL.

the license

www.opencyc.org

OpenCyc at SourceForge

THIS SOFTWARE AND KNOWLEDGE BASE CONTENT ARE PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OPENCYC ORGANIZATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE AND KNOWLEDGE BASE CONTENT, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


Field Summary
static int DEFAULT_VERBOSITY
          The default verbosity of this object's output.
protected  Interpreter interpreter
          the parent state machine interpreter
protected  boolean isThreadRunning
          indicates whether a thread is running this state.
protected  ProcedureInterpreter procedureInterpreter
          the procedure interpreter
protected  State state
          the interpreted active state
protected  int verbosity
          Sets verbosity of this object's output.
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
StateInterpreter(Interpreter interpreter, State state)
          Constructs a new StateInterpreter object given the parent state machine interpreter and the state to interpret.
 
Method Summary
protected  void complete()
          Completes this composite state.
 void enter()
          Enters this state, performing the entry action and the do-activity.
 void enterState(State entryState)
          Enters the given state, which might be the state interpreted by this state interpreter, or might be another state.
 void exit()
          Exits this state.
 State getParentState()
          Returns the parent state of the this state, or null if this is the top state.
 State getState()
          Gets the interpreted active state
 void interpretTransitionEntry(Transition transition)
          Interprets a transition into this state.
 void interpretTransitionExit(Transition transition)
          Interprets a transition from this state.
 boolean isCompositeState()
          Gets whether the interpreted state is a composite state.
 boolean isThreadRunning()
          Gets whether a thread is running this state
 boolean isTopState()
          Returns true if the interpreted state is the top state.
protected  void performEntryActions(Transition transition)
          Performs entry actions for the given entry state and for each of its superstates disjoint from the superstates of the transition source state.
 void performTransitionEffect(Transition transition)
          Performs the transition effect in this state and creates the transition completion event.
 void run()
          Interprets the effects of a transition into the given state.
 void setState(State state)
          Sets the interpreted active state
 void setVerbosity(int verbosity)
          Sets verbosity of this object's output.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_VERBOSITY

public static final int DEFAULT_VERBOSITY
The default verbosity of this object's output. 0 --> quiet ... 9 -> maximum diagnostic input.

verbosity

protected int verbosity
Sets verbosity of this object's output. 0 --> quiet ... 9 -> maximum diagnostic input.

interpreter

protected Interpreter interpreter
the parent state machine interpreter

procedureInterpreter

protected ProcedureInterpreter procedureInterpreter
the procedure interpreter

state

protected State state
the interpreted active state

isThreadRunning

protected boolean isThreadRunning
indicates whether a thread is running this state.
Constructor Detail

StateInterpreter

public StateInterpreter(Interpreter interpreter,
                        State state)
Constructs a new StateInterpreter object given the parent state machine interpreter and the state to interpret.
Parameters:
interpreter - the parent state machine interpreter
state - the state to interpret
Method Detail

run

public void run()
Interprets the effects of a transition into the given state.
Overrides:
run in class java.lang.Thread

interpretTransitionEntry

public void interpretTransitionEntry(Transition transition)
Interprets a transition into this state.
Parameters:
transition - the transistion

performEntryActions

protected void performEntryActions(Transition transition)
Performs entry actions for the given entry state and for each of its superstates disjoint from the superstates of the transition source state.
Parameters:
transition - the transition

performTransitionEffect

public void performTransitionEffect(Transition transition)
Performs the transition effect in this state and creates the transition completion event.

complete

protected void complete()
Completes this composite state. If this is the top state then the state machine terminates.

enterState

public void enterState(State entryState)
Enters the given state, which might be the state interpreted by this state interpreter, or might be another state.
Parameters:
entryState - the given state

enter

public void enter()
Enters this state, performing the entry action and the do-activity.

interpretTransitionExit

public void interpretTransitionExit(Transition transition)
Interprets a transition from this state.
Parameters:
transition - the transistion

exit

public void exit()
Exits this state.

getState

public State getState()
Gets the interpreted active state
Returns:
the interpreted active state

setState

public void setState(State state)
Sets the interpreted active state
Parameters:
state - the interpreted active state

isThreadRunning

public boolean isThreadRunning()
Gets whether a thread is running this state
Returns:
whether a thread is running this state

isCompositeState

public boolean isCompositeState()
Gets whether the interpreted state is a composite state.
Returns:
true if the interpreted state is a composite state, otherwise returns false

setVerbosity

public void setVerbosity(int verbosity)
Sets verbosity of this object's output. 0 --> quiet ... 9 -> maximum diagnostic input.
Parameters:
verbosity - 0 --> quiet ... 9 -> maximum diagnostic input

isTopState

public boolean isTopState()
Returns true if the interpreted state is the top state.
Returns:
true if the interpreted state is the top state

getParentState

public State getParentState()
Returns the parent state of the this state, or null if this is the top state.
Parameters:
state - the given state
Returns:
the parent state of this state, or null if given the top state