1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.springmodules.validation.bean.conf.loader.xml;
18
19 import org.springmodules.validation.bean.conf.loader.xml.handler.*;
20 import org.springmodules.validation.bean.conf.loader.xml.handler.jodatime.InstantInFutureRuleElementHandler;
21 import org.springmodules.validation.bean.conf.loader.xml.handler.jodatime.InstantInPastRuleElementHandler;
22 import org.springmodules.validation.util.LibraryUtils;
23
24 /**
25 * A {@link SimpleValidationRuleElementHandlerRegistry} that already registers the following default element handlers:
26 * <p/>
27 * <ol>
28 * <li>{@link NotNullRuleElementHandler}</li>
29 * <li>{@link LengthRuleElementHandler}</li>
30 * <li>{@link NotBlankRuleElementHandler}</li>
31 * <li>{@link EmailRuleElementHandler}</li>
32 * <li>{@link RegExpRuleElementHandler}</li>
33 * <li>{@link SizeRuleElementHandler}</li>
34 * <li>{@link NotEmptyRuleElementHandler}</li>
35 * <li>{@link NotBlankRuleElementHandler}</li>
36 * <li>{@link RangeRuleElementHandler}</li>
37 * <li>{@link ExpressionPropertyValidationElementHandler}</li>
38 * <li>{@link DateInPastRuleElementHandler}</li>
39 * <li>{@link DateInFutureRuleElementHandler}</li> *
40 * <li>{@link InstantInFutureRuleElementHandler} (only if joda-time library is available in the classpath)</li> *
41 * <li>{@link InstantInPastRuleElementHandler} (only if joda-time library is available in the classpath)</li> *
42 * </ol>
43 *
44 * @author Uri Boness
45 */
46 public class DefaultValidationRuleElementHandlerRegistry extends SimpleValidationRuleElementHandlerRegistry {
47
48 /**
49 * Constructs a new DefaultValidationRuleElementHandlerRegistry with the default handlers.
50 */
51 public DefaultValidationRuleElementHandlerRegistry() {
52
53 String namepsaceUri = DefaultXmlBeanValidationConfigurationLoader.DEFAULT_NAMESPACE_URL;
54
55
56 registerClassHandler(new ExpressionClassValidationElementHandler(namepsaceUri));
57
58
59 registerPropertyHandler(new NotNullRuleElementHandler(namepsaceUri));
60 registerPropertyHandler(new LengthRuleElementHandler(namepsaceUri));
61 registerPropertyHandler(new EmailRuleElementHandler(namepsaceUri));
62 registerPropertyHandler(new RegExpRuleElementHandler(namepsaceUri));
63 registerPropertyHandler(new SizeRuleElementHandler(namepsaceUri));
64 registerPropertyHandler(new NotEmptyRuleElementHandler(namepsaceUri));
65 registerPropertyHandler(new NotBlankRuleElementHandler(namepsaceUri));
66 registerPropertyHandler(new RangeRuleElementHandler(namepsaceUri));
67 registerPropertyHandler(new ExpressionPropertyValidationElementHandler(namepsaceUri));
68 registerPropertyHandler(new DateInPastRuleElementHandler(namepsaceUri));
69 registerPropertyHandler(new DateInFutureRuleElementHandler(namepsaceUri));
70 registerPropertyHandler(new ConditionReferenceRuleElementHandler(namepsaceUri));
71 if (LibraryUtils.JODA_TIME_IN_CLASSPATH) {
72 registerPropertyHandler(new InstantInPastRuleElementHandler(namepsaceUri));
73 registerPropertyHandler(new InstantInFutureRuleElementHandler(namepsaceUri));
74 }
75 }
76
77 }