KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > de > uka > ipd > coverage > natures > all_uses > Definition


1 /*
2  * Created on Apr 28, 2005
3  *
4  * written by Matthias Kempka
5  */

6 package de.uka.ipd.coverage.natures.all_uses;
7
8 import de.uka.ipd.coverage.natures.ISourceCodeLine;
9 import de.uka.ipd.coverage.recording.RegisteredMethod;
10
11 /**
12  * Created on Apr 28, 2005
13  * @author Matthias Kempka
14  */

15 public class Definition implements ISourceCodeLine {
16
17     private int line;
18     private int bytecodePos;
19     private RegisteredMethod method;
20     private String JavaDoc variableName;
21
22     public Definition(int sourceCodeLine,
23             int bytecodePos,
24             String JavaDoc variableName,
25             RegisteredMethod method) {
26         this.line = sourceCodeLine;
27         this.bytecodePos = bytecodePos;
28         this.variableName = variableName;
29         this.method = method;
30     }
31     
32     public int getSourceCodeLine() {
33         return line;
34     }
35     
36     public RegisteredMethod getMethod() {
37         return method;
38     }
39     
40     public boolean equals(Object JavaDoc obj) {
41         if (obj instanceof Definition) {
42             Definition def = (Definition) obj;
43             if ( line == def.line
44                     && bytecodePos == def.bytecodePos
45                     && variableName.equals(def.variableName)
46                     && method == def.method ) {
47                 return true;
48             }
49         }
50         return false;
51     }
52     
53     public int hashCode() {
54         return new Integer JavaDoc(line * bytecodePos).hashCode();
55     }
56     public String JavaDoc toString() {
57         return "DEF "+variableName+" ["+line+"(Source)/"+bytecodePos+"(Bytecode)] in " + method.getMethod().getName(); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
58
}
59     
60     public String JavaDoc getVariableName() {
61         return variableName;
62     }
63 }
64
Popular Tags