com.evelopers.unimod.core.stateworks
Class State

java.lang.Object
  extended bycom.evelopers.unimod.core.ModelElement
      extended bycom.evelopers.unimod.core.stateworks.State
All Implemented Interfaces:
java.io.Serializable

public class State
extends ModelElement

State abstraction.

See Also:
Serialized Form

Field Summary
static java.lang.String INCOMING_TRANSITIONS_PROPERTY
           
protected  java.util.List incomingTransitions
          Incoming transitions.
static java.lang.String ON_ENTER_ACTIONS_PROPERTY
           
protected  java.util.List onEnterActions
          On-enter actions to be executed on-enter
static java.lang.String OUTGOING_TRANSITIONS_PROPERTY
           
protected  java.util.List outgoingTransitions
          Outgoing transitions.
static java.lang.String STATE_TYPE_PROPERTY
           
protected  java.util.List submachines
          Included state machines to be executed on-enter if current state is active.
static java.lang.String SUBMACHINES_PROPERTY
           
protected  java.util.List substates
          Substates.
static java.lang.String SUBSTATES_PROPERTY
           
protected  State superstate
          Superstate.
protected  StateType type
           
 
Fields inherited from class com.evelopers.unimod.core.ModelElement
listeners, name, NAME_PROPERTY, stereotype, STEREOTYPE_PROPERTY
 
Constructor Summary
protected State(java.lang.String name, StateType type)
          Creates states with given name.
 
Method Summary
 void accept(ModelVisitor v)
          Accepts given visitor by substates if ModelVisitor.visit(com.evelopers.unimod.core.ModelElement)returns true.
(package private)  void addIncomingTransition(Transition transition)
          Adds incoming transition.
 void addOnEnterAction(Action action)
          Adds on-enter action
(package private)  void addOutgoingTransition(Transition transition)
          Adds outgoing transition.
 void addSubmachine(StateMachine sm)
          Adds included state machine
 void addSubstate(State substate)
          Adds substate.
 boolean equals(java.lang.Object o)
          Compare with another model element.
 java.util.List getEvents(boolean any)
          Returns all events that are located on outgoing transitions It's guaranteed that if ay event is present, it will be last in list
 java.util.List getFilteredOutgoingTransitions(Event event, boolean elseGuard)
          Returs filtered list of outgoing transitions.
 java.util.List getIncomingTransitions()
           
 State getInitialSubstate()
           
 java.util.List getOnEnterActions()
          Returns list of on-enter actions
 java.util.List getOutgoingTransitions()
          Returns outgoing transitions.
 java.util.List getSubmachines()
          Returns list of included state machines
 java.util.List getSubstates()
          Returns substates.
 State getSuperstate()
          Returns superstate.
 StateType getType()
          Returns state type.
 int hashCode()
          Returns model element hash code.
 boolean hasSuperstate()
          Returns true if state has superstate.
 boolean isComposite()
          Returns true if state has substates.
 boolean isTop()
          Returns true if state is top state
(package private)  void removeIncomingTransition(Transition transition)
           
 void removeOnEnterAction(Action action)
          Removes on-enter action
(package private)  void removeOutgoingTransition(Transition transition)
           
 void removeSubmachine(StateMachine sm)
          Removes given included state machine from list of submachines
 void removeSubstate(State substate)
          Removes given substate.
 void setSuperstate(State superstate)
          Sets superstate
 
Methods inherited from class com.evelopers.unimod.core.ModelElement
addPropertyChangeListener, firePropertyChange, getName, getStereotype, initListeners, removePropertyChangeListener, setName, setStereotype, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

STATE_TYPE_PROPERTY

public static final java.lang.String STATE_TYPE_PROPERTY
See Also:
Constant Field Values

OUTGOING_TRANSITIONS_PROPERTY

public static final java.lang.String OUTGOING_TRANSITIONS_PROPERTY
See Also:
Constant Field Values

INCOMING_TRANSITIONS_PROPERTY

public static final java.lang.String INCOMING_TRANSITIONS_PROPERTY
See Also:
Constant Field Values

SUBSTATES_PROPERTY

public static final java.lang.String SUBSTATES_PROPERTY
See Also:
Constant Field Values

SUBMACHINES_PROPERTY

public static final java.lang.String SUBMACHINES_PROPERTY
See Also:
Constant Field Values

ON_ENTER_ACTIONS_PROPERTY

public static final java.lang.String ON_ENTER_ACTIONS_PROPERTY
See Also:
Constant Field Values

type

protected StateType type

superstate

protected State superstate
Superstate. Null for top state.


outgoingTransitions

protected java.util.List outgoingTransitions
Outgoing transitions.


incomingTransitions

protected java.util.List incomingTransitions
Incoming transitions.


substates

protected java.util.List substates
Substates. Empty for simple state. If not empty then state is composite.


submachines

protected java.util.List submachines
Included state machines to be executed on-enter if current state is active.


onEnterActions

protected java.util.List onEnterActions
On-enter actions to be executed on-enter

Constructor Detail

State

protected State(java.lang.String name,
                StateType type)
Creates states with given name.

Parameters:
name - state name
Method Detail

getSuperstate

public State getSuperstate()
Returns superstate. Null for top state.

Returns:
superstate

setSuperstate

public void setSuperstate(State superstate)
Sets superstate

Parameters:
superstate - superstate

getOutgoingTransitions

public java.util.List getOutgoingTransitions()
Returns outgoing transitions.

Returns:
outgoing transitions

getIncomingTransitions

public java.util.List getIncomingTransitions()

getFilteredOutgoingTransitions

public java.util.List getFilteredOutgoingTransitions(Event event,
                                                     boolean elseGuard)
Returs filtered list of outgoing transitions.

Usage:

 
    State state = ...
    Event e1 = new Event("e1");
    List transitions;
 
    // Transitions trigged on event [e1] with not else guard condition
    transitions = state.getFilteredOutgoingTransitions(e1, false);
    ...
    // Transitions trigged on event [e1] with else guard condition
    transitions = state.getFilteredOutgoingTransitions(e1, true);
    ...
    // Transitions trigged on any event with not else guard condition
    transitions = state.getFilteredOutgoingTransitions(Event.ANY, false);
    ...
    // Transitions trigged on any event with else guard condition
    transitions = state.getFilteredOutgoingTransitions(Event.ANY, true);
  
 

If event is not equal to Event.ANY then transitions trigged on eny event won't be returned.

Parameters:
event - event trigging the transitions in result list
elseGuard - whether transitions in result list have else guard condition
Returns:
filtered list of transitions

addOutgoingTransition

void addOutgoingTransition(Transition transition)
Adds outgoing transition. For internal pusposes only, called by Transition.

Parameters:
transition - transition to add

removeOutgoingTransition

void removeOutgoingTransition(Transition transition)

addIncomingTransition

void addIncomingTransition(Transition transition)
Adds incoming transition. For internal pusposes only, called by Transition.

Parameters:
transition - transition to add

removeIncomingTransition

void removeIncomingTransition(Transition transition)

getType

public StateType getType()
Returns state type.

Returns:
state type

addSubstate

public void addSubstate(State substate)
Adds substate.

Parameters:
substate - state

removeSubstate

public void removeSubstate(State substate)
Removes given substate.

Parameters:
substate - state to remove
Throws:
java.lang.IllegalStateException - if given state is not substate of state is being called.

getInitialSubstate

public State getInitialSubstate()
Returns:
  • Initial substate if State is composite and has initial state;
  • null elsewise.

  • getSubstates

    public java.util.List getSubstates()
    Returns substates.

    Returns:
    substates

    isComposite

    public boolean isComposite()
    Returns true if state has substates.

    Returns:
    whether state has substates

    isTop

    public boolean isTop()
    Returns true if state is top state

    Returns:
    whether state is top state

    hasSuperstate

    public boolean hasSuperstate()
    Returns true if state has superstate. False only for top state.

    Returns:
    whether state has superstate

    getEvents

    public java.util.List getEvents(boolean any)
    Returns all events that are located on outgoing transitions It's guaranteed that if ay event is present, it will be last in list

    Parameters:
    any - include any events or not
    Returns:
    list of events

    getSubmachines

    public java.util.List getSubmachines()
    Returns list of included state machines

    Returns:
    list of included state machines

    addSubmachine

    public void addSubmachine(StateMachine sm)
    Adds included state machine

    Parameters:
    sm - state machine to include

    removeSubmachine

    public void removeSubmachine(StateMachine sm)
    Removes given included state machine from list of submachines

    Parameters:
    sm - state machine to remove

    getOnEnterActions

    public java.util.List getOnEnterActions()
    Returns list of on-enter actions

    Returns:
    list of on-enter actions

    addOnEnterAction

    public void addOnEnterAction(Action action)
    Adds on-enter action

    Parameters:
    action - action to add

    removeOnEnterAction

    public void removeOnEnterAction(Action action)
    Removes on-enter action

    Parameters:
    action - on-enter action to remove

    hashCode

    public int hashCode()
    Description copied from class: ModelElement
    Returns model element hash code.

    Specified by:
    hashCode in class ModelElement
    Returns:
    hash code

    equals

    public boolean equals(java.lang.Object o)
    Description copied from class: ModelElement
    Compare with another model element.

    Specified by:
    equals in class ModelElement
    Parameters:
    o - another model element
    Returns:
    boolean

    accept

    public void accept(ModelVisitor v)
                throws VisitorException
    Accepts given visitor by substates if ModelVisitor.visit(com.evelopers.unimod.core.ModelElement)returns true.

    Overrides:
    accept in class ModelElement
    Parameters:
    v - visitor to visit model element
    Throws:
    VisitorException - thrown by visitor methods
    See Also:
    ModelElement.accept(com.evelopers.unimod.core.ModelVisitor)