Coverage Report - org.apache.tapestry.util.ResourceBundlePropertySource
 
Classes in this File Line Coverage Branch Coverage Complexity
ResourceBundlePropertySource
0%
0/6
N/A
2
 
 1  
 // Copyright 2004, 2005 The Apache Software Foundation
 2  
 //
 3  
 // Licensed under the Apache License, Version 2.0 (the "License");
 4  
 // you may not use this file except in compliance with the License.
 5  
 // You may obtain a copy of the License at
 6  
 //
 7  
 //     http://www.apache.org/licenses/LICENSE-2.0
 8  
 //
 9  
 // Unless required by applicable law or agreed to in writing, software
 10  
 // distributed under the License is distributed on an "AS IS" BASIS,
 11  
 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 12  
 // See the License for the specific language governing permissions and
 13  
 // limitations under the License.
 14  
 
 15  
 package org.apache.tapestry.util;
 16  
 
 17  
 import java.util.MissingResourceException;
 18  
 import java.util.ResourceBundle;
 19  
 
 20  
 import org.apache.tapestry.engine.IPropertySource;
 21  
 
 22  
 /**
 23  
  *  A property source that is based on a {@link java.util.ResourceBundle}.
 24  
  *
 25  
  *  @author Howard Lewis Ship
 26  
  *  @since 3.0
 27  
  *
 28  
  **/
 29  
 
 30  
 public class ResourceBundlePropertySource implements IPropertySource
 31  
 {
 32  
     private ResourceBundle _bundle;
 33  
 
 34  
     public ResourceBundlePropertySource(ResourceBundle bundle)
 35  0
     {
 36  0
         _bundle = bundle;
 37  0
     }
 38  
 
 39  
     /**
 40  
      *  Gets the value from the bundle by invoking
 41  
      *  {@link ResourceBundle#getString(java.lang.String)}.  If
 42  
      *  the bundle does not contain the key (that is, it it
 43  
      *  throws {@link java.util.MissingResourceException}), then
 44  
      *  null is returned.
 45  
      * 
 46  
      **/
 47  
     
 48  
     public String getPropertyValue(String propertyName)
 49  
     {
 50  
         try
 51  
         {
 52  0
             return _bundle.getString(propertyName);
 53  
         }
 54  0
         catch (MissingResourceException ex)
 55  
         {
 56  0
             return null;
 57  
         }
 58  
     }
 59  
 
 60  
 }