01: // Copyright 2007 The Apache Software Foundation
02: //
03: // Licensed under the Apache License, Version 2.0 (the "License");
04: // you may not use this file except in compliance with the License.
05: // You may obtain a copy of the License at
06: //
07: // http://www.apache.org/licenses/LICENSE-2.0
08: //
09: // 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.services;
16:
17: import java.util.List;
18:
19: import org.apache.tapestry.FieldValidator;
20: import org.apache.tapestry.ioc.AnnotationProvider;
21:
22: /**
23: * Invoked to generate a list of validation constraint strings for a property. This typically
24: * involves scanning the property for annotations or naming conventions that confer the desired
25: * validation. The constraint strings are ultimately handed to
26: * {@link FieldValidatorSource#createValidator(org.apache.tapestry.Field, String, String, String, org.apache.tapestry.ioc.Messages, java.util.Locale)}.
27: */
28: public interface ValidationConstraintGenerator {
29: /**
30: * For a given property, identify all the approprite validation constraints. Each returned value
31: * is the name of a validator (i.e., "required") or a validator name and configuration (i.e.,
32: * "minlength=5"). These contraints are exactly the individual terms in a
33: * {@link FieldValidatorSource#createValidators(org.apache.tapestry.Field, String) validate specification}.
34: * These will ultimately be used to create {@link FieldValidator}s for the field that edits the
35: * property.
36: *
37: * @param propertyType
38: * the type of the property for which constraints are needed
39: * @param annotationProvider
40: * provides access to any annotations concerning the property (for implementations
41: * that are based on analysis of property annotations)
42: * @return a list of constraints
43: * @see FieldValidatorSource
44: */
45: List<String> buildConstraints(Class propertyType,
46: AnnotationProvider annotationProvider);
47: }
|