Coverage Report - org.apache.tapestry.valid.ValidatorException
 
Classes in this File Line Coverage Branch Coverage Complexity
ValidatorException
0%
0/10
N/A
1
 
 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.tapestry.valid;
 16  
 
 17  
 import org.apache.tapestry.IRender;
 18  
 
 19  
 /**
 20  
  * Thrown by a {@link IValidator}when submitted input is not valid.
 21  
  * 
 22  
  * @author Howard Lewis Ship
 23  
  * @since 1.0.8
 24  
  */
 25  
 
 26  
 public class ValidatorException extends Exception
 27  
 {
 28  
     private static final long serialVersionUID = 2451683137746501377L;
 29  
 
 30  
     private final IRender _errorRenderer;
 31  
 
 32  
     private final ValidationConstraint _constraint;
 33  
 
 34  
     public ValidatorException(String errorMessage)
 35  
     {
 36  0
         this(errorMessage, null, null);
 37  0
     }
 38  
 
 39  
     public ValidatorException(String errorMessage, ValidationConstraint constraint)
 40  
     {
 41  0
         this(errorMessage, null, constraint);
 42  0
     }
 43  
 
 44  
     /**
 45  
      * Creates a new instance.
 46  
      * 
 47  
      * @param errorMessage
 48  
      *            the default error message to be used (this may be overriden by the
 49  
      *            {@link IValidationDelegate})
 50  
      * @param errorRenderer
 51  
      *            to use to render the error message (may be null). This is used with custom
 52  
      *            validators that create renderers that produce rich markup (such as icons or links
 53  
      *            to help pages). Such renderes are expected to implement a <code>toString()</code>
 54  
      *            that returns a simple error message (without any markup).
 55  
      * @param constraint
 56  
      *            a validation constraint that has been compromised, or null if no constraint is
 57  
      *            applicable
 58  
      */
 59  
 
 60  
     public ValidatorException(String errorMessage, IRender errorRenderer,
 61  
             ValidationConstraint constraint)
 62  
     {
 63  0
         super(errorMessage);
 64  
 
 65  0
         _errorRenderer = errorRenderer;
 66  0
         _constraint = constraint;
 67  0
     }
 68  
 
 69  
     public ValidationConstraint getConstraint()
 70  
     {
 71  0
         return _constraint;
 72  
     }
 73  
 
 74  
     /**
 75  
      * Returns the error renderer for this exception, which may be null.
 76  
      * 
 77  
      * @since 3.0 *
 78  
      */
 79  
 
 80  
     public IRender getErrorRenderer()
 81  
     {
 82  0
         return _errorRenderer;
 83  
     }
 84  
 }