Clover coverage report - Clover results for XOM 1.2d1
Coverage timestamp: Wed Feb 8 2006 08:31:33 EST
file stats: LOC: 122   Methods: 4
NCLOC: 28   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
XSLException.java 100% 100% 100% 100%
coverage
 1    /* Copyright 2002-2005 Elliotte Rusty Harold
 2   
 3    This library is free software; you can redistribute it and/or modify
 4    it under the terms of version 2.1 of the GNU Lesser General Public
 5    License as published by the Free Software Foundation.
 6   
 7    This library is distributed in the hope that it will be useful,
 8    but WITHOUT ANY WARRANTY; without even the implied warranty of
 9    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 10    GNU Lesser General Public License for more details.
 11   
 12    You should have received a copy of the GNU Lesser General Public
 13    License along with this library; if not, write to the
 14    Free Software Foundation, Inc., 59 Temple Place, Suite 330,
 15    Boston, MA 02111-1307 USA
 16   
 17    You can contact Elliotte Rusty Harold by sending e-mail to
 18    elharo@metalab.unc.edu. Please include the word "XOM" in the
 19    subject line. The XOM home page is located at http://www.xom.nu/
 20    */
 21   
 22    package nu.xom.xslt;
 23   
 24    /**
 25    * <p>
 26    * Thrown when an XSL stylesheet fails to compile
 27    * or an XSL transform fails.
 28    * </p>
 29    *
 30    * @author Elliotte Rusty Harold
 31    * @version 1.1b3
 32    */
 33    public class XSLException extends Exception {
 34   
 35    private static final long serialVersionUID = -8605437693812807627L;
 36   
 37    private Throwable cause;
 38   
 39   
 40    /**
 41    * <p>
 42    * Creates a new <code>XSLException</code> with the specified
 43    * detail message and an underlying root cause.
 44    * </p>
 45    *
 46    * @param message information about the cause of the exception
 47    * @param cause the nested exception that caused this exception
 48    */
 49  132 public XSLException(String message, Throwable cause) {
 50  132 super(message);
 51  132 this.initCause(cause);
 52    }
 53   
 54   
 55    /**
 56    * <p>
 57    * Creates a new <code>XSLException</code>
 58    * with the specified detail message.
 59    * </p>
 60    *
 61    * @param message information about the cause of the exception
 62    */
 63  6 public XSLException(String message) {
 64  6 super(message);
 65    }
 66   
 67   
 68    // null is insufficient for detecting an uninitialized cause.
 69    // The cause may be set to null which may not then be reset.
 70    private boolean causeSet = false;
 71   
 72    /**
 73    * <p>
 74    * Sets the root cause of this exception. This may
 75    * only be called once. Subsequent calls throw an
 76    * <code>IllegalStateException</code>.
 77    * </p>
 78    *
 79    * <p>
 80    * This method is unnecessary in Java 1.4 where it could easily be
 81    * inherited from the superclass. However, including it here
 82    * allows this method to be used in Java 1.3 and earlier.
 83    * </p>
 84    *
 85    * @param cause the root cause of this exception
 86    *
 87    * @return this <code>XSLException</code>
 88    *
 89    * @throws IllegalArgumentException if the cause is this exception
 90    * (An exception cannot be its own cause.)
 91    * @throws IllegalStateException if this method is called twice
 92    */
 93  138 public final Throwable initCause(Throwable cause) {
 94   
 95  138 if (causeSet) {
 96  4 throw new IllegalStateException("Can't overwrite cause");
 97    }
 98  134 else if (cause == this) {
 99  1 throw new IllegalArgumentException(
 100    "Self-causation not permitted");
 101    }
 102  133 else this.cause = cause;
 103  133 causeSet = true;
 104  133 return this;
 105   
 106    }
 107   
 108   
 109    /**
 110    * <p>
 111    * Returns the underlying exception that caused this exception.
 112    * </p>
 113    *
 114    * @return the initial exception that caused this exception
 115    * to be thrown
 116    */
 117  18 public Throwable getCause() {
 118  18 return this.cause;
 119    }
 120   
 121   
 122    }