KickJava   Java API By Example, From Geeks To Geeks.

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


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 org.aspectj.tools.ide.*;
27 import java.util.*;
28
29 public class AJCMethodHelper implements MethodHelper {
30
31     private Declaration dec;
32
33     public AJCMethodHelper(Declaration dec) {
34         this.dec = dec;
35     }
36
37     public String JavaDoc getRealName() {
38         return dec.getSignature();
39     }
40
41     public String JavaDoc getDisplayName() {
42         return getRealName();
43     }
44
45     public String JavaDoc getToolTipText() {
46         return dec.getFullSignature();
47     }
48
49     public String JavaDoc getClassName() {
50         return dec.getDeclaringType();
51     }
52
53     public String JavaDoc getRelativePath() {
54         return dec.getFilename();
55     }
56
57     public int getLine() {
58         return dec.getBeginLine();
59     }
60
61     public String JavaDoc getBreakpoint() {
62         return getPackagePrefix() + dec.getDeclaringType() + "." + breakpointSignature();
63     }
64
65     private String JavaDoc getPackagePrefix() {
66         String JavaDoc packageName = dec.getPackageName();
67         if (packageName == null ||
68             packageName.equals("")) {
69             return "";
70         }
71         return packageName + ".";
72     }
73
74     public Declaration getDec() {
75         return dec;
76     }
77
78     private String JavaDoc breakpointSignature() {
79         return dec.getSignature();
80     }
81
82     private int type = Integer.MIN_VALUE;
83     public int getType() {
84         return (type >= 0) ? type : (type = _getType());
85     }
86     public int _getType() {
87         StringTokenizer tok = new StringTokenizer(dec.getFullSignature());
88         boolean isStatic = false;
89         boolean isPublic = false;
90         boolean isPrivate = false;
91         boolean isProtected = false;
92         boolean isInit = false;
93         boolean isCtr = false;
94         if (getRealName().startsWith("new(") || getRealName().equals("<init>")) {
95             isCtr = true;
96         }
97         while (tok.hasMoreTokens()) {
98             String JavaDoc token = tok.nextToken();
99             if (token.indexOf("(") != -1) break;
100             if (token.equals("static")) isStatic = true;
101             if (token.equals("public")) isPublic = true;
102             if (token.equals("protected")) isProtected = true;
103             if (token.equals("private")) isPrivate = true;
104         }
105         return MethodNode.getType(isCtr, isStatic, isPublic, isPrivate, isProtected);
106     }
107 }
108
Popular Tags