Coverage Report - org.seasar.cubby.dxo.impl.RequestParameterAnnotationReaderFactoryWrapper
 
Classes in this File Line Coverage Branch Coverage Complexity
RequestParameterAnnotationReaderFactoryWrapper
100%
7/7
N/A
0
RequestParameterAnnotationReaderFactoryWrapper$CubbyAnnotationReaderWrapper
100%
21/21
50%
6/12
0
 
 1  
 /*
 2  
  * Copyright 2004-2008 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.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  
  * @author baba
 31  
  * 
 32  
  */
 33  38
 public class RequestParameterAnnotationReaderFactoryWrapper implements
 34  
                 AnnotationReaderFactory {
 35  
 
 36  
         private AnnotationReaderFactory annotationReaderFactory;
 37  
 
 38  
         public void setAnnotationReaderFactory(
 39  
                         final AnnotationReaderFactory annotationReaderFactory) {
 40  38
                 this.annotationReaderFactory = annotationReaderFactory;
 41  38
         }
 42  
 
 43  
         public AnnotationReader getAnnotationReader() {
 44  76
                 final AnnotationReader annotationReader = annotationReaderFactory
 45  
                                 .getAnnotationReader();
 46  76
                 final CubbyConfiguration configuration = ThreadContext
 47  
                                 .getConfiguration();
 48  76
                 return new CubbyAnnotationReaderWrapper(annotationReader, configuration
 49  
                                 .getFormatPattern());
 50  
         }
 51  
 
 52  38
         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  76
                                 final FormatPattern formatPattern) {
 61  76
                         this.annotationReader = annotationReader;
 62  76
                         this.formatPattern = formatPattern;
 63  76
                 }
 64  
 
 65  
                 @SuppressWarnings("unchecked")
 66  
                 public String getDatePattern(final Class dxoClass, final Method method) {
 67  9
                         String datePattern = annotationReader.getDatePattern(dxoClass,
 68  
                                         method);
 69  9
                         if (StringUtil.isEmpty(datePattern) && formatPattern != null) {
 70  9
                                 datePattern = formatPattern.getDatePattern();
 71  
                         }
 72  9
                         return datePattern;
 73  
                 }
 74  
 
 75  
                 @SuppressWarnings("unchecked")
 76  
                 public String getTimePattern(final Class dxoClass, final Method method) {
 77  9
                         String timePattern = annotationReader.getTimePattern(dxoClass,
 78  
                                         method);
 79  9
                         if (StringUtil.isEmpty(timePattern) && formatPattern != null) {
 80  9
                                 timePattern = formatPattern.getTimePattern();
 81  
                         }
 82  9
                         return timePattern;
 83  
                 }
 84  
 
 85  
                 @SuppressWarnings("unchecked")
 86  
                 public String getTimestampPattern(final Class dxoClass,
 87  
                                 final Method method) {
 88  9
                         String timestampPattern = annotationReader.getTimestampPattern(
 89  
                                         dxoClass, method);
 90  9
                         if (StringUtil.isEmpty(timestampPattern) && formatPattern != null) {
 91  9
                                 timestampPattern = formatPattern.getTimestampPattern();
 92  
                         }
 93  9
                         return timestampPattern;
 94  
                 }
 95  
 
 96  
                 @SuppressWarnings("unchecked")
 97  
                 public String getConversionRule(final Class dxoClass,
 98  
                                 final Method method) {
 99  47
                         return annotationReader.getConversionRule(dxoClass, method);
 100  
                 }
 101  
 
 102  
                 @SuppressWarnings("unchecked")
 103  
                 public boolean isExcludeNull(final Class dxoClass, final Method method) {
 104  47
                         return annotationReader.isExcludeNull(dxoClass, method);
 105  
                 }
 106  
 
 107  
                 @SuppressWarnings("unchecked")
 108  
                 public Map getConverters(final Class destClass) {
 109  4
                         return annotationReader.getConverters(destClass);
 110  
                 }
 111  
 
 112  
                 @SuppressWarnings("unchecked")
 113  
                 public String getSourcePrefix(final Class dxoClass, final Method method) {
 114  47
                         return annotationReader.getSourcePrefix(dxoClass, method);
 115  
                 }
 116  
 
 117  
                 @SuppressWarnings("unchecked")
 118  
                 public String getDestPrefix(final Class dxoClass, final Method method) {
 119  47
                         return annotationReader.getDestPrefix(dxoClass, method);
 120  
                 }
 121  
 
 122  
         }
 123  
 
 124  
 }