KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tapestry > valid > ValidatorException


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 JavaDoc
27 {
28     private IRender _errorRenderer;
29
30     private ValidationConstraint _constraint;
31
32     public ValidatorException(String JavaDoc errorMessage)
33     {
34         this(errorMessage, null, null);
35     }
36
37     public ValidatorException(String JavaDoc errorMessage, ValidationConstraint constraint)
38     {
39         this(errorMessage, null, constraint);
40     }
41
42     /**
43      * Creates a new instance.
44      *
45      * @param errorMessage
46      * the default error message to be used (this may be overriden by the
47      * {@link IValidationDelegate})
48      * @param errorRenderer
49      * to use to render the error message (may be null). This is used with custom
50      * validators that create renderers that produce rich markup (such as icons or links
51      * to help pages). Such renderes are expected to implement a <code>toString()</code>
52      * that returns a simple error message (without any markup).
53      * @param constraint
54      * a validation constraint that has been compromised, or null if no constraint is
55      * applicable
56      */

57
58     public ValidatorException(String JavaDoc errorMessage, IRender errorRenderer,
59             ValidationConstraint constraint)
60     {
61         super(errorMessage);
62
63         _errorRenderer = errorRenderer;
64         _constraint = constraint;
65     }
66
67     public ValidationConstraint getConstraint()
68     {
69         return _constraint;
70     }
71
72     /**
73      * Returns the error renderer for this exception, which may be null.
74      *
75      * @since 3.0 *
76      */

77
78     public IRender getErrorRenderer()
79     {
80         return _errorRenderer;
81     }
82 }
Popular Tags