KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * $Id: DenotedState.java,v 1.1 2005/07/13 07:27:49 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 is to be used by an alternative node.
22  * It contains an index identifying the correct child, which state it also
23  * contains. The reason for existence of this class to make a reasonable estimate
24  * of the entire state signature and keep the signature size as small as possible.
25  * The problem is caused by the DeterministicNode used in higher levels of
26  * parse trees, where the signatures of superstates (created as o consequence of
27  * "deterministing" of the PT automaton.
28  * Please note that this is not an optimization, it is necessary for the signature
29  * principle to work.
30  */

31 public class DenotedState extends State {
32     
33     /**
34      * Creates a new instance of DenotedState.
35      *
36      * @param index index of the subtree which is the state related to
37      * @param state the state of a subtree
38      * @param children log(number of children of this state)
39      */

40     public DenotedState(int index, State state, int children) {
41         this.index = index;
42         this.state = state;
43         this.children = children;
44     }
45         
46
47     /**
48      * @see SOFA.SOFAnode.Util.objectweb.fractal.behprotocols.checker.state.State#createSignature()
49      */

50     protected void createSignature() {
51         if (index == -1)
52             for (int i = 0; i < children; ++i)
53                 signature.set(i, true); // the signature has a slot for -1 = 11..11
54

55         else
56             for (int i = 0; i < children; ++i)
57                 signature.set(i, (index & (1 << i)) != 0 ? true : false);
58         
59         signature.concat(state.getSignature());
60     }
61     
62     /**
63      * @see SOFA.SOFAnode.Util.objectweb.fractal.behprotocols.checker.state.State#equals(SOFA.SOFAnode.Util.objectweb.fractal.behprotocols.checker.state.State)
64      */

65     public boolean equals(State another) {
66         if (!(another instanceof DenotedState))
67             return false;
68
69         DenotedState dstate = (DenotedState) another;
70
71         if (this.index != dstate.index)
72             return false;
73
74         if (this.signature == null)
75             this.getSignature();
76
77         if (another.signature == null)
78             another.getSignature();
79
80         return this.getSignature().equals(dstate.getSignature());
81     }
82     
83     /**
84      * Index of the subtree to which the state is related
85      */

86     final public int index;
87     
88     /**
89      * State of a subtree
90      */

91     final public State state;
92     
93     /**
94      * Number of the children - necessary for signature construction
95      */

96     private int children;
97     
98
99 }
100
Popular Tags