EMMA Coverage Report (generated Sat Jul 01 16:38:45 PDT 2006)
[all classes][jade.jademx.util]

COVERAGE SUMMARY FOR SOURCE FILE [ThrowableUtil.java]

nameclass, %method, %block, %line, %
ThrowableUtil.java100% (1/1)67%  (2/3)92%  (34/37)80%  (8/10)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ThrowableUtil100% (1/1)67%  (2/3)92%  (34/37)80%  (8/10)
ThrowableUtil (): void 0%   (0/1)0%   (0/3)0%   (0/2)
errMsg (String, Throwable): String 100% (1/1)100% (12/12)100% (1/1)
stackTrace (Throwable): String 100% (1/1)100% (22/22)100% (7/7)

1// jademx - JADE management using JMX
2// Copyright 2005 Caboodle Networks, Inc.
3//
4// This library is free software; you can redistribute it and/or
5// modify it under the terms of the GNU Lesser General Public
6// License as published by the Free Software Foundation; either
7// version 2.1 of the License, or (at your option) any later version.
8//
9// This library is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12// Lesser General Public License for more details.
13//
14// You should have received a copy of the GNU Lesser General Public
15// License along with this library; if not, write to the Free Software
16// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
17 
18package jade.jademx.util;
19 
20//import jade.util.Logger;
21 
22import java.io.PrintWriter;
23import java.io.StringWriter;
24 
25/** 
26 * Throwable utility class.
27 * @author David Bernstein, <a href="http://www.caboodlenetworks.com"
28 *  >Caboodle Networks, Inc.</a>
29 */
30public class ThrowableUtil {
31 
32    /**
33     * private to prevent instantiation
34     */
35    private ThrowableUtil() {
36    }
37 
38    /**
39     * convenience method to put stack trace in a string
40     * @param t throwable to get stack trace for
41     * @return throwable's stack trace as a string
42     */
43    public static String stackTrace( Throwable t ) {
44        String s = null;
45        if ( null != t ) {
46            StringWriter sw = new StringWriter();
47            PrintWriter pw = new PrintWriter( sw );
48            t.printStackTrace( pw );
49            s = sw.toString();
50        }
51        return s;
52    }
53 
54    /**
55     * return message with throwable stack trace appended to i
56     * @param message message to return
57     * @param t throwable whose stack trace to include
58     * @return message with throwable stack trace appended to i
59     */
60    public static String errMsg( String message, Throwable t ) {
61        return message + "\n" + stackTrace( t );
62    }
63 
64}

[all classes][jade.jademx.util]
EMMA 2.0.5312 (C) Vladimir Roubtsov