View Javadoc

1   /*
2    * Copyright 2004-2007 the Seasar Foundation and the Others.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 
13   * either express or implied. See the License for the specific language
14   * governing permissions and limitations under the License.
15   */
16  package org.seasar.cubby.dxo;
17  
18  import java.lang.reflect.Method;
19  import java.util.Map;
20  
21  import org.seasar.cubby.action.FormatPattern;
22  import org.seasar.extension.dxo.annotation.AnnotationReader;
23  import org.seasar.framework.util.StringUtil;
24  
25  public class CubbyAnnotationReaderWrapper implements AnnotationReader {
26  
27  	private final AnnotationReader annotationReader;
28  
29  	private final FormatPattern formatPattern;
30  
31  	public CubbyAnnotationReaderWrapper(AnnotationReader annotationReader, FormatPattern formatPattern) {
32  		this.annotationReader = annotationReader;
33  		this.formatPattern = formatPattern;
34  	}
35  
36  	@SuppressWarnings("unchecked")
37  	public String getDatePattern(Class dxoClass, Method method) {
38  		String datePattern = annotationReader.getDatePattern(dxoClass, method);
39  		if (StringUtil.isEmpty(datePattern) && formatPattern != null) {
40  			datePattern = formatPattern.getDatePattern();
41  		}
42  		return datePattern;
43  	}
44  
45  	@SuppressWarnings("unchecked")
46  	public String getTimePattern(Class dxoClass, Method method) {
47  		String timePattern = annotationReader.getTimePattern(dxoClass, method);
48  		if (StringUtil.isEmpty(timePattern) && formatPattern != null) {
49  			timePattern = formatPattern.getTimePattern();
50  		}
51  		return timePattern;
52  	}
53  
54  	@SuppressWarnings("unchecked")
55  	public String getTimestampPattern(Class dxoClass, Method method) {
56  		String timestampPattern = annotationReader.getTimestampPattern(dxoClass, method);
57  		if (StringUtil.isEmpty(timestampPattern) && formatPattern != null) {
58  			timestampPattern = formatPattern.getTimestampPattern();
59  		}
60  		return timestampPattern;
61  	}
62  
63  	@SuppressWarnings("unchecked")
64  	public String getConversionRule(Class dxoClass, Method method) {
65  		return annotationReader.getConversionRule(dxoClass, method);
66  	}
67  
68  	@SuppressWarnings("unchecked")
69  	public boolean isExcludeNull(Class dxoClass, Method method) {
70  		return annotationReader.isExcludeNull(dxoClass, method);
71  	}
72  
73  	@SuppressWarnings("unchecked")
74  	public Map getConverters(Class destClass) {
75  		return annotationReader.getConverters(destClass);
76  	}
77  
78  	@SuppressWarnings("unchecked")
79  	public String getSourcePrefix(Class dxoClass, Method method) {
80  		return annotationReader.getSourcePrefix(dxoClass, method);
81  	}
82  
83  }