KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > aspectj > debugger > gui > ClassNode


1 /* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2  *
3  * This file is part of the compiler and core tools for the AspectJ(tm)
4  * programming language; see http://aspectj.org
5  *
6  * The contents of this file are subject to the Mozilla Public License
7  * Version 1.1 (the "License"); you may not use this file except in
8  * compliance with the License. You may obtain a copy of the License at
9  * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
10  *
11  * Software distributed under the License is distributed on an "AS IS" basis,
12  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13  * for the specific language governing rights and limitations under the
14  * License.
15  *
16  * The Original Code is AspectJ.
17  *
18  * The Initial Developer of the Original Code is Xerox Corporation. Portions
19  * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation.
20  * All Rights Reserved.
21  *
22  * Contributor(s):
23  */

24 package org.aspectj.debugger.gui;
25
26 import com.sun.jdi.*;
27 import java.util.List JavaDoc;
28 import java.util.*;
29 import javax.swing.tree.*;
30
31 public abstract class ClassNode extends AJClassNode implements Sourceable {
32     public ClassNode(ReferenceType refType) {
33         super(refType);
34         setUserObject(refType);
35     }
36
37     protected ReferenceType refType() {
38         return (ReferenceType) getUserObject();
39     }
40
41     protected void addMethod(Method method) {
42         if (method.declaringType().equals(refType())) {
43             MethodNode methodNode = new NonAdvisableMethodNode(method);
44             add(methodNode);
45         } else {
46             addToSuper(method);
47         }
48     }
49
50     protected void addToSuper(Method method) {
51         TreeNode treeNode = getChildAt(0);
52         if (!(treeNode instanceof ClassNode)) return;
53         ClassNode classNode = (ClassNode) treeNode;
54         classNode.addMethod(method);
55     }
56
57     protected abstract String JavaDoc name();
58     protected abstract String JavaDoc packageName();
59     public String JavaDoc fullName() {
60         String JavaDoc pname = packageName();
61         String JavaDoc name = name();
62         if (pname == null || pname.equals("")) {
63             return name;
64         }
65         return pname + "." + name;
66     }
67
68     public String JavaDoc toString() {
69         String JavaDoc name = name();
70         //!!! Come back and fix this
71
if (getParent() instanceof ClassTreePane.PackageNode) {
72             int idot = name.lastIndexOf('.');
73             return idot != -1 ? name.substring(idot+1) : name;
74         }
75         return name;
76     }
77
78     public String JavaDoc getToolTipText() {
79
80         return
81             kind() + " "
82             + name();
83     }
84
85     protected abstract String JavaDoc kind();
86
87     protected AJClassNode newClassNode(ReferenceType refType) {
88         return ClassNodeFactory.classNode(refType);
89     }
90
91     public void showOnSource(AbstractSourcePane sourcePane) {
92         sourcePane.showSourceForFileAndLine(getRelativePath(), getLine());
93     }
94     protected abstract String JavaDoc getRelativePath();
95     protected abstract int getLine();
96
97     public List JavaDoc getMethodStrings() {
98         List JavaDoc methodStrings = new Vector();
99         if (children == null) return methodStrings;
100         Iterator iter = children.iterator();
101         while (iter.hasNext()) {
102             methodStrings.add(((MethodNode) iter.next()).getBreakpoint());
103         }
104         return methodStrings;
105     }
106 }
107
Popular Tags