com.x8ing.lsm4j.state
Class ProcessableGraph

java.lang.Object
  extended by com.x8ing.lsm4j.state.StaticGraph
      extended by com.x8ing.lsm4j.state.ProcessableGraph

public class ProcessableGraph
extends StaticGraph

This class is the entry point for building a state machine. It keeps track of the graph layout and acts as controller for running it.

How to use this class is described in the tutorial link .

Author:
Patrick Heusser

Nested Class Summary
 
Nested classes/interfaces inherited from class com.x8ing.lsm4j.state.StaticGraph
StaticGraph.StateIterator, StaticGraph.TransitionList
 
Constructor Summary
ProcessableGraph()
           
 
Method Summary
 void addValidTransition(ProcessableState currentState, ProcessableState nextState, Condition condition)
           
 void addValidTransition(ProcessableState currentState, ProcessableState nextState, Condition condition, Action transitionAction)
           
 java.util.List getGraphListeners()
          A list with all listeners.
 java.util.List getLastVisitedStatesHistoryList()
          A list with the last visited states.
 int getLastVisitedStatesHistorySize()
           
 long getMaximumLoops()
           
 void registerGraphListener(GraphListener graphListener)
           
 ProcessableState run(int startStateID, StateContext startStateContext)
          Starts the processing of the graph.
 ProcessableState run(int startStateID, StateContext startStateContext, int numberOfSteps)
          Run the graph for a defined number of transitions.
 ProcessableState runContinue()
          Continues the processing of the previously interrupted graph.
 ProcessableState runContinue(int numberOfSteps)
          Continues the processing of the previously interrupted graph with a limited amount of transitions.
 void setLastVisitedStatesHistorySize(int lastVisitedStatesHistorySize)
           
 void setMaximumLoops(long maximumLoops)
           
 boolean unregisterGraphListener(GraphListener graphListener)
           
 
Methods inherited from class com.x8ing.lsm4j.state.StaticGraph
addTransition, addValidTransition, addValidTransition, getStateCount, getStateWithID, getTransitionListForState, getTransitionsBetweenStates, getTransitionsCount, isValidTransition, isValidTransition, printGraph, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ProcessableGraph

public ProcessableGraph()
Method Detail

addValidTransition

public void addValidTransition(ProcessableState currentState,
                               ProcessableState nextState,
                               Condition condition,
                               Action transitionAction)

addValidTransition

public void addValidTransition(ProcessableState currentState,
                               ProcessableState nextState,
                               Condition condition)

runContinue

public ProcessableState runContinue(int numberOfSteps)
                             throws NoMatchingTransitionConditionFoundException,
                                    MaximumIterationsReachedException
Continues the processing of the previously interrupted graph with a limited amount of transitions.

Parameters:
numberOfSteps - the number of transitions to be executed.
Returns:
the last State or null if entry point was not found.
Throws:
NoMatchingTransitionConditionFoundException
MaximumIterationsReachedException

runContinue

public ProcessableState runContinue()
                             throws NoMatchingTransitionConditionFoundException,
                                    MaximumIterationsReachedException
Continues the processing of the previously interrupted graph.

Returns:
the last State or null if entry point was not found.
Throws:
NoMatchingTransitionConditionFoundException
MaximumIterationsReachedException

run

public ProcessableState run(int startStateID,
                            StateContext startStateContext)
                     throws NoMatchingTransitionConditionFoundException,
                            MaximumIterationsReachedException
Starts the processing of the graph. The processing ends if an end point is found. Pleaes not that the startStateContext will be changed since it's passed by reference!

Parameters:
startStateID -
startStateContext -
Returns:
the last State or null if entry point was not found.
Throws:
NoMatchingTransitionConditionFoundException
MaximumIterationsReachedException

run

public ProcessableState run(int startStateID,
                            StateContext startStateContext,
                            int numberOfSteps)
                     throws NoMatchingTransitionConditionFoundException,
                            MaximumIterationsReachedException
Run the graph for a defined number of transitions. Pleae not that the startStateContext will be changed since it's passed by reference!

Parameters:
startStateID -
startStateContext -
numberOfSteps - the number of transitions to be executed.
Returns:
the last State or null if entry point was not found.
Throws:
NoMatchingTransitionConditionFoundException
MaximumIterationsReachedException

registerGraphListener

public void registerGraphListener(GraphListener graphListener)

unregisterGraphListener

public boolean unregisterGraphListener(GraphListener graphListener)
Parameters:
graphListener - to be removed.
Returns:
true if remove was success.

getMaximumLoops

public long getMaximumLoops()

setMaximumLoops

public void setMaximumLoops(long maximumLoops)

getLastVisitedStatesHistorySize

public int getLastVisitedStatesHistorySize()

setLastVisitedStatesHistorySize

public void setLastVisitedStatesHistorySize(int lastVisitedStatesHistorySize)

getGraphListeners

public java.util.List getGraphListeners()
A list with all listeners.

type: GraphListener


getLastVisitedStatesHistoryList

public java.util.List getLastVisitedStatesHistoryList()
A list with the last visited states. The history where we came from. Index 0 means the current state.

element type: ProcessableState



by Patrick Heusser