KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > ca > mcgill > sable > soot > cfg > model > CFGNode


1 /* Soot - a J*va Optimization Framework
2  * Copyright (C) 2004 Jennifer Lhotak
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */

19
20 package ca.mcgill.sable.soot.cfg.model;
21
22 import java.util.*;
23 import org.eclipse.draw2d.graph.*;
24
25 public class CFGNode extends CFGElement {
26
27     
28     private ArrayList inputs = new ArrayList();
29     private ArrayList outputs = new ArrayList();
30     private CFGFlowData before;
31     private CFGFlowData after;
32     private CFGNodeData data;
33     
34     private ArrayList children = new ArrayList();
35     
36     public CFGNode() {
37         super();
38     }
39     
40     public void addInput(CFGEdge input){
41         getInputs().add(input);
42         fireStructureChange(CFGElement.INPUTS, input);
43     }
44     
45     public void addOutput(CFGEdge output){
46         getOutputs().add(output);
47         fireStructureChange(CFGElement.OUTPUTS, output);
48     }
49
50     /**
51      * @return
52      */

53     public ArrayList getInputs() {
54         return inputs;
55     }
56
57     /**
58      * @return
59      */

60     public ArrayList getOutputs() {
61         return outputs;
62     }
63
64     /**
65      * @param list
66      */

67     public void setInputs(ArrayList list) {
68         inputs = list;
69     }
70
71     /**
72      * @param list
73      */

74     public void setOutputs(ArrayList list) {
75         outputs = list;
76     }
77
78     /**
79      * @return
80      */

81     public CFGFlowData getAfter() {
82         return after;
83     }
84
85     /**
86      * @return
87      */

88     public CFGFlowData getBefore() {
89         return before;
90     }
91
92     /**
93      * @param string
94      */

95     public void setAfter(CFGFlowData data) {
96         after = data;
97         int last = getChildren().size() - 1;
98         if (getChildren().get(last) instanceof CFGFlowData){
99             getChildren().remove(last);
100         }
101         getChildren().add(after);
102         
103         firePropertyChange(AFTER_INFO, after);
104     }
105
106     /**
107      * @param string
108      */

109     public void setBefore(CFGFlowData data) {
110         before = data;
111         if (getChildren().get(0) instanceof CFGFlowData){
112             getChildren().remove(0);
113         }
114         getChildren().add(0, before);
115         
116         firePropertyChange(BEFORE_INFO, before);
117     }
118
119     /**
120      * @return
121      */

122     public CFGNodeData getData() {
123         return data;
124     }
125
126     /**
127      * @param data
128      */

129     public void setData(CFGNodeData data) {
130         this.data = data;
131         getChildren().add(data);
132         firePropertyChange(NODE_DATA, data);
133     }
134
135     /**
136      * @return
137      */

138     public ArrayList getChildren() {
139         return children;
140     }
141
142     /**
143      * @param list
144      */

145     public void setChildren(ArrayList list) {
146         children = list;
147     }
148
149     public void handleClickEvent(Object JavaDoc evt){
150         firePropertyChange(REVEAL, this);
151     }
152     
153     public void handleHighlightEvent(Object JavaDoc evt){
154         firePropertyChange(HIGHLIGHT, this);
155     }
156 }
157
Popular Tags