KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > SOFA > SOFAnode > Util > DFSRChecker > DFSR > DFSRConsent


1 /*
2  * $Id: DFSRConsent.java,v 1.2 2005/07/08 12:04:11 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.DFSR;
19
20
21 import SOFA.SOFAnode.Util.DFSRChecker.node.ConsentNode;
22 import SOFA.SOFAnode.Util.DFSRChecker.node.InvalidParameterException;
23 import SOFA.SOFAnode.Util.DFSRChecker.state.State;
24
25
26 /**
27  * This class perform the checking operation in each state.
28  * It is called from the DFSRTraverser that implements the generic DFS algorithm.
29  */

30 public class DFSRConsent implements IDFSRExtension {
31
32     /**
33      * Creates a new instance of DFSRConsent.
34      * @param automaton the root of the parse tree
35      */

36     public DFSRConsent(ConsentNode automaton) {
37         this.automaton = automaton;
38     }
39
40     /**
41      * @see SOFA.SOFAnode.Util.objectweb.fractal.behprotocols.checker.DFSR.IDFSRExtension#action(SOFA.SOFAnode.Util.objectweb.fractal.behprotocols.checker.state.State)
42      */

43     public void action(State state) throws InvalidParameterException {
44
45     }
46
47     /**
48      * @see SOFA.SOFAnode.Util.objectweb.fractal.behprotocols.checker.DFSR.IDFSRExtension#actionNew(SOFA.SOFAnode.Util.objectweb.fractal.behprotocols.checker.state.State)
49      */

50     public boolean actionNew(State state) throws InvalidParameterException, AcceptingStateException {
51         state.label = new String JavaDoc("S" + timestamp);
52         state.timestamp = timestamp++;
53         return automaton.isAccepting(state);
54     }
55
56     /**
57      * @see SOFA.SOFAnode.Util.objectweb.fractal.behprotocols.checker.DFSR.IDFSRExtension#actionCycle(SOFA.SOFAnode.Util.objectweb.fractal.behprotocols.checker.state.State)
58      */

59     public void actionCycle(State state) throws InvalidParameterException {
60         if (state.getSignature().getCycleId() == Long.MAX_VALUE) {
61             state.cycleStart = true;
62             state.getSignature().setCycleId(state.timestamp);
63         }
64     }
65
66     /**
67      * @see SOFA.SOFAnode.Util.objectweb.fractal.behprotocols.checker.DFSR.IDFSRExtension#actionVisited(SOFA.SOFAnode.Util.objectweb.fractal.behprotocols.checker.state.State)
68      */

69     public void actionVisited(State state) throws InvalidParameterException {
70
71     }
72
73     /**
74      * @see SOFA.SOFAnode.Util.objectweb.fractal.behprotocols.checker.DFSR.IDFSRExtension#actionBack(SOFA.SOFAnode.Util.objectweb.fractal.behprotocols.checker.state.State)
75      */

76     public void actionBack(State state) throws InvalidParameterException {
77
78     }
79     
80     /**
81      * @see SOFA.SOFAnode.Util.objectweb.fractal.behprotocols.checker.DFSR.IDFSRExtension#reset()
82      */

83     public void reset() {
84         timestamp = 0;
85     }
86
87     //------------------------------
88
/**
89      * unique cycle id generator
90      */

91     private long timestamp = 0;
92
93     /**
94      * The automaton represented by the consent node of the parse tree.
95      */

96     private ConsentNode automaton;
97 }
Popular Tags