164 * <li> 165 * {@code "MyClass.mash(Native Method)"} - As above, but neither 166 * the file name nor the line number are available, and the method 167 * containing the execution point is known to be a native method. 168 * </ul> 169 * @see Throwable#printStackTrace() 170 */ 171 public String toString() { 172 return getClassName() + "." + methodName + 173 (isNativeMethod() ? "(Native Method)" : 174 (fileName != null && lineNumber >= 0 ? 175 "(" + fileName + ":" + lineNumber + ")" : 176 (fileName != null ? "("+fileName+")" : "(Unknown Source)"))); 177 } 178 179 /** 180 * Returns true if the specified object is another 181 * {@code StackTraceElement} instance representing the same execution 182 * point as this instance. Two stack trace elements {@code a} and 183 * {@code b} are equal if and only if: 184 * <pre> 185 * equals(a.getFileName(), b.getFileName()) && 186 * a.getLineNumber() == b.getLineNumber()) && 187 * equals(a.getClassName(), b.getClassName()) && 188 * equals(a.getMethodName(), b.getMethodName()) 189 * </pre> 190 * where {@code equals} has the semantics of {@link 191 * java.util.Objects#equals(Object, Object) Objects.equals}. 192 * 193 * @param obj the object to be compared with this stack trace element. 194 * @return true if the specified object is another 195 * {@code StackTraceElement} instance representing the same 196 * execution point as this instance. 197 */ 198 public boolean equals(Object obj) { 199 if (obj==this) 200 return true; 201 if (!(obj instanceof StackTraceElement)) 202 return false; 203 StackTraceElement e = (StackTraceElement)obj; 204 return e.declaringClass.equals(declaringClass) && 205 e.lineNumber == lineNumber && 206 Objects.equals(methodName, e.methodName) && 207 Objects.equals(fileName, e.fileName); 208 } 209 | 164 * <li> 165 * {@code "MyClass.mash(Native Method)"} - As above, but neither 166 * the file name nor the line number are available, and the method 167 * containing the execution point is known to be a native method. 168 * </ul> 169 * @see Throwable#printStackTrace() 170 */ 171 public String toString() { 172 return getClassName() + "." + methodName + 173 (isNativeMethod() ? "(Native Method)" : 174 (fileName != null && lineNumber >= 0 ? 175 "(" + fileName + ":" + lineNumber + ")" : 176 (fileName != null ? "("+fileName+")" : "(Unknown Source)"))); 177 } 178 179 /** 180 * Returns true if the specified object is another 181 * {@code StackTraceElement} instance representing the same execution 182 * point as this instance. Two stack trace elements {@code a} and 183 * {@code b} are equal if and only if: 184 * <pre>{@code 185 * equals(a.getFileName(), b.getFileName()) && 186 * a.getLineNumber() == b.getLineNumber()) && 187 * equals(a.getClassName(), b.getClassName()) && 188 * equals(a.getMethodName(), b.getMethodName()) 189 * }</pre> 190 * where {@code equals} has the semantics of {@link 191 * java.util.Objects#equals(Object, Object) Objects.equals}. 192 * 193 * @param obj the object to be compared with this stack trace element. 194 * @return true if the specified object is another 195 * {@code StackTraceElement} instance representing the same 196 * execution point as this instance. 197 */ 198 public boolean equals(Object obj) { 199 if (obj==this) 200 return true; 201 if (!(obj instanceof StackTraceElement)) 202 return false; 203 StackTraceElement e = (StackTraceElement)obj; 204 return e.declaringClass.equals(declaringClass) && 205 e.lineNumber == lineNumber && 206 Objects.equals(methodName, e.methodName) && 207 Objects.equals(fileName, e.fileName); 208 } 209 |