KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > SOFA > SOFAnode > Util > DFSRChecker > state > State


1 /*
2  * $Id: State.java,v 1.4 2005/07/08 12:04:12 kofron Exp $
3  *
4  * Copyright 2004
5  * Distributed Systems Research Group
6  * Department of Software Engineering
7  * Faculty of Mathematics and Physics
8  * Charles University, Prague
9  *
10  * Copyright 2005
11  * Formal Methods In Software Engineering Group
12  * Institute of Computer Science
13  * Academy of Sciences of the Czech Republic
14  *
15  * This code was developed by Jan Kofron <kofron@nenya.ms.mff.cuni.cz>
16  */

17
18
19 package SOFA.SOFAnode.Util.DFSRChecker.state;
20
21
22 /**
23  * This is abstract class representing a general state of the automaton
24  */

25 abstract public class State implements Comparable JavaDoc {
26
27     /** Creates a new instance of State */
28     public State() {
29         this.signature = new Signature();
30         this.signatureInit = false;
31         this.label = "<no_label>";
32         this.cycleStart = false;
33         //this.signature.accpetingCycleId = -1;
34
//this.acceptingReachable = false;
35
this.cycleTrace = null;
36     }
37
38     /**
39      * Comparison of references to State instances. The comparison of states is
40      * based on comparison of their signatures denoting the internal structure
41      * of the states
42      */

43      public boolean equals(State another) {
44          return this.getSignature().equals(another.getSignature());
45      }
46
47
48     /**
49      * @return the signature as the string Note that the entire buffer is
50      * returned
51      */

52     public Signature getSignature() {
53         if (!this.signatureInit) {
54             createSignature();
55             signatureInit = true;
56         }
57
58         //Debug.println("Signature: " + this.signature);
59
return this.signature;
60     }
61     
62     /**
63      *
64      * @see java.lang.Comparable#compareTo(java.lang.Object)
65      */

66     public int compareTo(Object JavaDoc o) {
67         if (o instanceof State) {
68             return this.getSignature().compareTo(((State)o).getSignature());
69         }
70         else
71             return -1;
72     }
73     
74     
75     /**
76      *
77      * @return true if this state is accpeting reachable
78      */

79     public boolean isAcceptingReachable() {
80         return ((signature.acceptingCycleId >> 63) & 1) != 0;
81     }
82
83     /**
84      * Creates the signature for this state if needed
85      */

86     abstract protected void createSignature();
87     
88     
89
90     //--------------------------------------------------------------------------
91
/**
92      * Signature of the state. The signature is compute from the substates as
93      * string concatenation and prepending the state type sign.
94      */

95     protected Signature signature;
96
97     /**
98      * The label of the state corresponding with the automaton state from
99      * visualization.
100      */

101     public String JavaDoc label;
102
103     /**
104      * flag for the start of a cycle
105      */

106     public boolean cycleStart;
107
108     /**
109      * timestamp of this when it was explored for the first time
110      */

111     public long timestamp;
112
113     /**
114      * the trace of the cycle if this is the start point
115      */

116     public String JavaDoc cycleTrace;
117     
118     /**
119      * Is this.signature already initialized and evaluated?
120      */

121     private boolean signatureInit;
122     
123 }
124
125
Popular Tags