package jsetool.data; import java.io.Serializable; /** * @author Mike Lawson * * As of Oct 20, 2004 * * The Transition class represents either a SEND or RECEIVE transition * in the CFSM diagram. It is composed of a message. * * */ public class Transition implements Serializable { /** Denotes a SEND transition */ public static final short SEND = 0; /** Denotes a RECEIVE transition */ public static final short RECEIVE = 1; /** The transition type - either SEND or RECEIVE */ protected short transitionType; /** The message being sent */ protected String message; protected MachineState sourceState; protected MachineState targetState; protected boolean explored = false; /** * Constructs a new Transition object * @param type the type of transition, either SEND or RECEIVE * @param source the state where this transition comes FROM * @param targetState the state that this transition goes TO * @param message the message associated with the transition */ public Transition(short type, MachineState source, MachineState targetState, String message) { this.transitionType = type; this.message = message; this.sourceState = source; this.targetState = targetState; } /** * Returns the String representation of this transition as we specified * in CS522: -M for sending M, +R for receiving R * @return String */ public String toString() { String modifier = transitionType == SEND ? "-" : "+"; return modifier + message; } /** * Returns a more verbose String version of this object. * @return String */ public String verboseString() { return sourceState.getStateName() + " " + toString() + " " + targetState.getStateName(); } /** * Returns true if this transition has been explored. * @return boolean */ public boolean isExplored() { return explored; } /** * Sets this transition as having been explored. */ public void setExplored() { this.explored = true; } /** * @return Returns the message. */ public String getMessage() { return message; } /** * @return Returns the targetState. */ public MachineState getTargetState() { return targetState; } /** * @return Returns the transitionType. */ public short getTransitionType() { return transitionType; } }