changeset 5925:59f6a47822a4

PRFParser: Ignore skip-lines field, simplifies code a bit.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Wed, 08 May 2013 15:04:04 +0200 (2013-05-08)
parents 454b7b455cb6
children 2604106173b6
files backend/src/main/java/org/dive4elements/river/importer/parsers/PRFParser.java
diffstat 1 files changed, 6 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- 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

http://dive4elements.wald.intevation.org