1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.seasar.cubby.dxo.impl;
17
18 import java.lang.reflect.Method;
19 import java.util.Map;
20
21 import org.seasar.cubby.action.FormatPattern;
22 import org.seasar.cubby.controller.CubbyConfiguration;
23 import org.seasar.extension.dxo.annotation.AnnotationReader;
24 import org.seasar.extension.dxo.annotation.AnnotationReaderFactory;
25 import org.seasar.framework.util.StringUtil;
26
27 public class RequestParameterAnnotationReaderFactoryWrapper implements
28 AnnotationReaderFactory {
29
30 private AnnotationReaderFactory annotationReaderFactory;
31
32 private CubbyConfiguration cubbyConfiguration;
33
34 public void setAnnotationReaderFactory(final AnnotationReaderFactory annotationReaderFactory) {
35 this.annotationReaderFactory = annotationReaderFactory;
36 }
37
38 public void setCubbyConfiguration(final CubbyConfiguration cubbyConfiguration) {
39 this.cubbyConfiguration = cubbyConfiguration;
40 }
41
42 public AnnotationReader getAnnotationReader() {
43 final AnnotationReader annotationReader = annotationReaderFactory
44 .getAnnotationReader();
45 return new CubbyAnnotationReaderWrapper(annotationReader,
46 cubbyConfiguration.getFormatPattern());
47 }
48
49 static class CubbyAnnotationReaderWrapper implements AnnotationReader {
50
51 private final AnnotationReader annotationReader;
52
53 private final FormatPattern formatPattern;
54
55 public CubbyAnnotationReaderWrapper(final AnnotationReader annotationReader, final FormatPattern formatPattern) {
56 this.annotationReader = annotationReader;
57 this.formatPattern = formatPattern;
58 }
59
60 @SuppressWarnings("unchecked")
61 public String getDatePattern(final Class dxoClass, final Method method) {
62 String datePattern = annotationReader.getDatePattern(dxoClass, method);
63 if (StringUtil.isEmpty(datePattern) && formatPattern != null) {
64 datePattern = formatPattern.getDatePattern();
65 }
66 return datePattern;
67 }
68
69 @SuppressWarnings("unchecked")
70 public String getTimePattern(final Class dxoClass, final Method method) {
71 String timePattern = annotationReader.getTimePattern(dxoClass, method);
72 if (StringUtil.isEmpty(timePattern) && formatPattern != null) {
73 timePattern = formatPattern.getTimePattern();
74 }
75 return timePattern;
76 }
77
78 @SuppressWarnings("unchecked")
79 public String getTimestampPattern(final Class dxoClass, final Method method) {
80 String timestampPattern = annotationReader.getTimestampPattern(dxoClass, method);
81 if (StringUtil.isEmpty(timestampPattern) && formatPattern != null) {
82 timestampPattern = formatPattern.getTimestampPattern();
83 }
84 return timestampPattern;
85 }
86
87 @SuppressWarnings("unchecked")
88 public String getConversionRule(final Class dxoClass, final Method method) {
89 return annotationReader.getConversionRule(dxoClass, method);
90 }
91
92 @SuppressWarnings("unchecked")
93 public boolean isExcludeNull(final Class dxoClass, final Method method) {
94 return annotationReader.isExcludeNull(dxoClass, method);
95 }
96
97 @SuppressWarnings("unchecked")
98 public Map getConverters(final Class destClass) {
99 return annotationReader.getConverters(destClass);
100 }
101
102 @SuppressWarnings("unchecked")
103 public String getSourcePrefix(final Class dxoClass, final Method method) {
104 return annotationReader.getSourcePrefix(dxoClass, method);
105 }
106
107 }
108
109 }