[Schmitzm-commits] r1978 - trunk/schmitzm-excelcsv/src/main/java/de/schmitzm/csv

scm-commit at wald.intevation.org scm-commit at wald.intevation.org
Thu May 3 00:12:22 CEST 2012


Author: mojays
Date: 2012-05-03 00:12:22 +0200 (Thu, 03 May 2012)
New Revision: 1978

Modified:
   trunk/schmitzm-excelcsv/src/main/java/de/schmitzm/csv/CsvUtil.java
Log:
CsvUtil: method to convert string to boolean

Modified: trunk/schmitzm-excelcsv/src/main/java/de/schmitzm/csv/CsvUtil.java
===================================================================
--- trunk/schmitzm-excelcsv/src/main/java/de/schmitzm/csv/CsvUtil.java	2012-05-02 14:13:39 UTC (rev 1977)
+++ trunk/schmitzm-excelcsv/src/main/java/de/schmitzm/csv/CsvUtil.java	2012-05-02 22:12:22 UTC (rev 1978)
@@ -200,6 +200,19 @@
   }
 
   /**
+   * Converts a string to boolean.
+   * @return {@code false} if input string is {@code null}
+   */
+  public static boolean convertBoolean(String str, Boolean... defaultValue) {
+    boolean defValue = defaultValue.length > 0 ? defaultValue[0] : false;
+  
+    if ( str == null || str.trim().isEmpty() )
+      return defValue;
+    
+    return LangUtil.parseStringDefaultFalse(str);
+  }
+
+  /**
    * Converts a string to double.
    * @return 0 if input string is {@code null}
    */



More information about the Schmitzm-commits mailing list