KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > turbine > services > intake > validator > Validator


1 package org.apache.turbine.services.intake.validator;
2
3 /*
4  * Copyright 2001-2004 The Apache Software Foundation.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License")
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18
19 /**
20  * Validator api.
21  *
22  * @author <a HREF="mailto:jmcnally@collab.net">John McNally</a>
23  * @version $Id: Validator.java,v 1.7.2.2 2004/05/20 03:06:47 seade Exp $
24  */

25 public interface Validator
26 {
27     /** "flexible" Rule, used in DateFormat Validator */
28     String JavaDoc FLEXIBLE_RULE_NAME = "flexible";
29
30     /** "format" Rule, used in DateFormat Validator */
31     String JavaDoc FORMAT_RULE_NAME = "format";
32
33     /** "invalidNumber" Rule, used in the various Number Validators */
34     String JavaDoc INVALID_NUMBER_RULE_NAME = "invalidNumber";
35
36     /** "mask" Rule, used in StringValidator */
37     String JavaDoc MASK_RULE_NAME = "mask";
38
39     /** "maxLength" Rule, used in all validators */
40     String JavaDoc MAX_LENGTH_RULE_NAME = "maxLength";
41
42     /** "maxValue" Rule, used in the various Number Validators */
43     String JavaDoc MAX_VALUE_RULE_NAME = "maxValue";
44
45     /** "minLength" Rule, used in all validators */
46     String JavaDoc MIN_LENGTH_RULE_NAME = "minLength";
47
48     /** "minValue" Rule, used in the various Number Validators */
49     String JavaDoc MIN_VALUE_RULE_NAME = "minValue";
50
51     /** "required" Rule, used in all validators */
52     String JavaDoc REQUIRED_RULE_NAME = "required";
53
54     /**
55      * Determine whether a testValue meets the criteria specified
56      * in the constraints defined for this validator
57      *
58      * @param testValue a <code>String</code> to be tested
59      * @return true if valid, false otherwise
60      */

61     boolean isValid(String JavaDoc testValue);
62
63     /**
64      * Determine whether a testValue meets the criteria specified
65      * in the constraints defined for this validator
66      *
67      * @param testValue a <code>String</code> to be tested
68      * @exception ValidationException containing an error message if the
69      * testValue did not pass the validation tests.
70      */

71     void assertValidity(String JavaDoc testValue)
72             throws ValidationException;
73
74     /**
75      * Get the last error message resulting from invalid input.
76      *
77      * @return a <code>String</code> message, or the empty String "".
78      */

79     String JavaDoc getMessage();
80 }
81
Popular Tags