Clover coverage report - DNA Site - 1.1
Coverage timestamp: Sun May 2 2004 15:33:21 BST
file stats: LOC: 158   Methods: 7
NCLOC: 63   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
ConfigurationException.java 100% 100% 100% 100%
coverage
 1   
 /*
 2   
  * Copyright (C) The DNA Group. All rights reserved.
 3   
  *
 4   
  * This software is published under the terms of the DNA
 5   
  * Software License version 1.1, a copy of which has been included
 6   
  * with this distribution in the LICENSE.txt file.
 7   
  */
 8   
 package org.codehaus.dna;
 9   
 
 10   
 /**
 11   
  * The ConfigurationException is used to signal a problem
 12   
  * with the configuration object. The configuration object
 13   
  * may have malformed data (ie expected an integer but got
 14   
  * a string), have missing data (ie no attribute with specified
 15   
  * name) or may fail to be valid via some other mechanism.
 16   
  *
 17   
  * @version $Revision: 1.2 $ $Date: 2004/05/01 09:51:48 $
 18   
  */
 19   
 public class ConfigurationException
 20   
     extends Exception
 21   
 {
 22   
     /**
 23   
      * The exception that caused this exception if any.
 24   
      */
 25   
     private final Throwable m_cause;
 26   
 
 27   
     /**
 28   
      * The xpath to the configuration element that
 29   
      * caused the exception. This may be null or empty
 30   
      * if not relevent or not known.
 31   
      */
 32   
     private final String m_path;
 33   
 
 34   
     /**
 35   
      * A string describing the location of the configuration
 36   
      * element that caused the exception. This may be null
 37   
      * or empty if not relevent or not known. The location is
 38   
      * usally formatted according to <tt>uri[:line number[:column number]]</tt>.
 39   
      * Note that the line and column numbers may not be present.
 40   
      */
 41   
     private final String m_location;
 42   
 
 43   
     /**
 44   
      * Create configuration exception with specified message,
 45   
      * path and location.
 46   
      *
 47   
      * @param message the message
 48   
      * @param path the path
 49   
      * @param location the location
 50   
      */
 51  84
     public ConfigurationException( final String message,
 52   
                                    final String path,
 53   
                                    final String location )
 54   
     {
 55  84
         this( message, path, location, null );
 56   
     }
 57   
 
 58   
     /**
 59   
      * Create configuration exception with specified
 60   
      * message and cause.
 61   
      *
 62   
      * @param message the message
 63   
      * @param cause the cause
 64   
      */
 65  4
     public ConfigurationException( final String message,
 66   
                                    final Throwable cause )
 67   
     {
 68  4
         this( message, null, null, cause );
 69   
     }
 70   
 
 71   
     /**
 72   
      * Create configuration exception with specified message,
 73   
      * path, location and cause.
 74   
      *
 75   
      * @param message the message
 76   
      * @param path the path
 77   
      * @param location the location
 78   
      * @param cause the cause
 79   
      */
 80  120
     public ConfigurationException( final String message,
 81   
                                    final String path,
 82   
                                    final String location,
 83   
                                    final Throwable cause )
 84   
     {
 85  120
         super( message );
 86  120
         m_cause = cause;
 87  120
         m_path = path;
 88  120
         m_location = location;
 89   
     }
 90   
 
 91   
     /**
 92   
      * The xpath to the configuration element that
 93   
      * caused the exception. This may be null or empty
 94   
      * if not relevent or not known.
 95   
      *
 96   
      * @return the xpath to element that caused exception
 97   
      */
 98  28
     public String getPath()
 99   
     {
 100  28
         return m_path;
 101   
     }
 102   
 
 103   
     /**
 104   
      * Return a string describing the location of the configuration
 105   
      * element that caused the exception. This may be null
 106   
      * or empty if not relevent or not known. The location is usally
 107   
      * formatted according to <tt>uri[:line number[:column number]]</tt>.
 108   
      * Note that the line and column numbers may not be present.
 109   
      *
 110   
      * @return the location where exception occured
 111   
      */
 112  28
     public String getLocation()
 113   
     {
 114  28
         return m_location;
 115   
     }
 116   
 
 117   
     /**
 118   
      * Return the exception that caused this exception if any.
 119   
      *
 120   
      * @return the exception that caused this exception if any.
 121   
      */
 122  28
     public Throwable getCause()
 123   
     {
 124  28
         return m_cause;
 125   
     }
 126   
 
 127   
     /**
 128   
      * Return the string representation of exception.
 129   
      *
 130   
      * @return the string representation of exception.
 131   
      */
 132  28
     public String toString()
 133   
     {
 134  28
         final StringBuffer sb = new StringBuffer();
 135   
 
 136  28
         if( null != m_path && !"".equals( m_path ) )
 137   
         {
 138  12
             sb.append( " - " );
 139  12
             sb.append( m_path );
 140   
         }
 141   
 
 142  28
         if( null != m_location && !"".equals( m_location ) )
 143   
         {
 144  12
             sb.append( " @ " );
 145  12
             sb.append( m_location );
 146   
         }
 147   
 
 148  28
         if( 0 != sb.length() )
 149   
         {
 150  20
             return super.toString() + sb;
 151   
         }
 152   
         else
 153   
         {
 154  8
             return super.toString();
 155   
         }
 156   
     }
 157   
 }
 158