KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hansel > ProbeData


1 package org.hansel;
2
3 import org.hansel.stack.HanselValue;
4
5 public class ProbeData {
6     private String JavaDoc classname;
7     private String JavaDoc methodname;
8     private int lineNumber;
9     private int pos;
10     private int size;
11     private HanselFrame frame;
12     private ClassLoader JavaDoc loader;
13
14     public ProbeData(String JavaDoc classname,
15                      String JavaDoc methodname,
16                      HanselFrame frame,
17                      int pos,
18                      int size,
19                      ClassLoader JavaDoc loader) {
20         this.classname = classname;
21         this.methodname = methodname;
22         this.pos = pos;
23         this.size = size;
24         this.frame = frame;
25         this.loader = loader;
26     }
27
28     public void setLineNumber(int lineNumber) {
29     this.lineNumber = lineNumber;
30     }
31
32     public String JavaDoc getClassName() {
33         return classname.replace('/', '.');
34     }
35
36     public String JavaDoc getShortClassName() {
37         String JavaDoc result = classname;
38
39         if (result.indexOf("/") > -1) {
40             result = result.substring(result.lastIndexOf("/") + 1);
41         }
42
43         if (result.indexOf("$") > -1) {
44             result = result.substring(0, result.lastIndexOf("$"));
45         }
46
47         return result;
48     }
49
50     public String JavaDoc getMethodName() {
51         return methodname;
52     }
53
54     public int getLineNumber() {
55         return lineNumber;
56     }
57
58     public int getStackSize() {
59         if (frame != null) {
60             return frame.getStackSize();
61         }
62
63         return -1;
64     }
65
66     public HanselValue getStackEntry(int depth) {
67         if (frame != null) {
68           return (HanselValue) frame.getStack(depth);
69         } else {
70             return new HanselValue("<unknown>", false, 1);
71         }
72     }
73
74     public int getPosition() {
75     return pos;
76     }
77
78     public boolean equals(Object JavaDoc o) {
79         if (o.getClass() != getClass()) {
80             return false;
81         }
82
83         ProbeData pd = (ProbeData) o;
84
85         return classname.equals(pd.classname)
86         && methodname.equals(pd.methodname)
87         && (pos == pd.pos)
88         && (size == pd.size);
89     }
90
91     public int hashCode() {
92         return classname.hashCode()
93         ^ methodname.hashCode()
94         ^ (pos << 16)
95         ^ (size);
96     }
97
98     public Class JavaDoc getTargetClass() throws ClassNotFoundException JavaDoc {
99         return loader.loadClass(getClassName());
100     }
101 }
102
Popular Tags