|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.opencyc.uml.interpreter.Interpreter
Interprets a UML StateMachine.
Copyright 2001 Cycorp, Inc., license is open source GNU LGPL.
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 |
public static final int DEFAULT_VERBOSITY
protected int verbosity
protected org.apache.commons.collections.UnboundedFifoBuffer eventQueue
protected Event currentEvent
protected StateMachine stateMachine
protected javax.swing.tree.DefaultTreeModel allStatesConfiguration
protected java.util.HashMap allStates
protected javax.swing.tree.DefaultTreeModel stateConfiguration
protected java.util.HashMap activeStates
protected java.util.ArrayList selectedTransitions
protected koala.dynamicjava.interpreter.TreeInterpreter treeInterpreter
protected ExpressionEvaluator expressionEvaluator
protected CycAccess cycAccess
protected StateMachineFactory stateMachineFactory
protected boolean isTerminated
Constructor Detail |
public Interpreter()
public Interpreter(StateMachine stateMachine, CycAccess cycAccess) throws java.io.IOException
stateMachine
- the state machine to interpretcycAccess
- the Cyc access instancepublic Interpreter(StateMachine stateMachine, CycAccess cycAccess, int verbosity) throws java.io.IOException
stateMachine
- the state machine to interpretcycAccess
- the Cyc access instanceverbosity
- indicates the verbosity of the interpreter's
diagnostic output - 9 = maximum, 0 = quietMethod Detail |
protected void initialize() throws java.io.IOException
public static void main(java.lang.String[] args)
args
- ignoredpublic void terminate()
public void interpret()
protected void formAllStatesConfiguration()
protected void formAllStatesConfigurationFrom(State state, javax.swing.tree.DefaultMutableTreeNode parentNode)
state
- the given state to be placed into the all states configurationparentNode
- the parent tree node in the all states configuration treeprotected void formInitialStateConfiguration()
protected void eventProcessor()
protected void selectTransitions(java.util.Iterator transitions)
transitions
- the given state transition iteratorprotected boolean currentEventEnables(Transition transition)
transition
- the given transitionprotected void eventDispatcher()
protected void fireSelectedTransitions()
protected void internalTransition(Transition transition)
transition
- the given internal transitionprotected void transitionExit(Transition transition)
transition
- the given transitionprotected void transitionEnter(Transition transition)
transition
- the given transitionpublic void enqueueEvent(Event event)
event
- the event to add to this state machine's event queuepublic StateMachine getStateMachine()
public void setStateMachine(StateMachine stateMachine)
stateMachine
- the state machinepublic int getVerbosity()
public void setVerbosity(int verbosity)
verbosity
- 0 --> quiet ... 9 -> maximum diagnostic inputpublic Event getCurrentEvent()
public javax.swing.tree.DefaultMutableTreeNode getActiveStatesRootedAt(State state)
state
- the given active stateprotected java.lang.Object[] getStatesFromRootTo(State state)
state
- the given statepublic javax.swing.tree.DefaultMutableTreeNode getActiveStateConfigurationTreeNode(State state)
state
- the given statepublic koala.dynamicjava.interpreter.TreeInterpreter getTreeInterpreter()
public java.lang.String displayAllStatesConfigurationTree()
public java.lang.String displayStateConfigurationTree()
protected void formStringTree(javax.swing.tree.DefaultMutableTreeNode stateTreeNode, int nestingDepth, java.lang.StringBuffer stringBuffer)
stateTreeNode
- the current tree nodenestingDepth
- the nesting depthstringBuffer
- the buffer containing the partially completed string
representation of the state configuration treepublic State getParentState(State state)
state
- the given statepublic StateMachineFactory getStateMachineFactory()
public java.util.HashMap getActiveStates()
public void setStateConfiguration(javax.swing.tree.DefaultTreeModel stateConfiguration)
stateConfiguration
- the given configuration tree, or null if
terminating the state machine
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |