Clover coverage report - JFox Service-Oriented Application Framework - 1.0-RC3
Coverage timestamp: 星期三 二月 15 2006 18:10:22 CST
file stats: LOC: 97   Methods: 9
NCLOC: 50   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
PropertiesHelper.java 0% 0% 0% 0%
coverage
 1   
 /**
 2   
  * @(#)PropertiesHelper.java
 3   
  * 
 4   
  * JFoxSOAF, Service-Oriented Application Framework
 5   
  * 
 6   
  * Copyright(c) JFoxSOAF Team
 7   
  * 
 8   
  * Licensed under the GNU LGPL, Version 2.1 (the "License"); 
 9   
  * you may not use this file except in compliance with the License. 
 10   
  * You may obtain a copy of the License at  
 11   
  * 
 12   
  * http://www.gnu.org/copyleft/lesser.html
 13   
  * 
 14   
  * Unless required by applicable law or agreed to in writing, software
 15   
  * distributed under the License is distributed on an "AS IS" BASIS, 
 16   
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
 17   
  * See the License for the specific language governing permissions and 
 18   
  * limitations under the License. 
 19   
  * 
 20   
  * For more information, please visit:
 21   
  * http://www.jfox.cn/confluence/display/JFoxSOAF/Home
 22   
  * http://www.huihoo.org/jfox/jfoxsoaf
 23   
  */
 24   
 
 25   
 package org.huihoo.jfox.soaf.util.resource;
 26   
 
 27   
 import java.util.HashMap;
 28   
 import java.util.Map;
 29   
 import java.util.Properties;
 30   
 import java.util.StringTokenizer;
 31   
 
 32   
 
 33   
 
 34   
 /**
 35   
  * A help class to access to property file.
 36   
  * 
 37   
  * @author <a href="mailto:founder_chen@yahoo.com.cn">Peter Cheng </a>
 38   
  * @version $Revision: 1.2 $ $Date: 2006/02/15 08:45:46 $
 39   
  * @version Revision: 1.0
 40   
  */
 41   
 
 42   
 public class PropertiesHelper {
 43   
 
 44  0
     public PropertiesHelper() {
 45   
     }
 46   
 
 47  0
     public static boolean getBoolean(String property, Properties properties) {
 48  0
         return Boolean.valueOf(properties.getProperty(property)).booleanValue();
 49   
     }
 50   
 
 51  0
     public static boolean getBoolean(String property, Properties properties,
 52   
             boolean defaultValue) {
 53  0
         String setting = properties.getProperty(property);
 54  0
         return (setting == null) ? defaultValue : Boolean.valueOf(setting)
 55   
                 .booleanValue();
 56   
     }
 57   
 
 58  0
     public static int getInt(String property, Properties properties,
 59   
             int defaultValue) {
 60  0
         String propValue = properties.getProperty(property);
 61  0
         return (propValue == null) ? defaultValue : Integer.parseInt(propValue);
 62   
     }
 63   
 
 64  0
     public static String getString(String property, Properties properties,
 65   
             String defaultValue) {
 66  0
         String propValue = properties.getProperty(property);
 67  0
         return (propValue == null) ? defaultValue : propValue;
 68   
     }
 69   
 
 70  0
     public static Integer getInteger(String property, Properties properties) {
 71  0
         String propValue = properties.getProperty(property);
 72  0
         return (propValue == null) ? null : Integer.valueOf(propValue);
 73   
     }
 74   
 
 75  0
     public static Map toMap(String property, String delim, Properties properties) {
 76  0
         Map map = new HashMap();
 77  0
         String propValue = properties.getProperty(property);
 78  0
         if (propValue != null) {
 79  0
             StringTokenizer tokens = new StringTokenizer(propValue, delim);
 80  0
             while (tokens.hasMoreTokens()) {
 81  0
                 map.put(tokens.nextToken(), tokens.hasMoreElements() ? tokens
 82   
                         .nextToken() : StringHelper.EMPTY_STRING);
 83   
             }
 84   
         }
 85  0
         return map;
 86   
     }
 87   
 
 88  0
     public static String[] toStringArray(String property, String delim,
 89   
             Properties properties) {
 90  0
         return toStringArray(properties.getProperty(property), delim);
 91   
     }
 92   
 
 93  0
     public static String[] toStringArray(String propValue, String delim) {
 94  0
         return StringHelper.split(delim, propValue);
 95   
     }
 96   
 
 97   
 }