1 package com.protomatter.util; 2 3 52 53 56 public class StackTraceInfo 57 { 58 61 public static int LINE_NUMBER_UNKNOWN = -1; 62 63 66 public String className = null; 67 68 71 public String methodName = null; 72 73 76 public int lineNumber = LINE_NUMBER_UNKNOWN; 77 78 81 public StackTraceInfo() 82 { 83 this(null, null, LINE_NUMBER_UNKNOWN); 84 } 85 86 89 public StackTraceInfo(String className, String methodName) 90 { 91 this(className, methodName, LINE_NUMBER_UNKNOWN); 92 } 93 94 97 public StackTraceInfo(String className, String methodName, int line) 98 { 99 this.className = className; 100 this.methodName = methodName; 101 this.lineNumber = line; 102 } 103 104 119 public String toString() 120 { 121 StringBuffer b = new StringBuffer (128); 122 if (className != null) 123 { 124 b.append(className); 125 if (methodName != null) 126 { 127 b.append("."); 128 b.append(methodName); 129 b.append("()"); 130 if (lineNumber != LINE_NUMBER_UNKNOWN) 131 { 132 b.append(":"); 133 b.append(lineNumber); 134 } 135 } 136 } 137 else 138 { 139 b.append(UtilResources.getResourceString(MessageConstants.STACK_TRACE_INFO_UNKNOWN)); 140 } 141 return b.toString(); 142 } 143 144 public String getClassAndMethod() 145 { 146 return className + "." + methodName + "()"; 147 } 148 149 public String getShortClassAndMethod() 150 { 151 return trimFromLastPeriod(className) + "." + methodName + "()"; 152 } 153 154 private String trimFromLastPeriod(String s) 155 { 156 int index = s.lastIndexOf("."); 157 if (index != -1) 158 return s.substring(index +1); 159 return s; 160 } 161 } 162
| Popular Tags
|