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>();
52 e2states.put( effect, states );
54 states.add( stateTo );
57 public FlatNode getID() {
62 public boolean equals( Object o ) {
67 if( !(o instanceof SMFEState) ) {
71 SMFEState state = (SMFEState) o;
73 return id.equals( state.id );
76 public int hashCode() {
81 public String toStringDOT() {
83 // first create the state as a node in DOT graph
84 String s = " "+id.nodeid+
85 "[shape=box,label=\"";
87 if( effects.size() == 1 ) {
88 s += effects.iterator().next().toString();
90 } else if( effects.size() > 1 ) {
92 Iterator<Effect> eItr = effects.iterator();
93 while( eItr.hasNext() ) {
94 Effect e = eItr.next();
97 if( eItr.hasNext() ) {
105 // then each transition is an edge
106 Iterator<Effect> eItr = e2states.keySet().iterator();
107 while( eItr.hasNext() ) {
108 Effect e = eItr.next();
109 Set<SMFEState> states = e2states.get( e );
111 Iterator<SMFEState> sItr = states.iterator();
112 while( sItr.hasNext() ) {
113 SMFEState state = sItr.next();
116 id.nodeid+" -> "+state.id.nodeid+
117 "[label=\""+e+"\"];";