1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.seasar.cubby.validator;
17
18 import java.lang.reflect.Method;
19
20 import org.seasar.cubby.action.Action;
21 import org.seasar.cubby.action.Validation;
22 import org.seasar.framework.beans.BeanDesc;
23 import org.seasar.framework.beans.PropertyDesc;
24 import org.seasar.framework.beans.factory.BeanDescFactory;
25
26
27
28
29
30
31
32 public class ValidationUtils {
33
34
35
36
37
38
39
40
41 public static Validation getValidation(final Method method) {
42 return method.getAnnotation(Validation.class);
43 }
44
45
46
47
48
49
50
51
52
53
54 public static ValidationRules getValidationRules(final Action action,
55 final String rulesPropertyName) {
56 final BeanDesc beanDesc = BeanDescFactory
57 .getBeanDesc(action.getClass());
58 final PropertyDesc propertyDesc = beanDesc
59 .getPropertyDesc(rulesPropertyName);
60 final ValidationRules rules = (ValidationRules) propertyDesc
61 .getValue(action);
62 return rules;
63 }
64
65 }