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