it.amattioli.workstate.core
Class MetaCompositeState

Show UML class diagram
java.lang.Object
  extended by it.amattioli.workstate.core.MetaState
      extended by it.amattioli.workstate.core.MetaRealState
          extended by it.amattioli.workstate.core.MetaCompositeState
All Implemented Interfaces:
Receiver
Direct Known Subclasses:
MetaConcurrentState, MetaSequentialState

public abstract class MetaCompositeState
extends MetaRealState

A MetaCompositeState is the configuration of a state that can have sub-states. This abstract class has facility methods to manipulate these sub-states: adding a sub-state, checking a sub-state existence, etc.


Constructor Summary
MetaCompositeState(String tag, StateAction entry, StateAction exit)
          Construct a new MetaCompositeState given its identifier (tag) and its entry and exit action.
 
Method Summary
 void addMetaState(MetaState newMetaState)
          Add a sub-state to this state.
protected  void checkAllowedSubstate(MetaState newMetaState)
          Verifies that a MetaState can be a sub-state of this.
 MetaState getSubstate(String tag)
          Returns, if exists, the sub-state of this state with a given tag.
 Collection<MetaState> getSubstates()
          Returns an (unmodifiable) collection containing the sub-state of this state.
 boolean isAncestorOf(MetaState metaState)
          Check if this meta-state is a super-state of the passed one.
 boolean isSubstate(String tag)
          Verifies if this state has a sub-state whose tag is passed as a parameter.
 void receive(Visitor visitor)
           
 
Methods inherited from class it.amattioli.workstate.core.MetaRealState
addAttribute, checkAttribute, equals, getEntryAction, getExitAction, getTag, initialAttributesValues, isAllowedAttribute, toString
 
Methods inherited from class it.amattioli.workstate.core.MetaState
addAvailableEvents, addTransition, checkParentState, descendFrom, findTriggeredTransition, getAvailableEvents, getConfig, getParent, newState, setParent
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MetaCompositeState

public MetaCompositeState(String tag,
                          StateAction entry,
                          StateAction exit)
Construct a new MetaCompositeState given its identifier (tag) and its entry and exit action.

Parameters:
tag - this state identifier
entry - this state entry action. Passing null means no action should be performed
exit - this state exit action. Passing null means no action should be performed
Throws:
NullPointerException - if the tag is null
Method Detail

checkAllowedSubstate

protected void checkAllowedSubstate(MetaState newMetaState)
Verifies that a MetaState can be a sub-state of this. This method should be called before an attempt to add a new substate to this and verifies that this action is allowed or not. The implementation in this class verifies that there is not another sub-state with the same tag but subclasses are free to redefine this method as long as they call super.checkAllowedSubstate. if the passed MetaState can be a sub-state of this the method will end normally, otherwise an IllegalArgumentException is thrown.

Parameters:
newMetaState - the MetaState that shoud be checked
Throws:
IllegalArgumentException - if the argument cannot be a sub-state of this state

addMetaState

public void addMetaState(MetaState newMetaState)
Add a sub-state to this state. Before adding the sub-state this method check that the passed meta-state can be a sub-state of this state calling checkAllowedSubstate(MetaState).

Parameters:
newMetaState - the new sub-state
Throws:
NullPointerException - if the parameter is null
IllegalArgumentException - if the parameter cannot be a sub-state of this state

isAncestorOf

public boolean isAncestorOf(MetaState metaState)
Check if this meta-state is a super-state of the passed one.

Parameters:
metaState -
Throws:
NullPointerException - if the parameter is null

getSubstates

public Collection<MetaState> getSubstates()
Returns an (unmodifiable) collection containing the sub-state of this state.

Returns:
the sub-states of this state

isSubstate

public boolean isSubstate(String tag)
Verifies if this state has a sub-state whose tag is passed as a parameter.

Parameters:
tag - the tag of the sub-state
Returns:
true if this state has a sub-state whose tag is passed as a parameter, false otherwise

getSubstate

public MetaState getSubstate(String tag)
Returns, if exists, the sub-state of this state with a given tag. If such a state does not exists, an IllegalArgumentException is thrown.


receive

public void receive(Visitor visitor)


Copyright © 2011. All Rights Reserved.