com.googlecode.jinahya.util.fsm
Class Machine

java.lang.Object
  extended by com.googlecode.jinahya.util.fsm.Machine

public class Machine
extends Object

A Finite State Machine.

Author:
Jin Kwon

Constructor Summary
Machine(MachineContext context)
          Creates a new instance.
 
Method Summary
 State getState()
          Returns current state.
protected  boolean isAllowed(Transition transition)
          Checks if given transition is allowed.
 boolean isFinished()
          Returns finished flag value.
protected  boolean isFinishing(Transition transition)
          Checks if given transition is an finishing condition.
 boolean isStarted()
          Returns started flag value.
protected  boolean isStarting(Transition transition)
          Checks if given transition is a starting condition.
 void setState(State state)
          Sets state.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Machine

public Machine(MachineContext context)
Creates a new instance.

Parameters:
context - task context
Method Detail

getState

public State getState()
Returns current state.

Returns:
state

setState

public void setState(State state)
              throws FSMException
Sets state.

Parameters:
state - new state
Throws:
FSMException - if an error occurs.

isStarted

public final boolean isStarted()
Returns started flag value.

Returns:
true if this machine has been started; false otherwise.

isFinished

public final boolean isFinished()
Returns finished flag value.

Returns:
true if this machine has been finished; false otherwise.

isStarting

protected boolean isStarting(Transition transition)
Checks if given transition is a starting condition. Default implementation always returns true. Override this method if customizations are needed.

Parameters:
transition - transition to check
Returns:
true

isAllowed

protected boolean isAllowed(Transition transition)
Checks if given transition is allowed. Default implementation always returns true. Override this method if customizations are needed.

Parameters:
transition - transition to check.
Returns:
true

isFinishing

protected boolean isFinishing(Transition transition)
Checks if given transition is an finishing condition. Default implementation always returns false. Override this method if customizations are needed.

Parameters:
transition - transition to check
Returns:
false


Copyright © 2011. All Rights Reserved.