/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2003 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* ident "%Z%%M% %I% %E% SMI" */
/**
* Formats a stack trace in a single line. The format is meant to
* convey the stack trace as a sequence of class names and line numbers,
* with the topmost frame first, suitable for logging. Beware, the
* format may evolve.
*/
public class SuccinctStackTraceFormatter {
/**
* Formats a Throwable and adds an optional description string.
* The string should be suitable to precede the top stack
* element, and include any punctuation that should
* differentiate it from the element.
*/
{
StringBuffer s = new StringBuffer();
s.append("(");
if (description != null)
s.append(description);
s.append(", ");
trace[i], s);
s.append(", ");
}
s.append(")");
s.append(" caused by ");
}
return (s.toString());
}
/**
* Formats a Throwable's stack trace. The format is meant to be
* a single line of output, conveying the stack trace as a
* sequence of class names and line numbers, with the topmost
* frame first, suitable for logging. If two adjacent stack
* trace elements share some portion of a class name, the
* bottommost element may have the common part replaced with an
* ampersand.
*/
{
return (formatWithDescription(t, null));
}
/**
* Formats a stack trace element as per <code>format()</code>.
*/
{
/*
* This could grab more of a common class name. (See
* SuccinctStackTraceFormatter.format())
*/
e.getClassName())) {
s.append(e.getClassName());
s.append(".");
} else
s.append("&.");
s.append(e.getMethodName());
if (e.getLineNumber() > 0) {
s.append(":");
s.append(e.getLineNumber());
}
if (e.isNativeMethod()) {
s.append(":");
s.append("native");
}
}
{
}
{
}
{
}
}
return new Throwable();
}
}