001: /*
002: * Hammurapi
003: * Automated Java code review system.
004: * Copyright (C) 2004 Johannes Bellert
005: *
006: * This program is free software; you can redistribute it and/or modify
007: * it under the terms of the GNU General Public License as published by
008: * the Free Software Foundation; either version 2 of the License, or
009: * (at your option) any later version.
010: *
011: * This program is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
014: * GNU General Public License for more details.
015: *
016: * You should have received a copy of the GNU General Public License
017: * along with this program; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
019: *
020: * URL: http://www.pavelvlasov.com/pv/content/menu.show?id=products.jtaste
021: * e-Mail: Johannes.Bellert@ercgroup.com
022: *
023: * * Created on Apr 18, 2004
024: *
025: */
026: package org.hammurapi.inspectors.metrics.callertrace;
027:
028: import com.pavelvlasov.jsel.JselException;
029: import com.pavelvlasov.jsel.OperationInfo;
030: import com.pavelvlasov.review.SourceMarker;
031:
032: /**
033: * @author Johannes Bellert
034: *
035: * To change the template for this generated type comment go to
036: * Window - Preferences - Java - Code Generation - Code and Comments
037: */
038: public class MethodWrapperImpl {
039: private String declaringType = "";
040: // private SourceMarker srcMarker = null;
041: private String sourceURL = "";
042: private String srcLine = "1";
043: private String name = "";
044: private String signature = "";
045: private int line = 0;
046: private MethodWrapperDeclaration callerMethod = null;
047: private boolean isTraced = false;
048:
049: public MethodWrapperImpl(OperationInfo _method, SourceMarker srcMrk) {
050: super ();
051: // aMethod = _method;
052: // name = _method.getName();
053: signature = _method.getSignature();
054: try {
055: declaringType = _method.getDeclaringType().getName()
056: .toString();
057: } catch (JselException e) {
058: // TODO Auto-generated catch block
059: e.printStackTrace();
060: }
061: sourceURL = srcMrk.getSourceURL();
062: srcLine = String.valueOf(srcMrk.getLine());
063: line = srcMrk.getLine();
064: // srcMarker = srcMrk;
065: }
066:
067: // only for Test Case usage !!
068: public MethodWrapperImpl(String _name, String _declType) {
069: super ();
070: signature = _name;
071: declaringType = _declType;
072: }
073:
074: //-- for initial search and test cases
075: public MethodWrapperImpl(String _name) {
076: super ();
077: // aMethod = _method;
078: name = _name;
079: signature = _name;
080: declaringType = "";
081: }
082:
083: public boolean equals(Object obj) {
084: return this .getMethodKey().equals(
085: ((MethodWrapper) obj).getMethodKey());
086: }
087:
088: public boolean isTraced() {
089: return isTraced;
090: }
091:
092: public void setTracedTrue() {
093: isTraced = true;
094: }
095:
096: public String getDeclaringType() {
097: return declaringType;
098: }
099:
100: /**
101: * @return Returns the name.
102: */
103: public String getName() {
104: return name;
105: }
106:
107: /**
108: * @param name The name to set.
109: */
110: public void setName(String name) {
111: this .name = name;
112: }
113:
114: /**
115: * @return Returns the line.
116: */
117: public int getLine() {
118: return line;
119: }
120:
121: public void setLine(int i) {
122: line = i;
123: return;
124: }
125:
126: public String getSrcURL() {
127: return sourceURL;
128: }
129:
130: public String getSrcLine() {
131: return srcLine;
132: }
133:
134: /**
135: * @return Returns the signature.
136: */
137: public String getSignature() {
138: return signature;
139: }
140:
141: /**
142: * @return Returns the sourceURL.
143: */
144: public String getSourceURL() {
145: return sourceURL;
146: }
147:
148: public String getMethodKey() {
149: // return declaringType + ">>"+signature;
150: StringBuffer sb = new StringBuffer();
151: sb.append("(");
152: sb.append(String.valueOf(this .hashCode()));
153: sb.append(")");
154: sb.append(declaringType);
155: sb.append(">>");
156: sb.append(signature);
157: return sb.toString();
158: }
159:
160: public String printMethodName() {
161: // return declaringType + ">>"+signature;
162: StringBuffer sb = new StringBuffer();
163:
164: sb.append(declaringType);
165: sb.append(">>");
166: sb.append(signature);
167: return sb.toString();
168: }
169:
170: public String toSearchKey() {
171: // return name;
172: // return declaringType + ">>"+signature;
173: StringBuffer sb = new StringBuffer();
174: sb.append("(");
175: sb.append(String.valueOf(this .hashCode()));
176: sb.append(")");
177: sb.append(declaringType);
178: sb.append(">>");
179: sb.append(signature);
180: return sb.toString();
181: }
182:
183: public String toString() {
184: // return this.getMethodKey();
185: StringBuffer sb = new StringBuffer();
186: sb.append(declaringType);
187: sb.append(">>");
188: sb.append(signature);
189: return sb.toString();
190: }
191: }
|