1 package Analysis.Disjoint;
9 //////////////////////////////////////////////
11 // SMFEState is part of a
12 // (S)tate (M)achine (F)or (E)ffects.
14 // StateMachineForEffects describes an intial
15 // state and the effect transtions a DFJ
16 // traverser should make from the current state
17 // when searching for possible runtime conflicts.
19 //////////////////////////////////////////////
21 public class SMFEState {
23 // uniquely identifies this state
24 protected FlatNode id;
26 // all possible effects in this state
27 protected Set<Effect> effects;
29 // the given effect allows a transition to a
31 protected Hashtable< Effect, Set<SMFEState> > e2states;
34 public SMFEState( FlatNode id ) {
36 effects = new HashSet<Effect>();
37 e2states = new Hashtable< Effect, Set<SMFEState> >();
40 public void addEffect( Effect e ) {
44 // the given effect allows the transition to the new state
45 public void addTransition( Effect effect,
49 Set<SMFEState> states = e2states.get( effect );
50 if( states == null ) {
51 states = new HashSet<SMFEState>();
53 states.add( stateTo );
56 public FlatNode getID() {
61 public boolean equals( Object o ) {
66 if( !(o instanceof SMFEState) ) {
70 SMFEState state = (SMFEState) o;
72 return id.equals( state.id );
75 public int hashCode() {
80 public String toStringDOT() {
82 // first create the state as a node in DOT graph
83 String s = " "+id.nodeid+
84 "[shape=box,label=\"";
86 if( effects.size() == 1 ) {
87 s += effects.iterator().next().toString();
89 } else if( effects.size() > 1 ) {
91 Iterator<Effect> eItr = effects.iterator();
92 while( eItr.hasNext() ) {
93 Effect e = eItr.next();
96 if( eItr.hasNext() ) {
104 // then each transition is an edge
105 Iterator<Effect> eItr = e2states.keySet().iterator();
106 while( eItr.hasNext() ) {
107 Effect e = eItr.next();
108 Set<SMFEState> states = e2states.get( e );
110 Iterator<SMFEState> sItr = states.iterator();
111 while( sItr.hasNext() ) {
112 SMFEState state = sItr.next();
115 id.nodeid+" -> "+state.id.nodeid+
116 "[label=\""+e+"\"];";