Coverage Report - org.seasar.cubby.controller.impl.DefaultMessagesBehaviour
 
Classes in this File Line Coverage Branch Coverage Complexity
DefaultMessagesBehaviour
100%
9/9
100%
2/2
0
 
 1  
 /*
 2  
  * Copyright 2004-2009 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.controller.impl;
 17  
 
 18  
 import java.util.Locale;
 19  
 import java.util.Map;
 20  
 import java.util.ResourceBundle;
 21  
 
 22  
 import org.seasar.cubby.controller.MessagesBehaviour;
 23  
 import org.seasar.cubby.internal.util.ResourceBundleMap;
 24  
 
 25  
 /**
 26  
  * メッセージの振る舞いのデフォルト実装です。
 27  
  * 
 28  
  * @author baba
 29  
  * @since 1.0.3
 30  
  */
 31  75
 public class DefaultMessagesBehaviour implements MessagesBehaviour {
 32  
 
 33  
         /** デフォルトのメッセージリソース名。 */
 34  
         public static final String DEFAULT_RESOURCE_NAME = "messages";
 35  
 
 36  
         /** リソースバンドル、完全指定されたクラス名の基底名。 */
 37  75
         private String baseName = DEFAULT_RESOURCE_NAME;
 38  
 
 39  
         /**
 40  
          * リソースバンドル、完全指定されたクラス名の基底名を取得します。
 41  
          * 
 42  
          * @return リソースバンドル、完全指定されたクラス名の基底名
 43  
          */
 44  
         public String getBaseName() {
 45  6
                 return baseName;
 46  
         }
 47  
 
 48  
         /**
 49  
          * リソースバンドル、完全指定されたクラス名の基底名を設定します。
 50  
          * 
 51  
          * @param baseName
 52  
          *            リソースバンドル、完全指定されたクラス名の基底名
 53  
          */
 54  
         public void setBaseName(final String baseName) {
 55  3
                 this.baseName = baseName;
 56  3
         }
 57  
 
 58  
         /**
 59  
          * {@inheritDoc}
 60  
          */
 61  
         public ResourceBundle getBundle(final Locale locale) {
 62  36
                 final ClassLoader classLoader = Thread.currentThread()
 63  
                                 .getContextClassLoader();
 64  36
                 final ResourceBundle bundle = ResourceBundle.getBundle(baseName,
 65  
                                 (locale == null ? Locale.getDefault() : locale), classLoader);
 66  36
                 return bundle;
 67  
         }
 68  
 
 69  
         /**
 70  
          * {@inheritDoc}
 71  
          */
 72  
         public Map<String, Object> toMap(final ResourceBundle bundle) {
 73  12
                 return new ResourceBundleMap(bundle);
 74  
         }
 75  
 
 76  
 }