Coverage Report - org.seasar.cubby.dxo.impl.RequestParameterAnnotationReader
 
Classes in this File Line Coverage Branch Coverage Complexity
RequestParameterAnnotationReader
100%
15/15
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  
 
 20  
 import org.seasar.cubby.action.FormatPattern;
 21  
 import org.seasar.cubby.controller.CubbyConfiguration;
 22  
 import org.seasar.cubby.dxo.FormDxo;
 23  
 import org.seasar.extension.dxo.annotation.impl.TigerAnnotationReader;
 24  
 import org.seasar.framework.container.S2Container;
 25  
 import org.seasar.framework.util.StringUtil;
 26  
 
 27  
 /**
 28  
  * Dxoインタフェースまたはクラスやそのメソッドからアノテーションを読み取るクラスで、リクエストのパラメータとアクションのプロパティとの変換に使用します。
 29  
  * <p>
 30  
  * 日付関連の処理を{@link CubbyConfiguration}から取得した{@link FormatPattern}へ移譲します。
 31  
  * </p>
 32  
  * 
 33  
  * @see FormDxo
 34  
  * @author baba
 35  
  * @since 1.0.0
 36  
  */
 37  
 public class RequestParameterAnnotationReader extends TigerAnnotationReader {
 38  
 
 39  
         /** フォーマットパターン。 */
 40  
         private final FormatPattern formatPattern;
 41  
 
 42  
         /**
 43  
          * インスタンス化します。
 44  
          * 
 45  
          * @param container
 46  
          *            コンテナ
 47  
          * @param configuration
 48  
          *            Cubby の全体的な設定情報
 49  
          */
 50  
         public RequestParameterAnnotationReader(final S2Container container,
 51  
                         final CubbyConfiguration configuration) {
 52  36
                 super(container);
 53  36
                 this.formatPattern = configuration.getFormatPattern();
 54  36
         }
 55  
 
 56  
         /**
 57  
          * {@inheritDoc}
 58  
          * <p>
 59  
          * {@link FormatPattern#getDatePattern()}へ移譲します。
 60  
          * </p>
 61  
          */
 62  
         @SuppressWarnings("unchecked")
 63  
         @Override
 64  
         public String getDatePattern(final Class dxoClass, final Method method) {
 65  9
                 String datePattern = super.getDatePattern(dxoClass, method);
 66  9
                 if (StringUtil.isEmpty(datePattern) && formatPattern != null) {
 67  9
                         datePattern = formatPattern.getDatePattern();
 68  
                 }
 69  9
                 return datePattern;
 70  
         }
 71  
 
 72  
         /**
 73  
          * {@inheritDoc}
 74  
          * <p>
 75  
          * {@link FormatPattern#getTimePattern()}へ移譲します。
 76  
          * </p>
 77  
          */
 78  
         @SuppressWarnings("unchecked")
 79  
         @Override
 80  
         public String getTimePattern(final Class dxoClass, final Method method) {
 81  9
                 String timePattern = super.getTimePattern(dxoClass, method);
 82  9
                 if (StringUtil.isEmpty(timePattern) && formatPattern != null) {
 83  9
                         timePattern = formatPattern.getTimePattern();
 84  
                 }
 85  9
                 return timePattern;
 86  
         }
 87  
 
 88  
         /**
 89  
          * {@inheritDoc}
 90  
          * <p>
 91  
          * {@link FormatPattern#getTimestampPattern()}へ移譲します。
 92  
          * </p>
 93  
          */
 94  
         @SuppressWarnings("unchecked")
 95  
         @Override
 96  
         public String getTimestampPattern(final Class dxoClass, final Method method) {
 97  9
                 String timestampPattern = super.getTimestampPattern(dxoClass, method);
 98  9
                 if (StringUtil.isEmpty(timestampPattern) && formatPattern != null) {
 99  9
                         timestampPattern = formatPattern.getTimestampPattern();
 100  
                 }
 101  9
                 return timestampPattern;
 102  
         }
 103  
 
 104  
 }