Clover coverage report - CRISPY - 1.1.1
Coverage timestamp: Mi Nov 15 2006 13:09:46 CET
file stats: LOC: 45   Methods: 2
NCLOC: 28   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
ClassPropertiesLoader.java 100% 100% 100% 100%
coverage
 1    package net.sf.crispy.properties;
 2   
 3    import java.io.InputStream;
 4    import java.util.Properties;
 5   
 6    import net.sf.crispy.PropertiesLoader;
 7   
 8    /**
 9    * Load file where the class is find.
 10    * Example: class is: <code>test.crispy.Run</code> the file is in the same directory
 11    * <code>/test/crispy/example.properties</code>
 12    * use internal: <code>clazz.getResourceAsStream(fileName);</code>
 13    *
 14    * @author Linke
 15    *
 16    */
 17    public class ClassPropertiesLoader implements PropertiesLoader {
 18   
 19    private String fileName = null;
 20    private Class clazz = null;
 21   
 22  5 public ClassPropertiesLoader(Class pvClass, String pvFileName) {
 23  5 fileName = pvFileName;
 24  5 clazz = pvClass;
 25    }
 26   
 27  6 public Properties load() {
 28  6 if (fileName == null) {
 29  2 throw new IllegalArgumentException("The file name for the ClassPropertiesLoader is null.");
 30    }
 31  4 if (clazz == null) {
 32  1 throw new IllegalArgumentException("The class for the ClassPropertiesLoader is null.");
 33    }
 34   
 35  3 InputStream lvInputStream = clazz.getResourceAsStream(fileName);
 36  3 Properties lvProperties = new Properties();
 37  3 try {
 38  3 lvProperties.load(lvInputStream);
 39    } catch (Exception e) {
 40  1 throw new PropertiesLoadException("Error in load-method:", e);
 41    }
 42  2 return lvProperties;
 43    }
 44   
 45    }