[Dive4elements-commits] [PATCH 2 of 2] PRFParser: Ignore skip-lines field, simplifies code a bit

Wald Commits scm-commit at wald.intevation.org
Wed May 8 14:57:11 CEST 2013


# HG changeset patch
# User Felix Wolfsteller <felix.wolfsteller at intevation.de>
# Date 1368018244 -7200
# Node ID 59f6a47822a4a38ec6ef00f2a1be67fcc8315124
# Parent  454b7b455cb6d80e1b352ed0de7be3040693b52c
PRFParser: Ignore skip-lines field, simplifies code a bit.

diff -r 454b7b455cb6 -r 59f6a47822a4 backend/src/main/java/org/dive4elements/river/importer/parsers/PRFParser.java
--- a/backend/src/main/java/org/dive4elements/river/importer/parsers/PRFParser.java	Wed May 08 14:58:16 2013 +0200
+++ b/backend/src/main/java/org/dive4elements/river/importer/parsers/PRFParser.java	Wed May 08 15:04:04 2013 +0200
@@ -85,10 +85,8 @@
         /**
          * @param kmData where data points will be added to.
          * @param line Line to parse.
-         * @return -1 at invalid lines, 1 if maxRepetitions values have been
-         *         read, 0 otherwise.
          */
-        public int extractData(String line, List<XY> kmData) {
+        public void extractData(String line, List<XY> kmData) {
             int L = line.length();
             if (L <= deleteChars) {
                 return -1;
@@ -117,8 +115,9 @@
                     y = Double.parseDouble(second);
                 }
                 catch (NumberFormatException nfe) {
-                    // broken line -> substract from dataset skip
-                    return -1;
+                    // "Dummy" line to separate datasets, or missing values.
+                    log.debug("PRFParser: Broken line: " + line);
+                    return;
                 }
 
                 if (first.indexOf('.') < 0) {
@@ -142,7 +141,7 @@
                 pos += firstIntegerPlaces + secondIntegerPlaces;
             }
 
-            return rep == maxRepetitions ? 1 : 0;
+            return;
         }
     } // class DataFormat
 
@@ -343,13 +342,7 @@
                 return false;
             }
 
-            int skip = lineSkipCount;
-
             while ((line = in.readLine()) != null) {
-                if (skip > 0) {
-                    --skip;
-                    continue;
-                }
                 double km;
                 try {
                     km = kmFormat.extractKm(line);
@@ -369,10 +362,7 @@
                     data.put(station, kmData);
                 }
 
-                int c = dataFormat.extractData(line, kmData);
-                if (c < 1) {
-                    skip = lineSkipCount + c;
-                }
+                dataFormat.extractData(line, kmData);
             }
 
             // sort all the lists by x and index


More information about the Dive4elements-commits mailing list