01: /*
02: * Created on Mar 22, 2004
03: *
04: * To change the template for this generated file go to
05: * Window>Preferences>Java>Code Generation>Code and Comments
06: */
07: package org.xdev.base.core.compiler.validator;
08:
09: import java.util.HashMap;
10:
11: import org.xdev.base.core.compiler.CompilerException;
12: import org.xdev.base.xssl.XSSLAction;
13: import org.xdev.base.xssl.XSSLComponent;
14:
15: /**
16: * @author AYegorov
17: *
18: * To change the template for this generated type comment go to
19: * Window>Preferences>Java>Code Generation>Code and Comments
20: */
21: public abstract class AbstractValidator {
22:
23: private static HashMap validators = new HashMap();
24:
25: public static synchronized ValidatorCollection getValidator(
26: Class cls) {
27: return (ValidatorCollection) validators.get(cls);
28: }
29:
30: public static synchronized void addValidator(Class cls,
31: Class validator) {
32: if (validators.containsKey(cls)) {
33: ValidatorCollection vals = (ValidatorCollection) validators
34: .get(cls);
35:
36: if (!vals.contains(validator)) {
37:
38: vals.add(validator);
39: }
40:
41: vals = null;
42: } else {
43:
44: ValidatorCollection vc = new ValidatorCollection();
45:
46: vc.add(validator);
47:
48: validators.put(cls, vc);
49:
50: vc = null;
51: }
52: }
53:
54: public static void doValidation(XSSLComponent component)
55: throws Exception {
56: if (component != null) {
57: ValidatorCollection vc = AbstractValidator
58: .getValidator(component.getClass());
59:
60: if (vc != null) {
61: vc.validate(component);
62: }
63:
64: vc = null;
65: }
66: }
67:
68: protected abstract void validate(XSSLComponent component)
69: throws Exception;
70: }
|