KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > inversoft > util > typevalidator > TypeValidator


1 /*
2  * Copyright (c) 2003, Inversoft
3  *
4  * This software is distribuable under the GNU Lesser General Public License.
5  * For more information visit gnu.org.
6  */

7 package com.inversoft.util.typevalidator;
8
9
10 import java.util.Locale JavaDoc;
11
12 import com.inversoft.beans.BeanException;
13 import com.inversoft.error.BasicError;
14 import com.inversoft.error.PropertyError;
15
16
17 /**
18  * <p>
19  * This interface defines a method of validating Objects
20  * directly, or validating JavaBean property values.
21  * </p>
22  *
23  * @author Brian Pontarelli
24  * @since 2.0
25  * @version 2.0
26  */

27 public interface TypeValidator {
28
29     /**
30      * This method validates a single value and returns the result of that
31      * validation. This result is a new BasicError object that contains the
32      * error message given
33      *
34      * @param value The value to validate
35      * @param params (Optional) An Object that can be used to pass parameters
36      * to a validator that can help determine how to validation is to
37      * take place
38      * @param message (Optional) The error message to use for failed validation.
39      * If this is null, a default message should be supplied by
40      * implementations of this interface
41      * @param mesgParams (Optional) An array of Objects that is passed to the
42      * java.text.MessageFormat class to format the message passed in.
43      * If this is null, no formatting takes place
44      * @return The result of the validation or null if the validation was
45      * successfull
46      */

47     BasicError validate(Object JavaDoc value, Object JavaDoc params, String JavaDoc message,
48             Object JavaDoc [] mesgParams);
49
50     /**
51      * This method validates a single value and returns the result of that
52      * validation. This result is a new BasicError object that contains the
53      * error stored in the bundle with the given name and the given key.
54      *
55      * @param value The value to validate
56      * @param params (Optional) An Object that can be used to pass parameters
57      * to a validator that can help determine how to validation is to
58      * take place
59      * @param bundleName (Optional) The name of the resource bundle that the
60      * error is stored in. If this or key are null, a default error
61      * message should be used by implemenations of this interface
62      * @param key (Optional) The key of the error mesage in the bundle
63      * @param locale (Optional) The Locale of the bundle. If null, the default
64      * Locale is used
65      * @param mesgParams (Optional) An array of Objects that is passed to the
66      * java.text.MessageFormat class to format the message passed in.
67      * If this is null, no formatting takes place
68      * @param caller (Optional) The caller object, which is passed to the
69      * ErrorRegistry and prepended to the key when looking up the error
70      * from the bundle. If this is null, then only the key is used
71      * @return The result of the validation or null if the validation was
72      * successfull
73      */

74     BasicError validate(Object JavaDoc value, Object JavaDoc params, String JavaDoc bundleName, String JavaDoc key,
75             Locale JavaDoc locale, Object JavaDoc [] mesgParams, Object JavaDoc caller);
76
77     /**
78      * This method validates a single value and returns the result of that
79      * validation. This result is a new PropertyError object that contains the
80      * error message given and is for the property name given. This method does
81      * not fetch the property value as does the fetchAndValidate methods.
82      *
83      * @param propertyName The name of the property to retrieve the value to be
84      * validated
85      * @param value The value to validate
86      * @param params (Optional) An Object that can be used to pass parameters
87      * to a validator that can help determine how to validation is to
88      * take place
89      * @param message The error message
90      * @param mesgParams (Optional) An array of Objects that is passed to the
91      * java.text.MessageFormat class to format the message passed in.
92      * If this is null, no formatting takes place
93      * @return The result of the validation or null if the validation was
94      * successfull
95      */

96     PropertyError validate(String JavaDoc propertyName, Object JavaDoc value, Object JavaDoc params,
97             String JavaDoc message, Object JavaDoc [] mesgParams);
98
99     /**
100      * This method validates a single value and returns the result of that
101      * validation. This result is a new PropertyError object that contains the
102      * error message given and is for the property name given. This method does
103      * not fetch the property value as does the fetchAndValidate methods.
104      *
105      * @param propertyName The name of the property to retrieve the value to be
106      * validated
107      * @param value The value to validate
108      * @param params (Optional) An Object that can be used to pass parameters
109      * to a validator that can help determine how to validation is to
110      * take place
111      * @param bundleName (Optional) The name of the resource bundle that the
112      * error is stored in. If this or key are null, a default error
113      * message should be used by implemenations of this interface
114      * @param key (Optional) The key of the error mesage in the bundle
115      * @param locale (Optional) The Locale of the bundle. If null, the default
116      * Locale is used
117      * @param mesgParams (Optional) An array of Objects that is passed to the
118      * java.text.MessageFormat class to format the message passed in.
119      * If this is null, no formatting takes place
120      * @param caller (Optional) The caller object, which is passed to the
121      * ErrorRegistry and prepended to the key when looking up the error
122      * from the bundle. If this is null, then only the key is used
123      * @return The result of the validation or null if the validation was
124      * successfull
125      */

126     PropertyError validate(String JavaDoc propertyName, Object JavaDoc value, Object JavaDoc params,
127             String JavaDoc bundleName, String JavaDoc key, Locale JavaDoc locale, Object JavaDoc [] mesgParams,
128             Object JavaDoc caller);
129
130     /**
131      * This method validates a single value, which is retrieved from the bean
132      * Object instance given from the property with the given JavaBean compliant
133      * property name, and returns the result of that validation. This result is
134      * a new PropertyError object that contains the error message given.
135      *
136      * @param propertyName The name of the property to retrieve the value to be
137      * validated
138      * @param bean The JavaBean instance to retrieve the value from
139      * @param params (Optional) An Object that can be used to pass parameters
140      * to a validator that can help determine how to validation is to
141      * take place
142      * @param message The error message
143      * @param mesgParams (Optional) An array of Objects that is passed to the
144      * java.text.MessageFormat class to format the message passed in.
145      * If this is null, no formatting takes place
146      * @return The result of the validation or null if the validation was
147      * successfull
148      * @throws BeanException If the propertyName is invalid or not a property on
149      * the given bean Object
150      */

151     PropertyError fetchAndValidate(String JavaDoc propertyName, Object JavaDoc bean, Object JavaDoc params,
152             String JavaDoc message, Object JavaDoc [] mesgParams)
153     throws BeanException;
154
155     /**
156      * This method validates a single value, which is retrieved from the bean
157      * Object instance given from the property with the given JavaBean compliant
158      * property name, and returns the result of that validation. This result is
159      * a new PropertyError object that contains the error stored in the bundle
160      * with the given name and the given key.
161      *
162      * @param propertyName The name of the property to retrieve the value to be
163      * validated
164      * @param bean The JavaBean instance to retrieve the value from
165      * @param params (Optional) An Object that can be used to pass parameters
166      * to a validator that can help determine how to validation is to
167      * take place
168      * @param bundleName (Optional) The name of the resource bundle that the
169      * error is stored in. If this or key are null, a default error
170      * message should be used by implemenations of this interface
171      * @param key (Optional) The key of the error mesage in the bundle
172      * @param locale (Optional) The Locale of the bundle. If null, the default
173      * Locale is used
174      * @param mesgParams (Optional) An array of Objects that is passed to the
175      * java.text.MessageFormat class to format the message passed in.
176      * If this is null, no formatting takes place
177      * @param caller (Optional) The caller object, which is passed to the
178      * ErrorRegistry and prepended to the key when looking up the error
179      * from the bundle. If this is null, then only the key is used
180      * @return The result of the validation or null if the validation was
181      * successfull
182      * @throws BeanException If the propertyName is invalid or not a property on
183      * the given bean Object
184      */

185     PropertyError fetchAndValidate(String JavaDoc propertyName, Object JavaDoc bean, Object JavaDoc params,
186             String JavaDoc bundleName, String JavaDoc key, Locale JavaDoc locale, Object JavaDoc [] mesgParams,
187             Object JavaDoc caller)
188     throws BeanException;
189 }
Popular Tags