public String toString() { StringBuffer tmp = new StringBuffer("StateMachine[:\n"); tmp.append("\tCurrentState: "+currentState.getName()); Iterator i = states.iterator(); while( i.hasNext() ) { tmp.append('\n').append(i.next()); } tmp.append(']'); return tmp.toString(); } }
public String toString() { StringBuffer tmp = new StringBuffer("State(name="); tmp.append(name); Iterator i = allowedTransitions.entrySet().iterator(); while( i.hasNext() ) { Map.Entry e = (Map.Entry) i.next(); tmp.append("\n\t on: "); tmp.append(e.getKey()); Transition t = (Transition) e.getValue(); tmp.append(" go to: "); tmp.append(t.getTarget().getName()); } tmp.append(')'); return tmp.toString(); } }
public boolean inService() throws PolicyContextException { validateState("inService"); State state = configStateMachine.getCurrentState(); boolean inService = state.getName().equals("inService"); return inService; }
/** Transition to the next state given the name of a valid transition. * @param actionName - the name of transition that is valid for the * current state. * @return the next state * @throws IllegalTransitionException */ public State nextState(String actionName) throws IllegalTransitionException { Transition t = currentState.getTransition(actionName); if( t == null ) { String msg = "No transition for action: '" + actionName + "' from state: '" + currentState.getName() + "'"; throw new IllegalTransitionException(msg); } State nextState = t.getTarget(); log.trace("nextState("+actionName+") = "+nextState); currentState = nextState; return currentState; }