Statemachine moved under the domain package.

git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/sandbox/graph2/trunk@144610 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
ddp committed 2002-05-08 17:48:56 +00:00
1 parent dc287abd3f
commit 20d217f17f
4 files changed
-328

No files matched your search

@@ -1,48 +0,0 @@
package org.apache.commons.graph.statemachine;
import org.apache.commons.graph.*;
/**
* Description of the Class
*/
public class State
implements Vertex, Named
{
private String name;
private StateMachine subMachine = null;
/**
* Constructor for the State object
*
* @param name
*/
public State(String name)
{
this.name = name;
}
/**
* Gets the name attribute of the State object
*/
public String getName()
{
return name;
}
/**
* Sets the submachine attribute of the State object
*/
public void setSubmachine(StateMachine subMachine)
{
this.subMachine = subMachine;
}
/**
* Gets the submachine attribute of the State object
*/
public StateMachine getSubmachine()
{
return this.subMachine;
}
}
@@ -1,131 +0,0 @@
package org.apache.commons.graph.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.impl.*;
import org.apache.commons.graph.exception.*;
import org.apache.commons.graph.statemachine.exception.*;
/**
* Description of the Class
*/
public class StateMachine
extends DirectedGraphImpl
{
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 String name;
/**
* Constructor for the StateMachine object
*
* @param name
*/
public StateMachine(String name)
{
this.name = name;
}
/**
* Gets the name attribute of the StateMachine object
*/
public String getName()
{
return name;
}
/**
* Adds a feature to the State attribute of the StateMachine object
*/
public void addState(State state)
throws GraphException
{
states.put(state.getName(), state);
addVertex(state);
}
/**
* Adds a feature to the State attribute of the StateMachine object
*/
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;
}
/**
* Sets the finalState attribute of the StateMachine object
*/
public void setFinalState(State state)
{
finalStates.add(state);
}
/**
* Adds a feature to the Transition attribute of the StateMachine object
*/
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
*/
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
*/
public void addTransition(Transition trans)
throws GraphException
{
transes.put(trans.getName(), trans);
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 attribute of the StateMachine object
*/
public Transition getTransition(String name)
{
return (Transition) transes.get(name);
}
}
@@ -1,111 +0,0 @@
package org.apache.commons.graph.statemachine;
import org.apache.commons.graph.*;
/**
* Description of the Class
*/
public class Transition
implements Edge, Named
{
private String name;
private State source;
private State target;
private String action = null;
private String guard = null;
private String output = null;
/**
* Description of the Field
*/
public final static String EPSILON = "\u03B5";
/**
* Constructor for the Transition object
*
* @param name
* @param source
* @param target
*/
public Transition(String name,
State source,
State target)
{
this.name = name;
this.source = source;
this.target = target;
}
/**
* Gets the name attribute of the Transition object
*/
public String getName()
{
return name;
}
/**
* Gets the source attribute of the Transition object
*/
public State getSource()
{
return source;
}
/**
* Gets the target attribute of the Transition object
*/
public State getTarget()
{
return target;
}
/**
* Sets the action attribute of the Transition object
*/
public void setAction()
{
this.action = action;
}
/**
* Gets the action attribute of the Transition object
*/
public String getAction()
{
return action;
}
/**
* Sets the guard attribute of the Transition object
*/
public void setGuard(String guard)
{
this.guard = guard;
}
/**
* Gets the guard attribute of the Transition object
*/
public String getGuard()
{
return guard;
}
/**
* Gets the output attribute of the Transition object
*/
public String getOutput()
{
return output;
}
/**
* Sets the output attribute of the Transition object
*/
public void setOutput(String output)
{
this.output = output;
}
}
@@ -1,38 +0,0 @@
package org.apache.commons.graph.statemachine.exception;
import org.apache.commons.graph.exception.*;
/**
* Description of the Class
*/
public class StateMachineException
extends GraphException
{
/**
* Constructor for the StateMachineException object
*/
public StateMachineException()
{
super();
}
/**
* Constructor for the StateMachineException object
*
* @param msg
*/
public StateMachineException(String msg)
{
super(msg);
}
/**
* Constructor for the StateMachineException object
*
* @param t
*/
public StateMachineException(Throwable t)
{
super(t);
}
}