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 | 21 | 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 | 21 | this.annotationReaderFactory = annotationReaderFactory; |
36 | 21 | } |
37 | |
|
38 | |
public void setCubbyConfiguration(final CubbyConfiguration cubbyConfiguration) { |
39 | 21 | this.cubbyConfiguration = cubbyConfiguration; |
40 | 21 | } |
41 | |
|
42 | |
public AnnotationReader getAnnotationReader() { |
43 | 15 | final AnnotationReader annotationReader = annotationReaderFactory |
44 | |
.getAnnotationReader(); |
45 | 15 | return new CubbyAnnotationReaderWrapper(annotationReader, |
46 | |
cubbyConfiguration.getFormatPattern()); |
47 | |
} |
48 | |
|
49 | 21 | static class CubbyAnnotationReaderWrapper implements AnnotationReader { |
50 | |
|
51 | |
private final AnnotationReader annotationReader; |
52 | |
|
53 | |
private final FormatPattern formatPattern; |
54 | |
|
55 | 15 | public CubbyAnnotationReaderWrapper(final AnnotationReader annotationReader, final FormatPattern formatPattern) { |
56 | 15 | this.annotationReader = annotationReader; |
57 | 15 | this.formatPattern = formatPattern; |
58 | 15 | } |
59 | |
|
60 | |
@SuppressWarnings("unchecked") |
61 | |
public String getDatePattern(final Class dxoClass, final Method method) { |
62 | 5 | String datePattern = annotationReader.getDatePattern(dxoClass, method); |
63 | 5 | if (StringUtil.isEmpty(datePattern) && formatPattern != null) { |
64 | 5 | datePattern = formatPattern.getDatePattern(); |
65 | |
} |
66 | 5 | return datePattern; |
67 | |
} |
68 | |
|
69 | |
@SuppressWarnings("unchecked") |
70 | |
public String getTimePattern(final Class dxoClass, final Method method) { |
71 | 5 | String timePattern = annotationReader.getTimePattern(dxoClass, method); |
72 | 5 | if (StringUtil.isEmpty(timePattern) && formatPattern != null) { |
73 | 5 | timePattern = formatPattern.getTimePattern(); |
74 | |
} |
75 | 5 | return timePattern; |
76 | |
} |
77 | |
|
78 | |
@SuppressWarnings("unchecked") |
79 | |
public String getTimestampPattern(final Class dxoClass, final Method method) { |
80 | 5 | String timestampPattern = annotationReader.getTimestampPattern(dxoClass, method); |
81 | 5 | if (StringUtil.isEmpty(timestampPattern) && formatPattern != null) { |
82 | 5 | timestampPattern = formatPattern.getTimestampPattern(); |
83 | |
} |
84 | 5 | return timestampPattern; |
85 | |
} |
86 | |
|
87 | |
@SuppressWarnings("unchecked") |
88 | |
public String getConversionRule(final Class dxoClass, final Method method) { |
89 | 10 | return annotationReader.getConversionRule(dxoClass, method); |
90 | |
} |
91 | |
|
92 | |
@SuppressWarnings("unchecked") |
93 | |
public boolean isExcludeNull(final Class dxoClass, final Method method) { |
94 | 10 | return annotationReader.isExcludeNull(dxoClass, method); |
95 | |
} |
96 | |
|
97 | |
@SuppressWarnings("unchecked") |
98 | |
public Map getConverters(final Class destClass) { |
99 | 4 | return annotationReader.getConverters(destClass); |
100 | |
} |
101 | |
|
102 | |
@SuppressWarnings("unchecked") |
103 | |
public String getSourcePrefix(final Class dxoClass, final Method method) { |
104 | 10 | return annotationReader.getSourcePrefix(dxoClass, method); |
105 | |
} |
106 | |
|
107 | |
} |
108 | |
|
109 | |
} |