Clover coverage report - Code Coverage for hivemind release 1.1-alpha-2
Coverage timestamp: Wed Feb 23 2005 09:59:04 EST
file stats: LOC: 110   Methods: 10
NCLOC: 57   Classes: 1
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover
 
 Source file Conditionals Statements Methods TOTAL
ApplicationRuntimeException.java 100% 100% 100% 100%
coverage
 1   
 // Copyright 2004, 2005 The Apache Software Foundation
 2   
 //
 3   
 // Licensed under the Apache License, Version 2.0 (the "License");
 4   
 // you may not use this file except in compliance with the License.
 5   
 // You may obtain a copy of the License at
 6   
 //
 7   
 //     http://www.apache.org/licenses/LICENSE-2.0
 8   
 //
 9   
 // Unless required by applicable law or agreed to in writing, software
 10   
 // distributed under the License is distributed on an "AS IS" BASIS,
 11   
 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 12   
 // See the License for the specific language governing permissions and
 13   
 // limitations under the License.
 14   
 
 15   
 package org.apache.hivemind;
 16   
 
 17   
 /**
 18   
  * General wrapper for any exception (normal or runtime) that may occur during runtime processing
 19   
  * for the application. This is exception is used when the intent is to communicate a low-level
 20   
  * failure to the user or developer; it is not expected to be caught. The
 21   
  * {@link #getRootCause() rootCause}property is a <em>nested</em> exception.
 22   
  * 
 23   
  * @author Howard Lewis Ship
 24   
  */
 25   
 
 26   
 public class ApplicationRuntimeException extends RuntimeException implements Locatable
 27   
 {
 28   
     private Throwable _rootCause;
 29   
 
 30   
     private transient Location _location;
 31   
 
 32   
     private transient Object _component;
 33   
 
 34  2
     public ApplicationRuntimeException(Throwable rootCause)
 35   
     {
 36  2
         this(rootCause.getMessage(), rootCause);
 37   
     }
 38   
 
 39  59
     public ApplicationRuntimeException(String message)
 40   
     {
 41  59
         this(message, null, null, null);
 42   
     }
 43   
 
 44  23
     public ApplicationRuntimeException(String message, Throwable rootCause)
 45   
     {
 46  23
         this(message, null, null, rootCause);
 47   
     }
 48   
 
 49  125
     public ApplicationRuntimeException(String message, Object component, Location location,
 50   
             Throwable rootCause)
 51   
     {
 52  125
         super(message);
 53   
 
 54  125
         _rootCause = rootCause;
 55  125
         _component = component;
 56   
 
 57  125
         _location = HiveMind.findLocation(new Object[]
 58   
         { location, rootCause, component });
 59   
     }
 60   
 
 61  32
     public ApplicationRuntimeException(String message, Location location, Throwable rootCause)
 62   
     {
 63  32
         this(message, null, location, rootCause);
 64   
     }
 65   
 
 66  7
     public Throwable getRootCause()
 67   
     {
 68  7
         return _rootCause;
 69   
     }
 70   
 
 71  16
     public Location getLocation()
 72   
     {
 73  16
         return _location;
 74   
     }
 75   
 
 76  7
     public Object getComponent()
 77   
     {
 78  7
         return _component;
 79   
     }
 80   
 
 81   
     /**
 82   
      * This method is for compatibility with JDK 1.4. Under 1.4, this will look like an override,
 83   
      * allowing <code>printStackTrace()</code> to descending into the root cause exception and
 84   
      * print its stack trace too.
 85   
      */
 86  1
     public Throwable getCause()
 87   
     {
 88  1
         return _rootCause;
 89   
     }
 90   
 
 91   
     /**
 92   
      * Overrides the default implementation of <code>toString</code>, suffixing the normal result
 93   
      * with the {@link #getLocation() location}of the exception (if non null). Example:
 94   
      * <code>org.apache.hivemind.ApplicationRuntimeException: Exception Message [file:foo/bar/baz, line 13]</code>.
 95   
      * 
 96   
      * @since 1.1
 97   
      */
 98  7
     public String toString()
 99   
     {
 100  7
         if (_location == null)
 101  6
             return super.toString();
 102   
 
 103  1
         StringBuffer buffer = new StringBuffer(super.toString());
 104  1
         buffer.append(" [");
 105  1
         buffer.append(_location);
 106  1
         buffer.append("]");
 107   
 
 108  1
         return buffer.toString();
 109   
     }
 110   
 }