Clover coverage report - brownies library - 1.0-beta-1
Coverage timestamp: 月 8 16 2004 17:14:42 GMT+09:00
file stats: LOC: 88   Methods: 8
NCLOC: 67   Classes: 1
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover
 
 Source file Conditionals Statements Methods TOTAL
PropertyUtils.java 66.7% 70.6% 75% 70.4%
coverage coverage
 1   
 /*
 2   
  * Joey and its relative products are published under the terms
 3   
  * of the Apache Software License.
 4   
  */
 5   
 /*
 6   
  * Created on 2004/01/13
 7   
  */
 8   
 package org.asyrinx.brownie.core.lang;
 9   
 
 10   
 /**
 11   
  * @author akima
 12   
  */
 13   
 public class PropertyUtils extends org.apache.commons.beanutils.PropertyUtils {
 14   
 
 15  9
     public static String getPropertyAsString(Object object, String propName) {
 16  9
         return getPropertyAsString(object, propName, null);
 17   
     }
 18   
 
 19  9
     public static String getPropertyAsString(Object object, String propName,
 20   
             String defaultValue) {
 21  9
         try {
 22  9
             return String.valueOf(getProperty(object, propName));
 23   
         } catch (Exception e) {
 24  3
             return defaultValue;
 25   
         }
 26   
     }
 27   
 
 28  9
     public static int getPropertyAsInt(Object object, String propName) {
 29  9
         return getPropertyAsInt(object, propName, 0);
 30   
     }
 31   
 
 32  9
     public static int getPropertyAsInt(Object object, String propName,
 33   
             int defaultValue) {
 34  9
         final Object result;
 35  9
         try {
 36  9
             result = getProperty(object, propName);
 37   
         } catch (Exception e) {
 38  3
             return defaultValue;
 39   
         }
 40  6
         if (result instanceof Number)
 41  2
             return ((Number) result).intValue();
 42  4
         else if (result instanceof String)
 43  2
             return NumberUtils.toInt(result, 0);
 44   
         else
 45  2
             return defaultValue;
 46   
     }
 47   
 
 48  0
     public static long getPropertyAsLong(Object object, String propName) {
 49  0
         return getPropertyAsLong(object, propName, 0);
 50   
     }
 51   
 
 52  0
     public static long getPropertyAsLong(Object object, String propName,
 53   
             long defaultValue) {
 54  0
         final Object result;
 55  0
         try {
 56  0
             result = getProperty(object, propName);
 57   
         } catch (Exception e) {
 58  0
             return defaultValue;
 59   
         }
 60  0
         if (result instanceof Number)
 61  0
             return ((Number) result).longValue();
 62  0
         else if (result instanceof String)
 63  0
             return NumberUtils.toLong(result, 0);
 64   
         else
 65  0
             return defaultValue;
 66   
     }
 67   
 
 68  9
     public static boolean getPropertyAsBoolean(Object object, String propName) {
 69  9
         return getPropertyAsBoolean(object, propName, false);
 70   
     }
 71   
 
 72  9
     public static boolean getPropertyAsBoolean(Object object, String propName,
 73   
             boolean defaultValue) {
 74  9
         final Object result;
 75  9
         try {
 76  9
             result = getProperty(object, propName);
 77   
         } catch (Exception e) {
 78  3
             return defaultValue;
 79   
         }
 80  6
         if (result instanceof Boolean)
 81  2
             return ((Boolean) result).booleanValue();
 82  4
         else if (result instanceof String)
 83  2
             return "true".equalsIgnoreCase((String) result);
 84   
         else
 85  2
             return defaultValue;
 86   
     }
 87   
 
 88   
 }