站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > JBoss 3.2.7 common API Documentation 英文版文档

StateMachine.Model (JBoss/Common API) - JBoss 3.2.7 common API Documentation 英文版文档


org.jboss.util.state
Interface StateMachine.Model

All Superinterfaces:
Cloneable, CloneableObject.Cloneable, PrettyString.Appendable
All Known Implementing Classes:
DefaultStateMachineModel
Enclosing interface:
StateMachine

public static interface StateMachine.Model
extends CloneableObject.Cloneable, PrettyString.Appendable

Defines the data model required by a StateMachine.


Method Summary
 Set acceptableStates(State state)
          Return an immutable set of the acceptable states for a given accepting state.
 Set addState(State state)
          Add a final state.
 Set addState(State state, Set acceptable)
          Add a non-final state.
 Set addState(State state, State[] acceptable)
          Add a non-final state.
 void clear()
          Clear all accepting state mappings and reset the initial and current state to null.
 boolean containsState(State state)
          Check if a give state is contained in the model.
 State getCurrentState()
          Get the current state.
 State getInitialState()
          Return the initial state which the state machine should start in.
 State getMappedState(State state)
          Returns the state object mapped for the given state value.
 boolean isMappedState(State state)
          Determins if there is a mapping for the given state object.
 Set removeState(State state)
          Remove a state from the model.
 void setCurrentState(State state)
          Set the current state.
 void setInitialState(State state)
          Set the initial state.
 Set states()
          Return an immutable set of the accepting states.
 
Methods inherited from interface org.jboss.util.CloneableObject.Cloneable
clone
 
Methods inherited from interface org.jboss.util.PrettyString.Appendable
appendPrettyString
 

Method Detail

addState

public Set addState(State state,
                    Set acceptable)
Add a non-final state.

Existing acceptable states will be replaced by the given states.

Acceptable states which are not registered as accepting states will be added as final states.

If the acceptable set is null, then the added state will be final.

Note, states are added based on the valid states which can be transitioned to from the given state, not on the states which accept the given state.

For example, if adding state A which accepts B and C, this means that when the machine is in state A, it will allow transitions to B or C and not from C to A or B to A (unless of course a state mapping is setup up such that C and B both accept A).

Parameters:
state - The accepting state; must not be null.
acceptable - The valid acceptable states; must not contain null elements.

addState

public Set addState(State state,
                    State[] acceptable)
Add a non-final state.

Parameters:
state - The accepting state; must not be null.
acceptable - The valid acceptable states; must not contain null elements.
See Also:
addState(State,Set)

addState

public Set addState(State state)
Add a final state.

Note, if the given state implements StateMachine.Acceptable then the final determiniation of its finality will be unknown until runtime.

Parameters:
state - The final state; must not be null.

getMappedState

public State getMappedState(State state)
Returns the state object mapped for the given state value.

Since states with the same value are equivlent, this provides access to the actual state instance which is bound in the model.

Parameters:
state - The state with the value of the bound state to return; null will return false.
Returns:
The bound state instance.
Throws:
IllegalArgumentException - State not mapped.

isMappedState

public boolean isMappedState(State state)
Determins if there is a mapping for the given state object.

Parameters:
state - The state with the value of the bound state to check for; must not be null.
Returns:
True if the state is mapped; else false.
Throws:
IllegalArgumentException - State not mapped.

setInitialState

public void setInitialState(State state)
Set the initial state.

Does not need to validate the state, StateMachine will handle those details.

Parameters:
state - The initial state; must not be null.

getInitialState

public State getInitialState()
Return the initial state which the state machine should start in.

Returns:
The initial state of the state machine; must not be null.

setCurrentState

public void setCurrentState(State state)
Set the current state.

Does not need to validate the state, StateMachine will handle those details.

Parameters:
state - The current state; must not be null.

getCurrentState

public State getCurrentState()
Get the current state.

Returns:
The current state; can be null if not used by a state machine. Once it has been given to a state machine this must not be null.

containsState

public boolean containsState(State state)
Check if a give state is contained in the model.

Parameters:
state - The state to look for.
Returns:
True if the state is contained in the model; false if not.

removeState

public Set removeState(State state)
Remove a state from the model.

Parameters:
state - The state to remove.
Returns:
The acceptable states for the removed state or null.

clear

public void clear()
Clear all accepting state mappings and reset the initial and current state to null.


states

public Set states()
Return an immutable set of the accepting states.

Returns:
A set of accepting states.

acceptableStates

public Set acceptableStates(State state)
Return an immutable set of the acceptable states for a given accepting state.

Parameters:
state - The accepting state to get acceptable states for; must not be null.
Returns:
A set of accepting states.


Copyright © 2002 JBoss Group, LLC. All Rights Reserved.