Coverage report

  %line %branch
net.sf.tlc.core.impl.DefaultPropertyManager
79% 
100% 

 1  
 /*
 2  
  * Created on May 19, 2005
 3  
  *
 4  
  * The default implementation of PropertyManager
 5  
  */
 6  
 package net.sf.tlc.core.impl;
 7  
 
 8  
 import java.io.File;
 9  
 import java.io.FileInputStream;
 10  
 import java.io.FileNotFoundException;
 11  
 import java.io.IOException;
 12  
 import java.util.Properties;
 13  
 import java.util.logging.Level;
 14  
 import java.util.logging.Logger;
 15  
 
 16  
 import net.sf.tlc.core.PropertyManager;
 17  
 
 18  
 /**
 19  
  * The default implementation of PropertyManager
 20  
  * 
 21  
  * @author aisrael
 22  
  */
 23  3
 public final class DefaultPropertyManager implements PropertyManager {
 24  
     
 25  57
     private static final Logger logger = Logger.getLogger(DefaultPropertyManager.class.getName());
 26  
 
 27  
     private final Properties properties;
 28  
 
 29  
     /**
 30  
      * @param file
 31  
      *            File
 32  
      */
 33  40
     public DefaultPropertyManager(final File file) {
 34  40
         properties = new Properties();
 35  
         try {
 36  40
             properties.load(new FileInputStream(file));
 37  0
         } catch (FileNotFoundException e) {
 38  0
             logger.log(Level.WARNING, "File not found: \"" + file.getName() + "\"", e);
 39  0
         } catch (IOException e) {
 40  0
             logger.log(Level.SEVERE, "IOException", e);
 41  36
         }
 42  40
     }
 43  
 
 44  
     /**
 45  
      * @param propertyFile
 46  
      *            String
 47  
      */
 48  
     public DefaultPropertyManager(final String propertyFile) {
 49  40
         this(new File(propertyFile));
 50  40
     }
 51  
 
 52  
     /**
 53  
      * (non-Javadoc)
 54  
      * 
 55  
      * @see net.sf.tlc.core.PropertyManager#getProperties()
 56  
      */
 57  
     public Properties getProperties() {
 58  10
         return this.properties;
 59  
     }
 60  
 
 61  
     /**
 62  
      * (non-Javadoc)
 63  
      * 
 64  
      * @see net.sf.tlc.core.PropertyManager#getProperty(java.lang.String)
 65  
      */
 66  
     public String getProperty(final String key) {
 67  40
         return this.properties.getProperty(key);
 68  
     }
 69  
 
 70  
     /**
 71  
      * (non-Javadoc)
 72  
      * @see net.sf.tlc.core.PropertyManager#getProperty(java.lang.String, java.lang.String)
 73  
      */
 74  
     public String getProperty(final String key, class="keyword">final String defaultValue) {
 75  30
         String result = getProperty(key);
 76  30
         if (null == result) {
 77  30
             result = defaultValue;
 78  
         }
 79  30
         return result;
 80  
     }
 81  
 
 82  
 }

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