Java Stacktrace stackTraceElementToString( StackTraceElement element)

Here you can find the source of stackTraceElementToString( StackTraceElement element)

Description

stack Trace Element To String

License

Open Source License

Declaration

private static String stackTraceElementToString(
            StackTraceElement element) 

Method Source Code

//package com.java2s;
/*/*from ww w  .ja  va2  s  . com*/
 * Smart GWT (GWT for SmartClient)
 * Copyright 2014 and beyond, Isomorphic Software, Inc.
 *
 * Smart GWT is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License version 3
 * is published by the Free Software Foundation.  Smart GWT is also
 * available under typical commercial license terms - see
 * http://smartclient.com/license
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 */

public class Main {
    private static final String UNKNOWN = "Unknown";

    private static String stackTraceElementToString(
            StackTraceElement element) {
        String methodName = element.getMethodName();
        if (methodName == null || UNKNOWN.equals(methodName))
            return null;

        String frame = "    at ";

        String className = element.getClassName();
        if (className != null && !UNKNOWN.equals(className))
            frame += className + ".";

        frame += methodName + "(";

        String fileName = element.getFileName();
        if (fileName != null && !UNKNOWN.equals(fileName)) {
            frame += fileName;

            int lineNumber = element.getLineNumber();
            if (lineNumber >= 0)
                frame += ":" + lineNumber;
        }
        frame += ")";

        return frame;
    }
}

Related

  1. stackTrace(StackTraceElement[] stackTrace)
  2. stackTrace2String(Throwable e)
  3. stackTraceApproved(StackTraceElement elt, String[] approved)
  4. stackTraceAsString(Throwable t)
  5. stackTraceContainsCause(Throwable throwable, Class searchedCause)
  6. stackTraceElementWithLinenumber( StackTraceElement stackTraceElement)
  7. stackTraceElementWithLinenumberAsString(StackTraceElement stackTraceElement)
  8. stackTraceEquals(StackTraceElement[] ta1, StackTraceElement[] ta2)
  9. stackTraceGenerate()