Clover coverage report - Clover results for XOM 1.2d1
Coverage timestamp: Wed Feb 8 2006 08:31:33 EST
file stats: LOC: 106   Methods: 3
NCLOC: 23   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
CanonicalizationException.java 100% 100% 100% 100%
coverage
 1    /* Copyright 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    package nu.xom.canonical;
 22   
 23    /**
 24    * <p>
 25    * Indicates problems with canonicalization.
 26    * </p>
 27    *
 28    * @author Elliotte Rusty Harold
 29    * @version 1.1b3
 30    *
 31    */
 32    public class CanonicalizationException extends RuntimeException {
 33   
 34   
 35    private static final long serialVersionUID = 6935623053373600014L;
 36   
 37    private Throwable cause;
 38   
 39   
 40    /**
 41    * <p>
 42    * Creates a new <code>CanonicalizationException</code>
 43    * with a detail message.
 44    * </p>
 45    *
 46    * @param message a string indicating the specific problem
 47    */
 48  11 public CanonicalizationException(String message) {
 49  11 super(message);
 50    }
 51   
 52   
 53    /**
 54    * <p>
 55    * Return the original cause that led to this exception,
 56    * or null if there was no original exception.
 57    * </p>
 58    *
 59    * @return the root cause of this exception
 60    */
 61  3 public final Throwable getCause() {
 62  3 return this.cause;
 63    }
 64   
 65   
 66    // null is insufficient for detecting an uninitialized cause.
 67    // The cause may be set to null which may not then be reset.
 68    private boolean causeSet = false;
 69   
 70   
 71    /**
 72    * <p>
 73    * Sets the root cause of this exception. This may
 74    * only be called once. Subsequent calls throw an
 75    * <code>IllegalStateException</code>.
 76    * </p>
 77    *
 78    * <p>
 79    * This method is unnecessary in Java 1.4 where it could easily be
 80    * inherited from the superclass. However, including it here
 81    * allows this method to be used in Java 1.3 and earlier.
 82    * </p>
 83    *
 84    * @param cause the root cause of this exception
 85    *
 86    * @return this <code>XMLException</code>
 87    *
 88    * @throws IllegalArgumentException if the cause is this exception
 89    * (An exception cannot be its own cause.)
 90    * @throws IllegalStateException if this method is called twice
 91    */
 92  7 public final Throwable initCause(Throwable cause) {
 93   
 94  7 if (causeSet) {
 95  4 throw new IllegalStateException("Can't overwrite cause");
 96    }
 97  3 else if (cause == this) {
 98  1 throw new IllegalArgumentException("Self-causation not permitted");
 99    }
 100  2 else this.cause = cause;
 101  2 causeSet = true;
 102  2 return this;
 103   
 104    }
 105   
 106    }