KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * $Id: Signature.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 package SOFA.SOFAnode.Util.DFSRChecker.state;
19
20 /**
21  * This class represent the siganture of a state. The nested states do share the
22  * same signature array, and differ only in the indices.
23  */

24 public class Signature extends BitList {
25     /**
26      * The ctor creates the new instance of Signature.
27      */

28     public Signature() {
29         super(size);
30         acceptingCycleId = Long.MAX_VALUE;
31     }
32
33     /**
34      * Sets the default size for the buffer - all sinatures will
35      * have the same maximal size.
36      * @param _size new size
37      */

38     public static void setSize(int _size) {
39         size = _size;
40     }
41     
42     /**
43      * Getter method for signature size.
44      * @return the size of all signatures within this run
45      */

46     public static int getSize() {
47         return size;
48     }
49
50     /**
51      *
52      * @see java.lang.Object#equals(java.lang.Object)
53      */

54     public boolean equals(Object JavaDoc o) {
55         if (o instanceof Signature)
56             return (super.equals(o)); /*&& ((this.acceptingCycleId >>> 63) & 1) == ((((Signature)o).acceptingCycleId >>> 63) & 1);*/
57         else
58             return false;
59             
60     }
61     
62     /**
63      * Tests whether this state is accepting reachable.
64      */

65     public boolean isAcceptingReachable() {
66         return ((acceptingCycleId >>> 63) & 1) != 0;
67     }
68     
69     /**
70      * Sets this state accepting reachable.
71      */

72     public void setAcceptingReachable(boolean accepting) {
73         if (accepting)
74             acceptingCycleId |= ((long)1 << 63);
75         else
76             acceptingCycleId &= (~((long)1 << 63));
77     }
78     
79     /**
80      * Sets the cycle id.
81      * @param id cycle id
82      */

83     public void setCycleId(long id) {
84         acceptingCycleId = id | (((acceptingCycleId >>> 63) & 1) << 63);
85     }
86     
87     /**
88      * Gets the cycle id.
89      * @return the cycle id.
90      */

91     public long getCycleId() {
92         return acceptingCycleId & (~((long)1 << 63));
93     }
94     
95     /**
96      * concatenates two signatures
97      * @param second the signature to be added to this
98      */

99     public void concat(Signature second) {
100         super.concat(second);
101     }
102     
103     /**
104      *
105      * @see java.lang.Object#toString()
106      */

107     public String JavaDoc toString() {
108         return super.toString();
109     }
110
111     //--------------------------------------------------------------------
112

113     /**
114      * the maximal size of all buffers
115      */

116     static private int size = 0;
117
118     /**
119      * denotes that the state with this signature can reach
120      * an accepting state
121      */

122     public long acceptingCycleId;
123     
124 }
125
126
Popular Tags