KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > SOFA > SOFAnode > Util > DFSRChecker > node > ExplicitNode


1 /*
2  * $Id: ExplicitNode.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.node;
19
20
21 import java.util.TreeMap JavaDoc;
22 import java.util.TreeSet JavaDoc;
23
24
25 import SOFA.SOFAnode.Util.DFSRChecker.state.State;
26 import SOFA.SOFAnode.Util.DFSRChecker.state.TransitionPair;
27 import SOFA.SOFAnode.Util.DFSRChecker.state.TransitionPairs;
28 import SOFA.SOFAnode.Util.DFSRChecker.utils.AnotatedProtocol;
29
30 /**
31  * Represents an explicit automaton for a parse subtree.
32  */

33 public class ExplicitNode extends TreeNode {
34
35     /** Creates a new instance of ExplicitNode */
36     public ExplicitNode(State initial, TreeMap JavaDoc transitions, TreeSet JavaDoc accepting, String JavaDoc protocol, TreeNode original) {
37         super(protocol);
38         this.initial = initial;
39         this.transitions = transitions;
40         this.accepting = accepting;
41
42         this.nodes = new TreeNode[0];
43         this.original = original;
44
45         this.weight = 1;
46     }
47
48     /**
49      * @see SOFA.SOFAnode.Util.objectweb.fractal.behprotocols.checker.node.TreeNode#getInitial()
50      */

51     public State getInitial() {
52         return initial;
53     }
54
55     /**
56      *
57      * @see SOFA.SOFAnode.Util.objectweb.fractal.behprotocols.checker.node.TreeNode#getTransitions(SOFA.SOFAnode.Util.objectweb.fractal.behprotocols.checker.state.State)
58      */

59     public TransitionPairs getTransitions(State state) throws InvalidParameterException {
60         TransitionPair[] result = (TransitionPair[]) transitions.get(state);
61         if (result != null)
62             return new TransitionPairs(result);
63         else
64             return new TransitionPairs(new TransitionPair[0]);
65
66     }
67
68     /**
69      *
70      * @see SOFA.SOFAnode.Util.objectweb.fractal.behprotocols.checker.node.TreeNode#isAccepting(SOFA.SOFAnode.Util.objectweb.fractal.behprotocols.checker.state.State)
71      */

72     public boolean isAccepting(SOFA.SOFAnode.Util.DFSRChecker.state.State state) {
73         return accepting.contains(state);
74     }
75
76     /**
77      *
78      * @see SOFA.SOFAnode.Util.objectweb.fractal.behprotocols.checker.node.TreeNode#getWeight()
79      */

80     public long getWeight() {
81         return 1;
82     }
83
84     /**
85      *
86      * @see SOFA.SOFAnode.Util.objectweb.fractal.behprotocols.checker.node.TreeNode#forwardCut(java.util.TreeSet)
87      */

88     public TreeNode forwardCut(TreeSet JavaDoc livingevents) {
89         // no cutting is performed here...
90
return this;
91     }
92
93     /**
94      *
95      * @see SOFA.SOFAnode.Util.objectweb.fractal.behprotocols.checker.node.TreeNode#copy()
96      */

97     public TreeNode copy() {
98         // no cutting is performed here...
99
return this;
100     }
101
102     /**
103      * @return the symbolic name of the treenode denoting its type
104      */

105     public String JavaDoc[] getTypeName() {
106         String JavaDoc[] result = { "Explicit", "EXPLICIT" };
107         return result;
108     }
109
110     /**
111      * @see SOFA.SOFAnode.Util.objectweb.fractal.behprotocols.checker.node.TreeNode#getAnotatedProtocol(SOFA.SOFAnode.Util.objectweb.fractal.behprotocols.checker.state.State)
112      */

113     public AnotatedProtocol getAnotatedProtocol(State state) {
114         return original.getAnotatedProtocol(state);
115     }
116     //--------------------------------------------------------------------------
117
/**
118      * The initial state.
119      */

120     final private State initial;
121     
122     /**
123      * The original parse subtree .
124      */

125     private TreeNode original;
126
127     /**
128      * The transition matrix.
129      */

130
131     final private TreeMap JavaDoc transitions;
132
133     /**
134      * The set of accepting states.
135      */

136     final private TreeSet JavaDoc accepting;
137
138
139 }
Popular Tags