T - The type of the events (i.e. the transition labels)public class Statechart<T extends Event>
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
protected int |
m_currentState
The ID of the current state in the execution of the statechart
|
protected int |
m_initialState
The ID of the initial state.
|
protected java.util.Map<java.lang.String,java.lang.Object> |
m_initialValues
The initial value of the state variables of this statechart
|
java.lang.String |
m_name
The name given to this statechart
|
protected Statechart<T> |
m_parent
The parent statechart, if any
|
protected State<T> |
m_trashState
A special sink state to make sure the transition relation is total
|
protected TrashTransition<T> |
m_trashTransition
An instance of the trash transition
|
protected java.util.Map<java.lang.String,java.lang.Object> |
m_variables
The state variables of this statechart
|
static java.lang.String |
TRASH
Label given to the trash sink in the statechart
|
static java.lang.String |
UP
Symbol indicating that the target of a transition refers to a state
in the parent of the current statechart
|
| Constructor and Description |
|---|
Statechart()
Creates a new anonymous statechart
|
Statechart(java.lang.String name)
Creates a new empty statechart
|
| Modifier and Type | Method and Description |
|---|---|
Statechart<T> |
add(int source,
Transition<T> transition)
Adds a new transition to the statechart
|
Statechart<T> |
add(State<T> s)
Adds a new state to this statechart
|
Statechart<T> |
add(java.lang.String source_name,
Transition<T> transition)
Adds a new transition to the statechart
|
boolean |
applyTransition(T event,
Configuration<T> node)
Attempts to apply a transition on this statechart
|
Statechart<T> |
clone(Statechart<T> parent)
Creates a copy of this statechart
|
static Statechart<?> |
findOwner(Statechart<?> statechart,
java.lang.String var_name)
Finds the statechart instance that "owns" the state variable of given name.
|
Statechart<?> |
findOwner(java.lang.String var_name)
Finds the statechart instance that "owns" the state variable of given name.
|
State<T> |
getAnyAtomicChild()
Returns an arbitrary state of this statechart that is not a
NestedState. |
State<T> |
getAnyAtomicChild(State<T> state)
Returns an arbitrary state of this statechart that is not a
NestedState and is contained within the state
given as argument. |
Configuration<T> |
getCurrentConfiguration()
Gets the identifier of the current state of the statechart.
|
int |
getEdgeCount()
Counts the edges in this statechart
|
Configuration<T> |
getInitialConfiguration()
Gets the initial configuration of this statechart
|
State<T> |
getInitialState()
Gets the initial state of this statechart
|
Statechart<T> |
getParent()
Gets the enclosing instance of this statechart
|
State<T> |
getState(int id)
Gets a state with given ID
|
protected State<T> |
getState(java.lang.String name)
Gets a state with given name
|
java.util.Map<java.lang.String,State<T>> |
getStates()
Gets the states of this statechart
|
java.util.Map<java.lang.Integer,java.util.Set<Transition<T>>> |
getTransitions() |
java.lang.Object |
getVariable(java.lang.String var_name)
Gets the value of a state variable
|
boolean |
hasVariable(java.lang.String var_name)
Checks if a statechart has a variable of given name
|
protected void |
putAllStateVariables(Statechart<T> sc) |
Statechart<T> |
reset()
Resets the statechart to its initial configuration
|
Statechart<T> |
setParent(Statechart<T> parent)
Sets the enclosing instance of this statechart
|
void |
setTransitions(java.util.Map<java.lang.Integer,java.util.Set<Transition<T>>> m_transitions) |
Statechart<T> |
setVariable(java.lang.String name,
java.lang.Object value)
Sets the value of a state variable.
|
Transition<T> |
takeTransition(T event)
Takes a transition in this statechart with the given event
|
public static final java.lang.String UP
public static final java.lang.String TRASH
public final java.lang.String m_name
protected final TrashTransition<T extends Event> m_trashTransition
protected int m_currentState
protected int m_initialState
protected final State<T extends Event> m_trashState
protected Statechart<T extends Event> m_parent
protected java.util.Map<java.lang.String,java.lang.Object> m_variables
protected java.util.Map<java.lang.String,java.lang.Object> m_initialValues
public Statechart(java.lang.String name)
name - The name given to this statechartpublic Statechart()
public Statechart<T> setVariable(java.lang.String name, java.lang.Object value)
name - The name of the variablevalue - The value of the variablepublic Statechart<T> setParent(Statechart<T> parent)
parent - The instancepublic Statechart<T> getParent()
null if this statechart has no parentpublic State<T> getState(int id)
id - The IDnull if no state exists with such IDpublic State<T> getAnyAtomicChild()
NestedState. The method recurses inside nested states if
the statechart only has nested states.
This method is mostly used for the graphical
rendering of a statechart.null if no such state existspublic State<T> getAnyAtomicChild(State<T> state)
NestedState and is contained within the state
given as argument. This method is mostly used for the graphical
rendering of a statechart.state - The state in questionnull if no such state existspublic Statechart<T> add(State<T> s)
s - The statepublic Statechart<T> add(int source, Transition<T> transition)
source - The ID of the source statetransition - The transitionpublic Statechart<T> add(java.lang.String source_name, Transition<T> transition)
source - The name of the source statetransition - The transitionpublic Transition<T> takeTransition(T event)
event - The eventpublic boolean applyTransition(T event, Configuration<T> node)
event - The event to applynode - The state nodetrue if the transition could be applied, false
otherwiseprotected State<T> getState(java.lang.String name)
name - The namenull if no state exists with such namepublic Configuration<T> getCurrentConfiguration()
public Statechart<T> reset()
public Statechart<T> clone(Statechart<T> parent)
parent - The parent statechart, in case this statechart is enclosed
within another. Set to null otherwisepublic int getEdgeCount()
public Configuration<T> getInitialConfiguration()
public boolean hasVariable(java.lang.String var_name)
var_name - The name of the variabletrue if the statechart has the variable, false
otherwisepublic java.lang.Object getVariable(java.lang.String var_name)
var_name - The name of the variablenull if the variable is not defined
in this statechartpublic static Statechart<?> findOwner(Statechart<?> statechart, java.lang.String var_name)
statechart - The statechart used as a starting point for the search.var_name - The name of the variablenull
if the variable could not be found in this statechart, nor any of its
parentspublic Statechart<?> findOwner(java.lang.String var_name)
var_name - The name of the variablenull
if the variable could not be found in this statechart, nor any of its
parentspublic java.util.Map<java.lang.Integer,java.util.Set<Transition<T>>> getTransitions()
public void setTransitions(java.util.Map<java.lang.Integer,java.util.Set<Transition<T>>> m_transitions)
m_transitions - the m_transitions to setpublic java.util.Map<java.lang.String,State<T>> getStates()
protected void putAllStateVariables(Statechart<T> sc)
Copyright © Sylvain HallĂ©. All Rights Reserved.