Coverage Report - org.seasar.cubby.action.impl.FormatPatternImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
FormatPatternImpl
100%
26/26
N/A
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.action.impl;
 17  
 
 18  
 import java.text.DateFormat;
 19  
 import java.text.SimpleDateFormat;
 20  
 
 21  
 import org.seasar.cubby.action.FormatPattern;
 22  
 
 23  
 /**
 24  
  * 日付や時刻のフォーマットパターンを保持するクラスの実装です。
 25  
  * 
 26  
  * @author baba
 27  
  * @since 1.0.0
 28  
  */
 29  91
 public class FormatPatternImpl implements FormatPattern {
 30  
 
 31  
         /**
 32  
          * 日付フォーマットパターン
 33  
          */
 34  91
         private String datePattern = "yyyy-MM-dd";
 35  
 
 36  
         /**
 37  
          * 時刻フォーマットパターン
 38  
          */
 39  91
         private String timePattern = "HH:mm:ss";
 40  
 
 41  
         /**
 42  
          * 日付時刻フォーマットパターン
 43  
          */
 44  91
         private String timestampPattern = "yyyy-MM-dd HH:mm:ss";
 45  
 
 46  
         /**
 47  
          * 日付フォーマットパターンを取得します。
 48  
          * 
 49  
          * @return 日付フォーマットパターン
 50  
          */
 51  
         public String getDatePattern() {
 52  5
                 return datePattern;
 53  
         }
 54  
 
 55  
         /**
 56  
          * 日付フォーマットパターンをセットします。
 57  
          * 
 58  
          * @param datePattern
 59  
          *            日付フォーマットパターン
 60  
          */
 61  
         public void setDatePattern(String datePattern) {
 62  22
                 this.datePattern = datePattern;
 63  22
         }
 64  
 
 65  
         /**
 66  
          * 時刻フォーマットパターンを取得します。
 67  
          * 
 68  
          * @return 時刻フォーマットパターン
 69  
          */
 70  
         public String getTimePattern() {
 71  3
                 return timePattern;
 72  
         }
 73  
 
 74  
         /**
 75  
          * 時刻フォーマットパターンをセットします。
 76  
          * 
 77  
          * @param timePattern
 78  
          *            時刻フォーマットパターン
 79  
          */
 80  
         public void setTimePattern(String timePattern) {
 81  22
                 this.timePattern = timePattern;
 82  22
         }
 83  
 
 84  
         /**
 85  
          * 日付時刻フォーマットパターンを取得します。
 86  
          * 
 87  
          * @return 日付時刻フォーマットパターン
 88  
          */
 89  
         public String getTimestampPattern() {
 90  2
                 return timestampPattern;
 91  
         }
 92  
 
 93  
         /**
 94  
          * 日付時刻フォーマットパターンをセットします。
 95  
          * 
 96  
          * @param timestampPattern
 97  
          *            日付時刻フォーマットパターン
 98  
          */
 99  
         public void setTimestampPattern(String timestampPattern) {
 100  22
                 this.timestampPattern = timestampPattern;
 101  22
         }
 102  
 
 103  
         /**
 104  
          * 日付フォーマットを取得します。
 105  
          * 
 106  
          * @return 日付フォーマット
 107  
          */
 108  
         public DateFormat getDateFormat() {
 109  10
                 return new SimpleDateFormat(this.datePattern);
 110  
         }
 111  
 
 112  
         /**
 113  
          * 時刻フォーマットを取得します。
 114  
          * 
 115  
          * @return 時刻フォーマット
 116  
          */
 117  
         public DateFormat getTimeFormat() {
 118  5
                 return new SimpleDateFormat(this.timePattern);
 119  
         }
 120  
 
 121  
         /**
 122  
          * 日付時刻フォーマットを取得します。
 123  
          * 
 124  
          * @return 日付時刻フォーマット
 125  
          */
 126  
         public DateFormat getTimestampFormat() {
 127  4
                 return new SimpleDateFormat(this.timestampPattern);
 128  
         }
 129  
 
 130  
         /**
 131  
          * このオブジェクトの文字列表現を取得します。
 132  
          * 
 133  
          * @return このオブジェクトの文字列表現
 134  
          */
 135  
         @Override
 136  
         public String toString() {
 137  84
                 StringBuilder builder = new StringBuilder();
 138  84
                 builder.append(super.toString());
 139  84
                 builder.append("[datePattern=");
 140  84
                 builder.append(datePattern);
 141  84
                 builder.append(",timePattern=");
 142  84
                 builder.append(timePattern);
 143  84
                 builder.append(",timestampPattern=");
 144  84
                 builder.append(timestampPattern);
 145  84
                 builder.append("]");
 146  84
                 return builder.toString();
 147  
         }
 148  
 
 149  
 }