annotate backend/src/main/java/org/dive4elements/river/importer/parsers/AbstractSedimentLoadParser.java @ 8043:bd0dea643440

Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
author Tom Gottfried <tom@intevation.de>
date Wed, 16 Jul 2014 19:11:31 +0200
parents
children d86cc6a17b7a
rev   line source
8043
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
2 * Software engineering by Intevation GmbH
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
3 *
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
4 * This file is Free Software under the GNU AGPL (>=v3)
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
6 * documentation coming with Dive4Elements River for details.
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
7 */
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
8
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
9 package org.dive4elements.river.importer.parsers;
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
10
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
11 import java.io.File;
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
12 import java.io.IOException;
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
13
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
14 import java.text.NumberFormat;
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
15 import java.text.ParseException;
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
16
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
17 import java.util.ArrayList;
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
18 import java.util.List;
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
19 import java.util.regex.Matcher;
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
20 import java.util.regex.Pattern;
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
21
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
22 import org.apache.log4j.Logger;
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
23
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
24 import org.dive4elements.river.importer.ImporterSession;
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
25 import org.dive4elements.river.importer.ImportGrainFraction;
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
26 import org.dive4elements.river.importer.ImportTimeInterval;
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
27 import org.dive4elements.river.importer.ImportUnit;
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
28
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
29 import org.dive4elements.river.model.GrainFraction;
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
30
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
31 import org.dive4elements.river.utils.DateUtil;
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
32 import org.dive4elements.river.utils.EpsilonComparator;
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
33
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
34 /** Parses sediment load files. */
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
35 public abstract class AbstractSedimentLoadParser extends LineParser {
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
36
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
37 private static final Logger log =
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
38 Logger.getLogger(AbstractSedimentLoadParser.class);
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
39
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
40
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
41 public static final NumberFormat nf = NumberFormat.getInstance(DEFAULT_LOCALE);
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
42
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
43
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
44 public static final Pattern TIMEINTERVAL_SINGLE =
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
45 Pattern.compile("\\D*([0-9]+?)\\D*");
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
46
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
47 public static final Pattern TIMEINTERVAL_EPOCH =
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
48 Pattern.compile("\\D*([0-9]+?)\\s*-\\s*([0-9]+?)\\D*");
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
49
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
50 public static final Pattern META_FRACTION =
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
51 Pattern.compile("^Fraktion: (.*)");
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
52
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
53 public static final Pattern META_FRACTION_NAME =
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
54 Pattern.compile("^Fraktionsname: (.*)");
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
55
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
56 public static final Pattern META_UNIT =
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
57 Pattern.compile("^Einheit: \\[(.*)\\].*");
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
58
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
59 public static final Pattern META_COLUMN_NAMES =
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
60 Pattern.compile("^Fluss-km.*");
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
61
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
62 public static final Pattern META_GRAIN_SIZE =
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
63 Pattern.compile("([0-9]*,*[0-9]+)-([0-9]*,*[0-9]+) *mm");
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
64
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
65
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
66 protected abstract void handleDataLine(String line);
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
67
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
68 /** Initialize SedimentLoadLSs from columns, set the kind
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
69 * with respect to file location (offical epoch or not?) */
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
70 protected abstract void initializeSedimentLoads();
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
71
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
72
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
73 protected ImportGrainFraction grainFraction;
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
74
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
75 protected ImportUnit unit;
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
76
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
77 protected String description;
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
78
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
79 protected String[] columnNames;
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
80
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
81 private String upper;
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
82
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
83 private String lower;
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
84
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
85
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
86 @Override
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
87 public void parse(File file) throws IOException {
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
88 description = file.getName();
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
89
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
90 super.parse(file);
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
91 }
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
92
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
93
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
94 @Override
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
95 protected void handleLine(int lineNum, String line) throws LineParserException {
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
96 if (line.startsWith(START_META_CHAR)) {
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
97 handleMetaLine(stripMetaLine(line));
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
98 }
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
99 else {
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
100 handleDataLine(line);
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
101 }
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
102 }
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
103
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
104
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
105 protected void handleMetaLine(String line) throws LineParserException {
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
106 if (handleMetaUnit(line)) {
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
107 return;
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
108 }
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
109 if (handleMetaFraction(line)) {
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
110 return;
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
111 }
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
112 if (handleMetaFractionName(line)) {
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
113 return;
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
114 }
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
115 if (handleColumnNames(line)) {
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
116 return;
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
117 }
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
118 log.warn("ASLP: Unknown meta line: '" + line + "'");
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
119 }
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
120
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
121
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
122 protected boolean handleMetaUnit(String line) {
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
123 Matcher m = META_UNIT.matcher(line);
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
124
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
125 if (m.matches()) {
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
126 unit = new ImportUnit(m.group(1));
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
127 return true;
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
128 }
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
129
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
130 return false;
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
131 }
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
132
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
133
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
134 public boolean handleMetaFraction(String line) {
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
135 Matcher m = META_FRACTION.matcher(line);
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
136
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
137 if (m.matches()) {
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
138 String interval = m.group(1);
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
139
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
140 Matcher sizes = META_GRAIN_SIZE.matcher(interval);
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
141 if (sizes.matches()) {
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
142 lower = sizes.group(1);
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
143 upper = sizes.group(2);
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
144
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
145 return true;
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
146 }
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
147
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
148 log.warn("ASLP: Unrecognized grain-size interval. Ignored.");
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
149 return true;
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
150
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
151 }
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
152
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
153 return false;
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
154 }
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
155
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
156
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
157 public boolean handleMetaFractionName(String line) throws LineParserException {
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
158 Matcher m = META_FRACTION_NAME.matcher(line);
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
159
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
160 if (m.matches()) {
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
161 String name = m.group(1);
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
162
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
163
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
164 GrainFraction gf = ImporterSession.getInstance().getGrainFraction(name);
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
165
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
166 if (gf != null) {
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
167
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
168 if (lower != null && upper != null) {
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
169 // Validate grain size interval
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
170 try {
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
171 Double lowval = nf.parse(lower).doubleValue();
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
172 Double upval = nf.parse(upper).doubleValue();
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
173
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
174 if (EpsilonComparator.CMP.compare(lowval,
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
175 gf.getLower()) != 0 ||
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
176 EpsilonComparator.CMP.compare(upval,
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
177 gf.getUpper()) != 0) {
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
178 log.warn("ASLP: Invalid grain size for grain fraction '" +
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
179 name + "'. Ignored.");
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
180 }
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
181 }
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
182 catch (ParseException pe) {
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
183 log.warn("ASLP: Could not parse grain-size interval. Ignored.");
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
184 }
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
185 }
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
186
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
187 grainFraction = new ImportGrainFraction(gf);
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
188 return true;
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
189 }
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
190
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
191 throw new LineParserException("ASLP: Unknown grain fraction: '" +
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
192 name + "'");
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
193 }
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
194
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
195 return false;
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
196 }
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
197
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
198
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
199 public boolean handleColumnNames(String line) throws LineParserException {
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
200 Matcher m = META_COLUMN_NAMES.matcher(line);
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
201
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
202 if (m.matches()) {
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
203 columnNames = line.split(SEPERATOR_CHAR);
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
204
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
205 // 'Fluss-km', 'Hinweise' and at least one data column required
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
206 if (columnNames.length < 3) {
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
207 throw new LineParserException("ASLP: missing columns in '" +
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
208 line + "'");
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
209 }
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
210
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
211 initializeSedimentLoads();
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
212
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
213 return true;
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
214 }
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
215
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
216 return false;
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
217 }
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
218
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
219
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
220 protected ImportTimeInterval getTimeInterval(String column) {
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
221 try {
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
222 Matcher a = TIMEINTERVAL_EPOCH.matcher(column);
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
223 if (a.matches()) {
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
224 int yearA = nf.parse(a.group(1)).intValue();
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
225 int yearB = nf.parse(a.group(2)).intValue();
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
226
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
227 return new ImportTimeInterval(
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
228 DateUtil.getStartDateFromYear(yearA),
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
229 DateUtil.getEndDateFromYear(yearB)
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
230 );
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
231 }
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
232
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
233 Matcher b = TIMEINTERVAL_SINGLE.matcher(column);
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
234 if (b.matches()) {
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
235 int year = nf.parse(b.group(1)).intValue();
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
236
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
237 return new ImportTimeInterval(DateUtil.getStartDateFromYear(year));
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
238 }
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
239
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
240 log.warn("ASLP: Unknown time interval string: '" + column + "'");
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
241 }
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
242 catch (ParseException pe) {
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
243 log.warn("ASLP: Could not parse years: " + column, pe);
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
244 }
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
245
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
246 return null;
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
247 }
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
248
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
249 }
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and SedimentLoadLSParser to be able to reuse code for a new SedimentLoadParser for data at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
250 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org