Coverage report

  %line %branch
net.sf.infrared.web.util.PropertyUtil
0% 
0% 

 1  
 /*
 2  
  *
 3  
  * Copyright 2005 Tavant Technologies and Contributors
 4  
  * 
 5  
  * Licensed under the Apache License, Version 2.0 (the "License")
 6  
  * you may not use this file except in compliance with the License.
 7  
  * You may obtain a copy of the License at
 8  
  *
 9  
  *     http://www.apache.org/licenses/LICENSE-2.0
 10  
  *
 11  
  * Unless required by applicable law or agreed to in writing, software
 12  
  * distributed under the License is distributed on an "AS IS" BASIS,
 13  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14  
  * See the License for the specific language governing permissions and
 15  
  * limitations under the License.
 16  
  *
 17  
  *
 18  
  *
 19  
  * Original Author:  prashant.nair (Tavant Technologies)
 20  
  * Contributor(s):   
 21  
  *
 22  
  */
 23  
 
 24  
 package net.sf.infrared.web.util;
 25  
 
 26  
 import java.net.URL;
 27  
 import java.util.Properties;
 28  
 
 29  
 import net.sf.infrared.base.util.LoggingFactory;
 30  
 
 31  
 import org.apache.log4j.Logger;
 32  
 
 33  
 public class PropertyUtil {
 34  
     
 35  
     private Properties prop;
 36  
     private URL config;
 37  0
     public static Logger log = LoggingFactory.getLogger(PropertyUtil.class);
 38  
 
 39  0
     public PropertyUtil(String propertyFile){
 40  
         try {
 41  0
             prop = new Properties();
 42  0
             ClassLoader loader = Thread.currentThread().getContextClassLoader();
 43  0
             config = loader.getResource(propertyFile);
 44  0
             prop.load(config.openStream());
 45  
         }
 46  0
         catch (Exception e) {
 47  0
             log.error("Unable to load web configuration , will use default configuration");
 48  0
         }        
 49  0
     }
 50  
     
 51  
     public String getProperty(String property , String defaultValue){
 52  0
         if(prop.getProperty(property) == null){
 53  0
             log.debug("The property " + property + " is not defined. " +
 54  
                                     "Returning default value " + defaultValue);
 55  0
             return defaultValue;
 56  
         }
 57  
         else{
 58  0
             return prop.getProperty(property);
 59  
         }
 60  
     }
 61  
 
 62  
 
 63  
 }

This report is generated by jcoverage, Maven and Maven JCoverage Plugin.