KickJava   Java API By Example, From Geeks To Geeks.

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


1 /* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 *
3 * This file is part of the debugger 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 package org.aspectj.debugger.gui;
23
24 import com.sun.jdi.*;
25 import java.util.*;
26
27 public class NonAJCMethodHelper implements MethodHelper {
28
29     private Method method;
30
31     public NonAJCMethodHelper(Method method) {
32         this.method = method;
33     }
34
35     public String JavaDoc getRealName() {
36         return method.name();
37     }
38
39     public String JavaDoc getDisplayName() {
40         return getRealName() + args();
41     }
42
43     public String JavaDoc getToolTipText() {
44         return longName();
45     }
46
47     public String JavaDoc getClassName() {
48         return method.declaringType().name();
49     }
50
51     private String JavaDoc longName() {
52         return accessString()
53             + " " + modsString()
54             + " " + method.returnTypeName()
55             + " " + method.name() + args();
56     }
57
58     private String JavaDoc modsString() {
59         return (method.isAbstract() ? " abstract" : "")
60             + (method.isFinal() ? " final" : "")
61             + (method.isNative() ? " native" : "")
62             + (method.isSynchronized() ? " synchronized" : "");
63     }
64
65     private String JavaDoc accessString() {
66         if (method.isPublic()) return "public";
67         if (method.isProtected()) return "protected";
68         if (method.isPrivate()) return "private";
69         return "";
70     }
71
72     private String JavaDoc args() {
73         String JavaDoc str = "(";
74         List names = method.argumentTypeNames();
75         if (names != null && names.size() > 0) {
76             Iterator iter = names.iterator();
77             while (iter.hasNext()) {
78                 str += iter.next() + (iter.hasNext() ? "," : "");
79             }
80         }
81         str += ")";
82         return str;
83     }
84
85     public String JavaDoc getRelativePath() {
86         return SourceNameFactory.sourceName(method.declaringType());
87     }
88
89     public int getLine() {
90         Location loc = method.location();
91         return loc != null ? loc.lineNumber() : -1;
92     }
93
94     public String JavaDoc getBreakpoint() {
95         return method.declaringType().name() + "." + method.name() + args();
96     }
97
98     public int getType() {
99         return MethodNode.getType(method.isConstructor(),
100                                   method.isStatic(),
101                                   method.isPublic(),
102                                   method.isPrivate(),
103                                   method.isProtected());
104     }
105 }
106
Popular Tags