##### Coverage Report - org.seasar.cubby.controller.impl.DefaultMessagesBehaviour

Classes in this File | Line Coverage | Branch Coverage | Complexity
DefaultMessagesBehaviour |
100% | 9/9
100% | 2/2
| 1.25;1.25

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 |  |
      */
30 | 25 |
     public class DefaultMessagesBehaviour implements MessagesBehaviour {
31 |  |
32 |  |
             /** デフォルトのメッセージリソース名。 */
33 |  |
             public static final String DEFAULT_RESOURCE_NAME = "messages";
34 |  |
35 |  |
             /** リソースバンドル、完全指定されたクラス名の基底名。 */
36 | 25 |
             private String baseName = DEFAULT_RESOURCE_NAME;
37 |  |
38 |  |
             /**
39 |  |
              * リソースバンドル、完全指定されたクラス名の基底名を取得します。
40 |  |
              *
41 |  |
              * @return リソースバンドル、完全指定されたクラス名の基底名
42 |  |
              */
43 |  |
             public String getBaseName() {
44 | 2 |
                     return baseName;
45 |  |
             }
46 |  |
47 |  |
             /**
48 |  |
              * リソースバンドル、完全指定されたクラス名の基底名を設定します。
49 |  |
              *
50 |  |
              * @param baseName
51 |  |
              *            リソースバンドル、完全指定されたクラス名の基底名
52 |  |
              */
53 |  |
             public void setBaseName(final String baseName) {
54 | 1 |
                     this.baseName = baseName;
55 | 1 |
             }
56 |  |
57 |  |
             /**
58 |  |
              * {@inheritDoc}
59 |  |
              */
60 |  |
             public ResourceBundle getBundle(final Locale locale) {
61 | 12 |
                     final ClassLoader classLoader = Thread.currentThread()
62 |  |
                                     .getContextClassLoader();
63 | 12 |
                     final ResourceBundle bundle = ResourceBundle.getBundle(baseName,
64 |  |
                                     (locale == null ? Locale.getDefault() : locale), classLoader);
65 | 12 |
                     return bundle;
66 |  |
             }
67 |  |
68 |  |
             /**
69 |  |
              * {@inheritDoc}
70 |  |
              */
71 |  |
             public Map<String, Object> toMap(final ResourceBundle bundle) {
72 | 4 |
                     return new ResourceBundleMap(bundle);
73 |  |
             }
74 |  |
75 |  |
     }