Clover coverage report - picocontainer - 1.2-beta-1
Coverage timestamp: Sun May 29 2005 14:29:04 BST
file stats: LOC: 110   Methods: 8
NCLOC: 38   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
PicoException.java 100% 92.9% 87.5% 92.3%
coverage coverage
 1    /*****************************************************************************
 2    * Copyright (C) PicoContainer Organization. All rights reserved. *
 3    * ------------------------------------------------------------------------- *
 4    * The software in this package is published under the terms of the BSD *
 5    * style license a copy of which has been included with this distribution in *
 6    * the LICENSE.txt file. *
 7    * *
 8    * Original code by *
 9    *****************************************************************************/
 10    package org.picocontainer;
 11   
 12    import java.io.PrintStream;
 13    import java.io.PrintWriter;
 14   
 15    /**
 16    * Superclass for all Exceptions in PicoContainer. You can use this if you want to catch all exceptions thrown by
 17    * PicoContainer. Be aware that some parts of the PicoContainer API will also throw {@link NullPointerException} when
 18    * <code>null</code> values are provided for method arguments, and this is not allowed.
 19    *
 20    * @author Paul Hammant
 21    * @author Aslak Helles&oslash;y
 22    * @version $Revision: 1812 $
 23    * @since 1.0
 24    */
 25    public abstract class PicoException extends RuntimeException {
 26    /**
 27    * The exception that caused this one.
 28    */
 29    private Throwable cause;
 30   
 31    /**
 32    * Construct a new exception with no cause and no detail message. Note modern JVMs may still track the exception
 33    * that caused this one.
 34    */
 35  14 protected PicoException() {
 36    }
 37   
 38    /**
 39    * Construct a new exception with no cause and the specified detail message. Note modern JVMs may still track the
 40    * exception that caused this one.
 41    *
 42    * @param message the message detailing the exception.
 43    */
 44  194 protected PicoException(final String message) {
 45  194 super(message);
 46    }
 47   
 48    /**
 49    * Construct a new exception with the specified cause and no detail message.
 50    *
 51    * @param cause the exception that caused this one.
 52    */
 53  28 protected PicoException(final Throwable cause) {
 54  28 this.cause = cause;
 55    }
 56   
 57    /**
 58    * Construct a new exception with the specified cause and the specified detail message.
 59    *
 60    * @param message the message detailing the exception.
 61    * @param cause the exception that caused this one.
 62    */
 63  28 protected PicoException(final String message, final Throwable cause) {
 64  28 super(message);
 65  28 this.cause = cause;
 66    }
 67   
 68    /**
 69    * Retrieve the exception that caused this one.
 70    *
 71    * @return the exception that caused this one, or null if it was not set.
 72    * @see Throwable#getCause() the method available since JDK 1.4 that is overridden by this method.
 73    */
 74  36 public Throwable getCause() {
 75  36 return cause;
 76    }
 77   
 78    /**
 79    * Overridden to provide 1.4 style stack traces on pre-1.4.
 80    *
 81    * @param s the {@link PrintStream} used to print the stack trace
 82    */
 83  0 public void printStackTrace() {
 84  0 printStackTrace(System.err);
 85    }
 86   
 87    /**
 88    * Overridden to provide 1.4 style stack traces on pre-1.4.
 89    */
 90  4 public void printStackTrace(PrintStream s) {
 91  4 super.printStackTrace(s);
 92  4 if(cause!=null) {
 93  2 s.println("Caused by:\n");
 94  2 cause.printStackTrace(s);
 95    }
 96    }
 97   
 98    /**
 99    * Overridden to provide 1.4 style stack traces on pre-1.4.
 100    *
 101    * @param s the {@link PrintWriter} used to print the stack trace
 102    */
 103  4 public void printStackTrace(PrintWriter s) {
 104  4 super.printStackTrace(s);
 105  4 if(cause!=null) {
 106  2 s.println("Caused by:\n");
 107  2 cause.printStackTrace(s);
 108    }
 109    }
 110    }