You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by dd...@apache.org on 2002/08/23 15:51:50 UTC

cvs commit: jakarta-commons-sandbox/graph2/src/java/org/apache/commons/graph/domain/statemachine StateMachine.java

ddp         2002/08/23 06:51:50

  Modified:    graph2/src/java/org/apache/commons/graph/domain/statemachine
                        StateMachine.java
  Log:
  Removed Unused Variable
  
  Revision  Changes    Path
  1.2       +163 -164  jakarta-commons-sandbox/graph2/src/java/org/apache/commons/graph/domain/statemachine/StateMachine.java
  
  Index: StateMachine.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/graph2/src/java/org/apache/commons/graph/domain/statemachine/StateMachine.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- StateMachine.java	8 May 2002 17:43:20 -0000	1.1
  +++ StateMachine.java	23 Aug 2002 13:51:50 -0000	1.2
  @@ -1,164 +1,163 @@
  -package org.apache.commons.graph.domain.statemachine;
  -
  -import java.util.Map;
  -import java.util.Set;
  -import java.util.HashMap;
  -import java.util.HashSet;
  -import java.util.Iterator;
  -
  -import org.apache.commons.graph.*;
  -import org.apache.commons.graph.exception.*;
  -import org.apache.commons.graph.domain.basic.*;
  -import org.apache.commons.graph.contract.Contract;
  -import org.apache.commons.graph.factory.GraphFactory;
  -import org.apache.commons.graph.decorator.DDirectedGraph;
  -import org.apache.commons.graph.statemachine.exception.*;
  -
  -/**
  - * StateMachine -
  - * 
  - * This represents a Finite State Machine.  It has a collection
  - * of states and transitions which move between them.
  - */
  -public class StateMachine
  -     extends DDirectedGraph
  -{
  -  private Map states = new HashMap();// NAME X STATE
  -  private Map transes = new HashMap();// NAME X TRANSITION
  -  private Set finalStates = new HashSet();
  -  private State startState = null;
  -  private MutableDirectedGraph graph = null;
  -  private String name;
  -  private GraphFactory factory = new GraphFactory();
  -
  -    /**
  -     * Create a new StateMachine given the name.
  -     *
  -     * @param name Name (or Namespace) of StateMachine
  -     */
  -    public StateMachine(String name)
  -    {
  -        this.name = name;
  -	
  -	Contract[] contracts = new Contract[0];
  -	graph = factory.makeMutableDirectedGraph( contracts,
  -						  false,
  -						  null );
  -	setDirGraph( graph );
  -    }
  -
  -    /**
  -     * Gets the StateMachines name (or namespace)
  -     */
  -    public String getName()
  -    {
  -        return name;
  -    }
  -
  -    /**
  -     * Adds a State to the collection of states maintained
  -     * by the machine.
  -     */
  -    public void addState(State state)
  -        throws GraphException
  -    {
  -        states.put(state.getName(), state);
  -        graph.addVertex(state);
  -    }
  -
  -    /**
  -     * Creates a new State with name provided.  Adds it to the
  -     * machine.
  -     */
  -    public void addState(String name)
  -        throws GraphException
  -    {
  -        State newState = new State(name);
  -        addState(new State(name));
  -    }
  -
  -    /**
  -     * Sets the startState attribute of the StateMachine object
  -     */
  -    public void setStartState(State state)
  -    {
  -        startState = state;
  -    }
  -
  -    /**
  -     * Adds the state to the set of Final States available.
  -     */
  -    public void addFinalState(State state)
  -    {
  -        finalStates.add(state);
  -    }
  -
  -    /**
  -     * Add a Transition to the diagram with the name provided.
  -     *
  -     * This transition traverses from the State specified in source
  -     * and the target.
  -     * @param name Name of the Transition.
  -     * @param source Name of the Source State.
  -     * @param target Name of the Target State.
  -     */
  -    public void addTransition(String name,
  -                              String source,
  -                              String target)
  -        throws GraphException
  -    {
  -        addTransition(name,
  -            getState(source),
  -            getState(target));
  -    }
  -
  -    /**
  -     * Adds a feature to the Transition attribute of the StateMachine object.
  -     * @param name Name of the Transition
  -     * @param source Source of the Transition
  -     * @param target Target of the Transition
  -     */
  -    public void addTransition(String name,
  -                              State source,
  -                              State target)
  -        throws GraphException
  -    {
  -        Transition trans = new Transition(name, source, target);
  -        addTransition(trans);
  -    }
  -
  -    /**
  -     * Adds a feature to the Transition attribute of the StateMachine object.
  -     * Transition is expected to know its source and target.
  -     */
  -    public void addTransition(Transition trans)
  -        throws GraphException
  -    {
  -        transes.put(trans.getName(), trans);
  -        graph.addEdge(trans, trans.getSource(), trans.getTarget());
  -    }
  -
  -    /**
  -     * Gets the state attribute of the StateMachine object
  -     */
  -    public State getState(String name)
  -    {
  -        return (State) states.get(name);
  -    }
  -
  -    /**
  -     * Gets the Transition associated with the Name. 
  -     */
  -    public Transition getTransition(String name)
  -    {
  -        return (Transition) transes.get(name);
  -    }
  -}
  -
  -
  -
  -
  -
  -
  -
  -
  +package org.apache.commons.graph.domain.statemachine;
  +
  +import java.util.Map;
  +import java.util.Set;
  +import java.util.HashMap;
  +import java.util.HashSet;
  +import java.util.Iterator;
  +
  +import org.apache.commons.graph.*;
  +import org.apache.commons.graph.exception.*;
  +import org.apache.commons.graph.domain.basic.*;
  +import org.apache.commons.graph.contract.Contract;
  +import org.apache.commons.graph.factory.GraphFactory;
  +import org.apache.commons.graph.decorator.DDirectedGraph;
  +import org.apache.commons.graph.domain.statemachine.exception.*;
  +
  +/**
  + * StateMachine -
  + * 
  + * This represents a Finite State Machine.  It has a collection
  + * of states and transitions which move between them.
  + */
  +public class StateMachine
  +     extends DDirectedGraph
  +{
  +  private Map states = new HashMap();// NAME X STATE
  +  private Map transes = new HashMap();// NAME X TRANSITION
  +  private Set finalStates = new HashSet();
  +  private State startState = null;
  +  private MutableDirectedGraph graph = null;
  +  private String name;
  +  private GraphFactory factory = new GraphFactory();
  +
  +    /**
  +     * Create a new StateMachine given the name.
  +     *
  +     * @param name Name (or Namespace) of StateMachine
  +     */
  +    public StateMachine(String name)
  +    {
  +        this.name = name;
  +	
  +	Contract[] contracts = new Contract[0];
  +	graph = factory.makeMutableDirectedGraph( contracts,
  +						  false,
  +						  null );
  +	setDirGraph( graph );
  +    }
  +
  +    /**
  +     * Gets the StateMachines name (or namespace)
  +     */
  +    public String getName()
  +    {
  +        return name;
  +    }
  +
  +    /**
  +     * Adds a State to the collection of states maintained
  +     * by the machine.
  +     */
  +    public void addState(State state)
  +        throws GraphException
  +    {
  +        states.put(state.getName(), state);
  +        graph.addVertex(state);
  +    }
  +
  +    /**
  +     * Creates a new State with name provided.  Adds it to the
  +     * machine.
  +     */
  +    public void addState(String name)
  +        throws GraphException
  +    {
  +        addState(new State(name));
  +    }
  +
  +    /**
  +     * Sets the startState attribute of the StateMachine object
  +     */
  +    public void setStartState(State state)
  +    {
  +        startState = state;
  +    }
  +
  +    /**
  +     * Adds the state to the set of Final States available.
  +     */
  +    public void addFinalState(State state)
  +    {
  +        finalStates.add(state);
  +    }
  +
  +    /**
  +     * Add a Transition to the diagram with the name provided.
  +     *
  +     * This transition traverses from the State specified in source
  +     * and the target.
  +     * @param name Name of the Transition.
  +     * @param source Name of the Source State.
  +     * @param target Name of the Target State.
  +     */
  +    public void addTransition(String name,
  +                              String source,
  +                              String target)
  +        throws GraphException
  +    {
  +        addTransition(name,
  +            getState(source),
  +            getState(target));
  +    }
  +
  +    /**
  +     * Adds a feature to the Transition attribute of the StateMachine object.
  +     * @param name Name of the Transition
  +     * @param source Source of the Transition
  +     * @param target Target of the Transition
  +     */
  +    public void addTransition(String name,
  +                              State source,
  +                              State target)
  +        throws GraphException
  +    {
  +        Transition trans = new Transition(name, source, target);
  +        addTransition(trans);
  +    }
  +
  +    /**
  +     * Adds a feature to the Transition attribute of the StateMachine object.
  +     * Transition is expected to know its source and target.
  +     */
  +    public void addTransition(Transition trans)
  +        throws GraphException
  +    {
  +        transes.put(trans.getName(), trans);
  +        graph.addEdge(trans, trans.getSource(), trans.getTarget());
  +    }
  +
  +    /**
  +     * Gets the state attribute of the StateMachine object
  +     */
  +    public State getState(String name)
  +    {
  +        return (State) states.get(name);
  +    }
  +
  +    /**
  +     * Gets the Transition associated with the Name. 
  +     */
  +    public Transition getTransition(String name)
  +    {
  +        return (Transition) transes.get(name);
  +    }
  +}
  +
  +
  +
  +
  +
  +
  +
  +
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>