Coverage Report - javax.faces.internal.JavaMessageResourceBundle
 
Classes in this File Line Coverage Branch Coverage Complexity
JavaMessageResourceBundle
65%
13/20
75%
3/4
1.833
 
 1  
 /*
 2  
  * Copyright 2004-2011 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 javax.faces.internal;
 17  
 
 18  
 import java.util.Locale;
 19  
 import java.util.MissingResourceException;
 20  
 import java.util.ResourceBundle;
 21  
 
 22  
 import org.seasar.framework.log.Logger;
 23  
 import org.seasar.framework.message.MessageResourceBundle;
 24  
 import org.seasar.framework.util.ResourceBundleUtil;
 25  
 
 26  
 /**
 27  
  * @author shot
 28  
  */
 29  
 public class JavaMessageResourceBundle implements MessageResourceBundle {
 30  
 
 31  1
     private static final Logger logger = Logger
 32  1
             .getLogger(JavaMessageResourceBundle.class);
 33  
 
 34  
     private String bundleName;
 35  
 
 36  
     private Locale locale;
 37  
 
 38  
     private ResourceBundle bundle;
 39  
 
 40  
     private MessageResourceBundle parent;
 41  
 
 42  108
     public JavaMessageResourceBundle(String bundleName, Locale locale) {
 43  108
         this.bundleName = bundleName;
 44  108
         this.locale = locale;
 45  
         try {
 46  108
             this.bundle = ResourceBundleUtil.getBundle(bundleName, locale);
 47  0
         } catch (MissingResourceException e) {
 48  0
             logger
 49  
                     .info("ResourceBundle " + bundleName
 50  
                             + " could not be found.");
 51  108
         }
 52  108
     }
 53  
 
 54  
     public String get(String key) {
 55  215
         if (bundle == null || key == null) {
 56  3
             return null;
 57  
         }
 58  
         try {
 59  212
             return bundle.getString(key);
 60  36
         } catch (MissingResourceException ignore) {
 61  36
             return null;
 62  
         }
 63  
     }
 64  
 
 65  
     public MessageResourceBundle getParent() {
 66  0
         return parent;
 67  
     }
 68  
 
 69  
     public void setParent(MessageResourceBundle parent) {
 70  0
         this.parent = parent;
 71  0
     }
 72  
 
 73  
     public String getBundleName() {
 74  0
         return bundleName;
 75  
     }
 76  
 
 77  
     public Locale getLocale() {
 78  0
         return locale;
 79  
     }
 80  
 }