KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hammurapi > inspectors > metrics > callertrace > MethodWrapperImpl


1 /*
2  * Hammurapi
3  * Automated Java code review system.
4  * Copyright (C) 2004 Johannes Bellert
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  *
20  * URL: http://www.pavelvlasov.com/pv/content/menu.show?id=products.jtaste
21  * e-Mail: Johannes.Bellert@ercgroup.com
22  *
23  * * Created on Apr 18, 2004
24  *
25  */

26 package org.hammurapi.inspectors.metrics.callertrace;
27 import com.pavelvlasov.jsel.JselException;
28 import com.pavelvlasov.jsel.OperationInfo;
29 import com.pavelvlasov.review.SourceMarker;
30
31 /**
32  * @author Johannes Bellert
33  *
34  * To change the template for this generated type comment go to
35  * Window - Preferences - Java - Code Generation - Code and Comments
36  */

37 public class MethodWrapperImpl {
38     private String JavaDoc declaringType = "";
39     // private SourceMarker srcMarker = null;
40
private String JavaDoc sourceURL = "";
41     private String JavaDoc srcLine = "1";
42     private String JavaDoc name = "";
43     private String JavaDoc signature = "";
44     private int line = 0;
45     private MethodWrapperDeclaration callerMethod = null;
46     private boolean isTraced = false;
47     public MethodWrapperImpl(OperationInfo _method, SourceMarker srcMrk) {
48         super();
49         // aMethod = _method;
50
// name = _method.getName();
51
signature = _method.getSignature();
52         try {
53             declaringType = _method.getDeclaringType().getName().toString();
54         } catch (JselException e) {
55             // TODO Auto-generated catch block
56
e.printStackTrace();
57         }
58         sourceURL = srcMrk.getSourceURL();
59         srcLine = String.valueOf(srcMrk.getLine());
60         line = srcMrk.getLine();
61         // srcMarker = srcMrk;
62
}
63     
64     // only for Test Case usage !!
65
public MethodWrapperImpl(String JavaDoc _name, String JavaDoc _declType) {
66         super();
67         signature = _name;
68         declaringType = _declType;
69     }
70     //-- for initial search and test cases
71
public MethodWrapperImpl(String JavaDoc _name) {
72         super();
73         // aMethod = _method;
74
name = _name;
75         signature = _name;
76         declaringType = "";
77     }
78     public boolean equals(Object JavaDoc obj) {
79         return this.getMethodKey().equals(((MethodWrapper) obj).getMethodKey());
80     }
81     public boolean isTraced() {
82         return isTraced;
83     }
84     public void setTracedTrue() {
85         isTraced = true;
86     }
87     public String JavaDoc getDeclaringType() {
88         return declaringType;
89     }
90     /**
91      * @return Returns the name.
92      */

93     public String JavaDoc getName() {
94         return name;
95     }
96     /**
97      * @param name The name to set.
98      */

99     public void setName(String JavaDoc name) {
100         this.name = name;
101     }
102     /**
103      * @return Returns the line.
104      */

105     public int getLine() {
106         return line;
107     }
108     public void setLine(int i) {
109         line = i;
110         return;
111     }
112     public String JavaDoc getSrcURL() {
113         return sourceURL;
114     }
115     public String JavaDoc getSrcLine() {
116         return srcLine;
117     }
118     /**
119      * @return Returns the signature.
120      */

121     public String JavaDoc getSignature() {
122         return signature;
123     }
124     /**
125      * @return Returns the sourceURL.
126      */

127     public String JavaDoc getSourceURL() {
128         return sourceURL;
129     }
130     public String JavaDoc getMethodKey() {
131         // return declaringType + ">>"+signature;
132
StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
133         sb.append("(");
134         sb.append(String.valueOf(this.hashCode()));
135         sb.append(")");
136         sb.append(declaringType);
137         sb.append(">>");
138         sb.append(signature);
139         return sb.toString();
140     }
141     
142     public String JavaDoc printMethodName() {
143         // return declaringType + ">>"+signature;
144
StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
145         
146         sb.append(declaringType);
147         sb.append(">>");
148         sb.append(signature);
149         return sb.toString();
150     }
151     
152     public String JavaDoc toSearchKey() {
153         // return name;
154
// return declaringType + ">>"+signature;
155
StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
156         sb.append("(");
157         sb.append(String.valueOf(this.hashCode()));
158         sb.append(")");
159         sb.append(declaringType);
160         sb.append(">>");
161         sb.append(signature);
162         return sb.toString();
163     }
164     public String JavaDoc toString() {
165         // return this.getMethodKey();
166
StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
167         sb.append(declaringType);
168         sb.append(">>");
169         sb.append(signature);
170         return sb.toString();
171     }
172 }
173
Popular Tags