Coverage Report - org.apache.commons.latka.ValidationException
 
Classes in this File Line Coverage Branch Coverage Complexity
ValidationException
0%
0/18
0%
0/6
1.6
 
 1  
 /*
 2  
  * Copyright 1999-2002,2004 The Apache Software Foundation.
 3  
  * 
 4  
  * Licensed under the Apache License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  * 
 8  
  *      http://www.apache.org/licenses/LICENSE-2.0
 9  
  * 
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  */
 16  
 
 17  
 package org.apache.commons.latka;
 18  
 
 19  
 /**
 20  
  * This exception is thrown by <em>validators</em> when a validation has failed
 21  
  *
 22  
  * @author Doug Sale
 23  
  * @author dIon Gillard (mainly javadoc)
 24  
  * @version $Revision: 155424 $
 25  
  */
 26  
 public class ValidationException extends Exception {
 27  
     
 28  
     /**
 29  
      * Create a validation exception with a null label and reason
 30  
      */
 31  
     public ValidationException() {
 32  0
         this(null, null);
 33  0
     }
 34  
 
 35  
     /**
 36  
      * Create a validation exception with the given
 37  
      * label and reason
 38  
      * @param label the user's description of the assertion/test
 39  
      * @param reason the reason it failed
 40  
      */    
 41  0
     public ValidationException(String label, String reason) {
 42  0
         _label = label;
 43  0
         _reason = reason;
 44  0
     }
 45  
 
 46  
     /** User's description of the test/assertion */
 47  0
     private String _label = null;
 48  
 
 49  
     /** Why the test/assertion failed */
 50  0
     private String _reason = null;
 51  
 
 52  
     /**
 53  
      * the message of the exception
 54  
      * @return the message of the exception, built from
 55  
      * the label and reason
 56  
      */    
 57  
     public String getMessage() {
 58  0
         StringBuffer buf = new StringBuffer();
 59  0
         if (null != getLabel()) {
 60  0
             buf.append(getLabel());
 61  0
             if (null != getReason()) {
 62  0
                 buf.append(": ");
 63  
             }
 64  
         }
 65  0
         if (null != getReason()) {
 66  0
             buf.append(getReason());
 67  
         }
 68  0
         return buf.toString();
 69  
     }
 70  
 
 71  
     /**
 72  
      * User's description of the test/assertion
 73  
      * @return User's description of the test/assertion
 74  
      */
 75  
     public String getLabel() {
 76  0
         return _label;
 77  
     }
 78  
 
 79  
     /**
 80  
      * Why the test/assertion failed
 81  
      * @return Why the test/assertion failed
 82  
      */
 83  
     public String getReason() {
 84  0
         return _reason;
 85  
     }
 86  
 }