Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.opencyc.uml.interpreter
Class Interpreter

    java.lang.Object
      |
      +--org.opencyc.uml.interpreter.Interpreter

public class Interpreter
extends java.lang.Object

Interprets 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
`protected java.util.HashMap` | `activeStates` a dictionary associating active states with tree nodes in the active state configuration
`protected java.util.HashMap` | `allStates` a dictionary associating states with tree nodes in the all states configuration
`protected javax.swing.tree.DefaultTreeModel` | `allStatesConfiguration` The state configuration of all states, which is a tree consisting of a top state at the root down to individual simple states at the leaves.
`protected Event` | `currentEvent` the current event
`protected CycAccess` | `cycAccess` the cyc access instance
`static int` | `DEFAULT_VERBOSITY` The default verbosity of this object's output.
`protected org.apache.commons.collections.UnboundedFifoBuffer` | `eventQueue` the event queue
`protected ExpressionEvaluator` | `expressionEvaluator` an expression evaluator
`protected boolean` | `isTerminated` indicates that the state machine has terminated
`protected java.util.ArrayList` | `selectedTransitions` The list of selected transitions for firing.
`protected javax.swing.tree.DefaultTreeModel` | `stateConfiguration` The (active) state configuration, which is a tree consisting of a top state at the root down to individual active simple states at the leaves.
`protected StateMachine` | `stateMachine` the state machine
`protected StateMachineFactory` | `stateMachineFactory` the state machine factory used to create and destroy events
`protected koala.dynamicjava.interpreter.TreeInterpreter` | `treeInterpreter` TreeInterpreter that interprets java source code statements.
`protected int` | `verbosity` Sets verbosity of this object's output.

Constructor Summary
`Interpreter()` Constructs a new Interpreter object.
`Interpreter(StateMachine stateMachine, CycAccess cycAccess)` Constructs a new Interpreter object given a state machine to interpret given the state machine to interpret
`Interpreter(StateMachine stateMachine, CycAccess cycAccess, int verbosity)` Constructs a new Interpreter object given the state machine to interpret.

Method Summary
`protected boolean` | `currentEventEnables(Transition transition)` Determines whether the given transition can be triggered by the current event.
`java.lang.String` | `displayAllStatesConfigurationTree()` Returns an indented string representation of the all states configuration tree.
`java.lang.String` | `displayStateConfigurationTree()` Returns an indented string representation of the active state configuration tree.
`void` | `enqueueEvent(Event event)` Adds an event to this state machine's event queue.
`protected void` | `eventDispatcher()` Selects and dequeues event instances from the event queue for processing.
`protected void` | `eventProcessor()` Processes dispatched event instances according to the general semantics of UML state machines and the specific form of this state machine.
`protected void` | `fireSelectedTransitions()` Fires the selected transitions and runs the associated actions to completion.
`protected void` | `formAllStatesConfiguration()` Forms the all states configuration for this state machine.
`protected void` | `formAllStatesConfigurationFrom(State state, javax.swing.tree.DefaultMutableTreeNode parentNode)` Recursively forms the all states configuration from the given state and tree node.
`protected void` | `formInitialStateConfiguration()` Forms the initial (active) state configuration for this state machine.
`protected void` | `formStringTree(javax.swing.tree.DefaultMutableTreeNode stateTreeNode, int nestingDepth, java.lang.StringBuffer stringBuffer)` Recursively builds the indented string representation of the given state configuration tree.
`javax.swing.tree.DefaultMutableTreeNode` | `getActiveStateConfigurationTreeNode(State state)` Returns the tree node associated with the given state in the active configuration state tree.
`java.util.HashMap` | `getActiveStates()` Gets the dictionary of active states.
`javax.swing.tree.DefaultMutableTreeNode` | `getActiveStatesRootedAt(State state)` Returns the Tree at the given active state.
`Event` | `getCurrentEvent()` Gets the current event.
`State` | `getParentState(State state)` Returns the parent state of the given state, or null if given the top state.
`StateMachine` | `getStateMachine()` Gets the state machine
`StateMachineFactory` | `getStateMachineFactory()` Gets the state machine factory used by this interpreter for event creation and destruction.
`protected java.lang.Object[]` | `getStatesFromRootTo(State state)` Returns the list of states from the root down to the given state in the all states configuration tree.
`koala.dynamicjava.interpreter.TreeInterpreter` | `getTreeInterpreter()` Gets the tree interpreter which interprets java statements
`int` | `getVerbosity()` Gets the verbosity of this object's output.
`protected void` | `initialize()` Initializes this object.
`protected void` | `internalTransition(Transition transition)` Interprets the given internal transition.
`void` | `interpret()` Interprets the state machine.
`static void` | `main(java.lang.String[] args)` Executes the Interpreter application.
`protected void` | `selectTransitions(java.util.Iterator transitions)` Selects transitions from the given state transition iterator.
`void` | `setStateConfiguration(javax.swing.tree.DefaultTreeModel stateConfiguration)` Sets the active state configuration to the given configuration tree
`void` | `setStateMachine(StateMachine stateMachine)` Sets the state machine
`void` | `setVerbosity(int verbosity)` Sets verbosity of this object's output.
`void` | `terminate()` Terminates the interpretation of the state machine.
`protected void` | `transitionEnter(Transition transition)` Transitions into a state with the given transition.
`protected void` | `transitionExit(Transition transition)` Transitions from a state with the given transition.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, 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.

### eventQueue

    protected org.apache.commons.collections.UnboundedFifoBuffer eventQueue

  the event queue

### currentEvent

    protected Event currentEvent

  the current event

### stateMachine

    protected StateMachine stateMachine

  the state machine

### allStatesConfiguration

    protected javax.swing.tree.DefaultTreeModel allStatesConfiguration

  The state configuration of all states, which is a tree consisting of a top state at the root down to individual simple states at the leaves. States other than the leaf states are composite states, and branches in the state configuration are concurrent composite states.

### allStates

    protected java.util.HashMap allStates

  a dictionary associating states with tree nodes in the all states configuration

### stateConfiguration

    protected javax.swing.tree.DefaultTreeModel stateConfiguration

  The (active) state configuration, which is a tree consisting of a top state at the root down to individual active simple states at the leaves. States other than the leaf states are composite states, and branches in the state configuration are concurrent composite states.

### activeStates

    protected java.util.HashMap activeStates

  a dictionary associating active states with tree nodes in the active state configuration

### selectedTransitions

    protected java.util.ArrayList selectedTransitions

  The list of selected transitions for firing. Each of these has an active source state, a matching trigger event and a guard expression which evaluates true.

### treeInterpreter

    protected koala.dynamicjava.interpreter.TreeInterpreter treeInterpreter

  TreeInterpreter that interprets java source code statements.

### expressionEvaluator

    protected ExpressionEvaluator expressionEvaluator

  an expression evaluator

### cycAccess

    protected CycAccess cycAccess

  the cyc access instance

### stateMachineFactory

    protected StateMachineFactory stateMachineFactory

  the state machine factory used to create and destroy events

### isTerminated

    protected boolean isTerminated

  indicates that the state machine has terminated

Constructor Detail

### Interpreter

    public Interpreter()

  Constructs a new Interpreter object.

### Interpreter

    public Interpreter(StateMachine stateMachine,
                       CycAccess cycAccess)
                throws java.io.IOException

  Constructs a new Interpreter object given a state machine to interpret given the state machine to interpret
  Parameters:
    `stateMachine` - the state machine to interpret
    `cycAccess` - the Cyc access instance

### Interpreter

    public Interpreter(StateMachine stateMachine,
                       CycAccess cycAccess,
                       int verbosity)
                throws java.io.IOException

  Constructs a new Interpreter object given the state machine to interpret.
  Parameters:
    `stateMachine` - the state machine to interpret
    `cycAccess` - the Cyc access instance
    `verbosity` - indicates the verbosity of the interpreter's diagnostic output - 9 = maximum, 0 = quiet

Method Detail

### initialize

    protected void initialize()
                       throws java.io.IOException

  Initializes this object.

### main

    public static void main(java.lang.String[] args)

  Executes the Interpreter application.
  Parameters:
    `args` - ignored

### terminate

    public void terminate()

  Terminates the interpretation of the state machine.

### interpret

    public void interpret()

  Interprets the state machine.

### formAllStatesConfiguration

    protected void formAllStatesConfiguration()

  Forms the all states configuration for this state machine.

### formAllStatesConfigurationFrom

    protected void formAllStatesConfigurationFrom(State state,
                                                  javax.swing.tree.DefaultMutableTreeNode parentNode)

  Recursively forms the all states configuration from the given state and tree node.
  Parameters:
    `state` - the given state to be placed into the all states configuration
    `parentNode` - the parent tree node in the all states configuration tree

### formInitialStateConfiguration

    protected void formInitialStateConfiguration()

  Forms the initial (active) state configuration for this state machine.

### eventProcessor

    protected void eventProcessor()

  Processes dispatched event instances according to the general semantics of UML state machines and the specific form of this state machine. Selects the transitions from active source states which are triggered by the current event.

### selectTransitions

    protected void selectTransitions(java.util.Iterator transitions)

  Selects transitions from the given state transition iterator.
  Parameters:
    `transitions` - the given state transition iterator

### currentEventEnables

    protected boolean currentEventEnables(Transition transition)

  Determines whether the given transition can be triggered by the current event.
  Parameters:
    `transition` - the given transition
  Returns:
    whether the given transition can be triggered by the current event

### eventDispatcher

    protected void eventDispatcher()

  Selects and dequeues event instances from the event queue for processing.

### fireSelectedTransitions

    protected void fireSelectedTransitions()

  Fires the selected transitions and runs the associated actions to completion.

### internalTransition

    protected void internalTransition(Transition transition)

  Interprets the given internal transition.
  Parameters:
    `transition` - the given internal transition

### transitionExit

    protected void transitionExit(Transition transition)

  Transitions from a state with the given transition.
  Parameters:
    `transition` - the given transition

### transitionEnter

    protected void transitionEnter(Transition transition)

  Transitions into a state with the given transition.
  Parameters:
    `transition` - the given transition

### enqueueEvent

    public void enqueueEvent(Event event)

  Adds an event to this state machine's event queue.
  Parameters:
    `event` - the event to add to this state machine's event queue

### getStateMachine

    public StateMachine getStateMachine()

  Gets the state machine
  Returns:
    the state machine

### setStateMachine

    public void setStateMachine(StateMachine stateMachine)

  Sets the state machine
  Parameters:
    `stateMachine` - the state machine

### getVerbosity

    public int getVerbosity()

  Gets the verbosity of this object's output. 0 --> quiet ... 9 -> maximum diagnostic input. 0 --> quiet ... 9 -> maximum diagnostic input.
  Returns:
    the verbosity of this object's output. 0 --> quiet ... 9 -> maximum diagnostic input

### 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

### getCurrentEvent

    public Event getCurrentEvent()

  Gets the current event.
  Returns:
    the current event

### getActiveStatesRootedAt

    public javax.swing.tree.DefaultMutableTreeNode getActiveStatesRootedAt(State state)

  Returns the Tree at the given active state.
  Parameters:
    `state` - the given active state
  Returns:
    the sub tree of active states rooted at the given active state

### getStatesFromRootTo

    protected java.lang.Object[] getStatesFromRootTo(State state)

  Returns the list of states from the root down to the given state in the all states configuration tree.
  Parameters:
    `state` - the given state
  Returns:
    the list of states from the root down to the given state in the all states configuration tree

### getActiveStateConfigurationTreeNode

    public javax.swing.tree.DefaultMutableTreeNode getActiveStateConfigurationTreeNode(State state)

  Returns the tree node associated with the given state in the active configuration state tree.
  Parameters:
    `state` - the given state
  Returns:
    the tree node associated with the given state in the active configuration state tree

### getTreeInterpreter

    public koala.dynamicjava.interpreter.TreeInterpreter getTreeInterpreter()

  Gets the tree interpreter which interprets java statements
  Returns:
    the tree interpreter which interprets java statements

### displayAllStatesConfigurationTree

    public java.lang.String displayAllStatesConfigurationTree()

  Returns an indented string representation of the all states configuration tree.

### displayStateConfigurationTree

    public java.lang.String displayStateConfigurationTree()

  Returns an indented string representation of the active state configuration tree.

### formStringTree

    protected void formStringTree(javax.swing.tree.DefaultMutableTreeNode stateTreeNode,
                                  int nestingDepth,
                                  java.lang.StringBuffer stringBuffer)

  Recursively builds the indented string representation of the given state configuration tree.
  Parameters:
    `stateTreeNode` - the current tree node
    `nestingDepth` - the nesting depth
    `stringBuffer` - the buffer containing the partially completed string representation of the state configuration tree

### getParentState

    public State getParentState(State state)

  Returns the parent state of the given state, or null if given the top state.
  Parameters:
    `state` - the given state
  Returns:
    the parent state of this state, or null if given the top state

### getStateMachineFactory

    public StateMachineFactory getStateMachineFactory()

  Gets the state machine factory used by this interpreter for event creation and destruction.
  Returns:
    the state machine factory used by this interpreter for event creation and destruction

### getActiveStates

    public java.util.HashMap getActiveStates()

  Gets the dictionary of active states.
  Returns:
    the dictionary of active states

### setStateConfiguration

    public void setStateConfiguration(javax.swing.tree.DefaultTreeModel stateConfiguration)

  Sets the active state configuration to the given configuration tree
  Parameters:
    `stateConfiguration` - the given configuration tree, or null if terminating the state machine

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD