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.cubby.controller.ThreadContext;
24 import org.seasar.extension.dxo.annotation.AnnotationReader;
25 import org.seasar.extension.dxo.annotation.AnnotationReaderFactory;
26 import org.seasar.framework.util.StringUtil;
27
28
29
30
31
32
33 public class RequestParameterAnnotationReaderFactoryWrapper implements
34 AnnotationReaderFactory {
35
36 private AnnotationReaderFactory annotationReaderFactory;
37
38 public void setAnnotationReaderFactory(
39 final AnnotationReaderFactory annotationReaderFactory) {
40 this.annotationReaderFactory = annotationReaderFactory;
41 }
42
43 public AnnotationReader getAnnotationReader() {
44 final AnnotationReader annotationReader = annotationReaderFactory
45 .getAnnotationReader();
46 final CubbyConfiguration configuration = ThreadContext
47 .getConfiguration();
48 return new CubbyAnnotationReaderWrapper(annotationReader, configuration
49 .getFormatPattern());
50 }
51
52 static class CubbyAnnotationReaderWrapper implements AnnotationReader {
53
54 private final AnnotationReader annotationReader;
55
56 private final FormatPattern formatPattern;
57
58 public CubbyAnnotationReaderWrapper(
59 final AnnotationReader annotationReader,
60 final FormatPattern formatPattern) {
61 this.annotationReader = annotationReader;
62 this.formatPattern = formatPattern;
63 }
64
65 @SuppressWarnings("unchecked")
66 public String getDatePattern(final Class dxoClass, final Method method) {
67 String datePattern = annotationReader.getDatePattern(dxoClass,
68 method);
69 if (StringUtil.isEmpty(datePattern) && formatPattern != null) {
70 datePattern = formatPattern.getDatePattern();
71 }
72 return datePattern;
73 }
74
75 @SuppressWarnings("unchecked")
76 public String getTimePattern(final Class dxoClass, final Method method) {
77 String timePattern = annotationReader.getTimePattern(dxoClass,
78 method);
79 if (StringUtil.isEmpty(timePattern) && formatPattern != null) {
80 timePattern = formatPattern.getTimePattern();
81 }
82 return timePattern;
83 }
84
85 @SuppressWarnings("unchecked")
86 public String getTimestampPattern(final Class dxoClass,
87 final Method method) {
88 String timestampPattern = annotationReader.getTimestampPattern(
89 dxoClass, method);
90 if (StringUtil.isEmpty(timestampPattern) && formatPattern != null) {
91 timestampPattern = formatPattern.getTimestampPattern();
92 }
93 return timestampPattern;
94 }
95
96 @SuppressWarnings("unchecked")
97 public String getConversionRule(final Class dxoClass,
98 final Method method) {
99 return annotationReader.getConversionRule(dxoClass, method);
100 }
101
102 @SuppressWarnings("unchecked")
103 public boolean isExcludeNull(final Class dxoClass, final Method method) {
104 return annotationReader.isExcludeNull(dxoClass, method);
105 }
106
107 @SuppressWarnings("unchecked")
108 public Map getConverters(final Class destClass) {
109 return annotationReader.getConverters(destClass);
110 }
111
112 @SuppressWarnings("unchecked")
113 public String getSourcePrefix(final Class dxoClass, final Method method) {
114 return annotationReader.getSourcePrefix(dxoClass, method);
115 }
116
117 @SuppressWarnings("unchecked")
118 public String getDestPrefix(final Class dxoClass, final Method method) {
119 return annotationReader.getDestPrefix(dxoClass, method);
120 }
121
122 }
123
124 }