KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > samples > callgraph > ClassVertex


1 package samples.callgraph;
2
3 import java.util.HashMap JavaDoc;
4 import java.util.Map JavaDoc;
5 //import java.util.Stack;
6

7 import salvo.jesus.graph.DirectedEdgeImpl;
8 import salvo.jesus.graph.EdgeImpl;
9 import salvo.jesus.graph.VertexImpl;
10
11 public class ClassVertex extends VertexImpl {
12     private String JavaDoc name;
13 // private Stack activeMethods;
14
// private Stack finishedMethods;
15
private Map JavaDoc children;
16     private Map JavaDoc childEdges;
17
18     public ClassVertex(String JavaDoc className) {
19         super(className);
20         this.name = className;
21         children = new HashMap JavaDoc();
22         childEdges = new HashMap JavaDoc();
23 // activeMethods = new Stack();
24
// finishedMethods = new Stack();
25
}
26
27     public String JavaDoc getName() {
28         return name;
29     }
30
31     public void setName(String JavaDoc name) {
32         this.name = name;
33     }
34
35 // public EdgeImpl addMethodCall(ClassVertex sinkClass, String methodName) {
36
// MethodEdge methodCall = new MethodEdge(this, sinkClass, methodName);
37
// activeMethods.push(methodCall);
38

39 // return methodCall;
40
// }
41

42 // public void finishMethodCall() {
43
// MethodEdge methodCall = (MethodEdge) activeMethods.pop();
44
// if (methodCall != null) {
45
// finishedMethods.push(methodCall);
46
// }
47
// }
48

49     public boolean hasChild(String JavaDoc className) {
50         return children.containsKey(className);
51     }
52     
53     public ClassVertex getChild(String JavaDoc className) {
54         return (ClassVertex) children.get(className);
55     }
56
57     public void addChild(ClassVertex vertex, MethodEdge edge) {
58         children.put(vertex.getName(), vertex);
59         childEdges.put(vertex.getName(), edge);
60     }
61
62     public MethodEdge getEdge(String JavaDoc className) {
63         return (MethodEdge) childEdges.get(className);
64     }
65 }
66
Popular Tags