[PATCH 1 of 2] issue1433: Do not emit warning when tolerated empty string as value

Wald Commits scm-commit at wald.intevation.org
Tue Aug 6 10:56:55 CEST 2013


# HG changeset patch
# User Felix Wolfsteller <felix.wolfsteller at intevation.de>
# Date 1375779281 -7200
# Node ID f275aae00c55ccc0873dc6fe9c6eaf3a6256727a
# Parent  aee8cb5c801aff9240a683cbd2d2d99f041c13cd
issue1433: Do not emit warning when tolerated empty string as value.

diff -r aee8cb5c801a -r f275aae00c55 backend/src/main/java/org/dive4elements/river/importer/parsers/WaterlevelDifferencesParser.java
--- a/backend/src/main/java/org/dive4elements/river/importer/parsers/WaterlevelDifferencesParser.java	Mon Aug 05 15:24:44 2013 +0200
+++ b/backend/src/main/java/org/dive4elements/river/importer/parsers/WaterlevelDifferencesParser.java	Tue Aug 06 10:54:41 2013 +0200
@@ -199,7 +199,9 @@
     }
 
 
-    /** Handle one line of data, add one value for all columns. */
+    /** Handle one line of data, add one value for all columns.
+     * @param line the line to parse
+     */
     private void handleDataLine(String line) {
         String[] cols = line.split(SEPERATOR_CHAR);
 
@@ -209,6 +211,8 @@
         }
 
         try {
+            // The first value in a line like 12,9;4,3;4,5 is the station, later
+            // real values.
             Double station = nf.parse(cols[0]).doubleValue();
 
             for (int i = 0; i < columns.length; i++) {
@@ -221,13 +225,15 @@
 
                 String value = cols[idx];
 
-                try {
-                    columns[i].addColumnValue(
-                        new BigDecimal(station),
-                        new BigDecimal(nf.parse(value).doubleValue()));
-                }
-                catch (ParseException pe) {
-                    log.warn("Could not parse value: '" + value + "'");
+                if (value != null && !value.equals("")) {
+                    try {
+                        columns[i].addColumnValue(
+                            new BigDecimal(station),
+                            new BigDecimal(nf.parse(value).doubleValue()));
+                    }
+                    catch (ParseException pe) {
+                        log.warn("Could not parse value: '" + value + "'");
+                    }
                 }
             }
         }


More information about the Dive4elements-commits mailing list