annotate backend/src/main/java/org/dive4elements/river/importer/parsers/AbstractSedimentLoadParser.java @ 8856:5e38e2924c07 3.2.x

Fix code style.
author Tom Gottfried <tom@intevation.de>
date Thu, 18 Jan 2018 20:12:01 +0100
parents 7bc675e4e6e0
children 0a5239a1e46e
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.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
18 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
19
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 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
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.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
23 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
24 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
25
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.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
27
8187
3bb1c62ad732 Moved package org.dive4elements.river.utils to org.dive4elements.river.backend.utils.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8081
diff changeset
28 import org.dive4elements.river.backend.utils.DateUtil;
3bb1c62ad732 Moved package org.dive4elements.river.utils to org.dive4elements.river.backend.utils.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8081
diff changeset
29 import org.dive4elements.river.backend.utils.EpsilonComparator;
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
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 /** 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
32 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
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 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
35 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
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
8856
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8491
diff changeset
38 public static final NumberFormat nf = NumberFormat.getInstance(
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8491
diff changeset
39 DEFAULT_LOCALE);
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
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
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 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
43 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
44
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 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
46 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
47
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 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
49 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
50
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 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
52 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
53
8059
bde5f5ec7c72 SCHEMA CHANGE and Importer: get time intervals of SQ-relations from metalines in sediment load files.
Tom Gottfried <tom@intevation.de>
parents: 8056
diff changeset
54 public static final Pattern META_SQ_TIMEINTERVAL =
bde5f5ec7c72 SCHEMA CHANGE and Importer: get time intervals of SQ-relations from metalines in sediment load files.
Tom Gottfried <tom@intevation.de>
parents: 8056
diff changeset
55 Pattern.compile("^S-Q-Beziehung: (.*)");
bde5f5ec7c72 SCHEMA CHANGE and Importer: get time intervals of SQ-relations from metalines in sediment load files.
Tom Gottfried <tom@intevation.de>
parents: 8056
diff changeset
56
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
57 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
58 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
59
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 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
61 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
62
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
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 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
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 /** 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
67 * 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
68 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
69
8056
d86cc6a17b7a Importer: Import sediment load at measurement stations.
Tom Gottfried <tom@intevation.de>
parents: 8043
diff changeset
70 protected abstract void handleMetaLine(String line)
d86cc6a17b7a Importer: Import sediment load at measurement stations.
Tom Gottfried <tom@intevation.de>
parents: 8043
diff changeset
71 throws LineParserException;
d86cc6a17b7a Importer: Import sediment load at measurement stations.
Tom Gottfried <tom@intevation.de>
parents: 8043
diff changeset
72
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
73
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 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
75
8059
bde5f5ec7c72 SCHEMA CHANGE and Importer: get time intervals of SQ-relations from metalines in sediment load files.
Tom Gottfried <tom@intevation.de>
parents: 8056
diff changeset
76 protected ImportTimeInterval sqTimeInterval;
bde5f5ec7c72 SCHEMA CHANGE and Importer: get time intervals of SQ-relations from metalines in sediment load files.
Tom Gottfried <tom@intevation.de>
parents: 8056
diff changeset
77
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
78 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
79
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 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
81
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 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
83
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 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
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
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 @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
88 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
89 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
90
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 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
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
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 @Override
8856
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8491
diff changeset
96 protected void handleLine(int lineNum, String line)
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8491
diff changeset
97 throws LineParserException {
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
98 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
99 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
100 }
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 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
102 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
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
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
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 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
108 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
109
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 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
111 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
112
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 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
114 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
115 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
116 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
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 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
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 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
122 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
123
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
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 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
127 }
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
8856
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8491
diff changeset
130 public boolean handleMetaFractionName(String line)
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8491
diff changeset
131 throws LineParserException {
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
132 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
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 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
135 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
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
8856
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8491
diff changeset
138 GrainFraction gf = ImporterSession.getInstance()
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8491
diff changeset
139 .getGrainFraction(name);
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
140
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 (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
142
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 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
144 // 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
145 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
146 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
147 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
148
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 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
150 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
151 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
152 gf.getUpper()) != 0) {
8856
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8491
diff changeset
153 log.warn(
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8491
diff changeset
154 "ASLP: Invalid grain size for grain fraction '"
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8491
diff changeset
155 + name + "'. Ignored.");
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
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 }
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 catch (ParseException pe) {
8856
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8491
diff changeset
159 log.warn("ASLP: Could not parse grain-size interval. "
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8491
diff changeset
160 + "Ignored.");
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
161 }
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 = 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
165 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
166 }
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
8491
7bc675e4e6e0 Remove trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8187
diff changeset
168 throw new LineParserException("ASLP: Unknown grain fraction: '" +
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
169 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
170 }
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
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 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
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
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
8059
bde5f5ec7c72 SCHEMA CHANGE and Importer: get time intervals of SQ-relations from metalines in sediment load files.
Tom Gottfried <tom@intevation.de>
parents: 8056
diff changeset
176 public boolean handleMetaSQTimeInterval(String line) {
bde5f5ec7c72 SCHEMA CHANGE and Importer: get time intervals of SQ-relations from metalines in sediment load files.
Tom Gottfried <tom@intevation.de>
parents: 8056
diff changeset
177 Matcher m = META_SQ_TIMEINTERVAL.matcher(line);
bde5f5ec7c72 SCHEMA CHANGE and Importer: get time intervals of SQ-relations from metalines in sediment load files.
Tom Gottfried <tom@intevation.de>
parents: 8056
diff changeset
178
bde5f5ec7c72 SCHEMA CHANGE and Importer: get time intervals of SQ-relations from metalines in sediment load files.
Tom Gottfried <tom@intevation.de>
parents: 8056
diff changeset
179 if (m.matches()) {
bde5f5ec7c72 SCHEMA CHANGE and Importer: get time intervals of SQ-relations from metalines in sediment load files.
Tom Gottfried <tom@intevation.de>
parents: 8056
diff changeset
180 String interval = m.group(1);
bde5f5ec7c72 SCHEMA CHANGE and Importer: get time intervals of SQ-relations from metalines in sediment load files.
Tom Gottfried <tom@intevation.de>
parents: 8056
diff changeset
181
bde5f5ec7c72 SCHEMA CHANGE and Importer: get time intervals of SQ-relations from metalines in sediment load files.
Tom Gottfried <tom@intevation.de>
parents: 8056
diff changeset
182 try {
bde5f5ec7c72 SCHEMA CHANGE and Importer: get time intervals of SQ-relations from metalines in sediment load files.
Tom Gottfried <tom@intevation.de>
parents: 8056
diff changeset
183 Matcher a = TIMEINTERVAL_EPOCH.matcher(interval);
bde5f5ec7c72 SCHEMA CHANGE and Importer: get time intervals of SQ-relations from metalines in sediment load files.
Tom Gottfried <tom@intevation.de>
parents: 8056
diff changeset
184 if (a.matches()) {
bde5f5ec7c72 SCHEMA CHANGE and Importer: get time intervals of SQ-relations from metalines in sediment load files.
Tom Gottfried <tom@intevation.de>
parents: 8056
diff changeset
185 int yearA = nf.parse(a.group(1)).intValue();
bde5f5ec7c72 SCHEMA CHANGE and Importer: get time intervals of SQ-relations from metalines in sediment load files.
Tom Gottfried <tom@intevation.de>
parents: 8056
diff changeset
186 int yearB = nf.parse(a.group(2)).intValue();
bde5f5ec7c72 SCHEMA CHANGE and Importer: get time intervals of SQ-relations from metalines in sediment load files.
Tom Gottfried <tom@intevation.de>
parents: 8056
diff changeset
187
bde5f5ec7c72 SCHEMA CHANGE and Importer: get time intervals of SQ-relations from metalines in sediment load files.
Tom Gottfried <tom@intevation.de>
parents: 8056
diff changeset
188 sqTimeInterval = new ImportTimeInterval(
bde5f5ec7c72 SCHEMA CHANGE and Importer: get time intervals of SQ-relations from metalines in sediment load files.
Tom Gottfried <tom@intevation.de>
parents: 8056
diff changeset
189 DateUtil.getStartDateFromYear(yearA),
bde5f5ec7c72 SCHEMA CHANGE and Importer: get time intervals of SQ-relations from metalines in sediment load files.
Tom Gottfried <tom@intevation.de>
parents: 8056
diff changeset
190 DateUtil.getEndDateFromYear(yearB)
bde5f5ec7c72 SCHEMA CHANGE and Importer: get time intervals of SQ-relations from metalines in sediment load files.
Tom Gottfried <tom@intevation.de>
parents: 8056
diff changeset
191 );
bde5f5ec7c72 SCHEMA CHANGE and Importer: get time intervals of SQ-relations from metalines in sediment load files.
Tom Gottfried <tom@intevation.de>
parents: 8056
diff changeset
192 }
bde5f5ec7c72 SCHEMA CHANGE and Importer: get time intervals of SQ-relations from metalines in sediment load files.
Tom Gottfried <tom@intevation.de>
parents: 8056
diff changeset
193 else {
bde5f5ec7c72 SCHEMA CHANGE and Importer: get time intervals of SQ-relations from metalines in sediment load files.
Tom Gottfried <tom@intevation.de>
parents: 8056
diff changeset
194 log.warn("ASLP: Unknown SQ-time string: '" + interval +
bde5f5ec7c72 SCHEMA CHANGE and Importer: get time intervals of SQ-relations from metalines in sediment load files.
Tom Gottfried <tom@intevation.de>
parents: 8056
diff changeset
195 "'. Ignored.");
bde5f5ec7c72 SCHEMA CHANGE and Importer: get time intervals of SQ-relations from metalines in sediment load files.
Tom Gottfried <tom@intevation.de>
parents: 8056
diff changeset
196 }
bde5f5ec7c72 SCHEMA CHANGE and Importer: get time intervals of SQ-relations from metalines in sediment load files.
Tom Gottfried <tom@intevation.de>
parents: 8056
diff changeset
197 }
bde5f5ec7c72 SCHEMA CHANGE and Importer: get time intervals of SQ-relations from metalines in sediment load files.
Tom Gottfried <tom@intevation.de>
parents: 8056
diff changeset
198 catch (ParseException pe) {
bde5f5ec7c72 SCHEMA CHANGE and Importer: get time intervals of SQ-relations from metalines in sediment load files.
Tom Gottfried <tom@intevation.de>
parents: 8056
diff changeset
199 log.error("ASLP: Could not parse SQ-time string: '" +
bde5f5ec7c72 SCHEMA CHANGE and Importer: get time intervals of SQ-relations from metalines in sediment load files.
Tom Gottfried <tom@intevation.de>
parents: 8056
diff changeset
200 interval + "'. Ignored.", pe);
bde5f5ec7c72 SCHEMA CHANGE and Importer: get time intervals of SQ-relations from metalines in sediment load files.
Tom Gottfried <tom@intevation.de>
parents: 8056
diff changeset
201 }
bde5f5ec7c72 SCHEMA CHANGE and Importer: get time intervals of SQ-relations from metalines in sediment load files.
Tom Gottfried <tom@intevation.de>
parents: 8056
diff changeset
202
bde5f5ec7c72 SCHEMA CHANGE and Importer: get time intervals of SQ-relations from metalines in sediment load files.
Tom Gottfried <tom@intevation.de>
parents: 8056
diff changeset
203 return true;
bde5f5ec7c72 SCHEMA CHANGE and Importer: get time intervals of SQ-relations from metalines in sediment load files.
Tom Gottfried <tom@intevation.de>
parents: 8056
diff changeset
204
bde5f5ec7c72 SCHEMA CHANGE and Importer: get time intervals of SQ-relations from metalines in sediment load files.
Tom Gottfried <tom@intevation.de>
parents: 8056
diff changeset
205 }
bde5f5ec7c72 SCHEMA CHANGE and Importer: get time intervals of SQ-relations from metalines in sediment load files.
Tom Gottfried <tom@intevation.de>
parents: 8056
diff changeset
206
bde5f5ec7c72 SCHEMA CHANGE and Importer: get time intervals of SQ-relations from metalines in sediment load files.
Tom Gottfried <tom@intevation.de>
parents: 8056
diff changeset
207 return false;
bde5f5ec7c72 SCHEMA CHANGE and Importer: get time intervals of SQ-relations from metalines in sediment load files.
Tom Gottfried <tom@intevation.de>
parents: 8056
diff changeset
208 }
bde5f5ec7c72 SCHEMA CHANGE and Importer: get time intervals of SQ-relations from metalines in sediment load files.
Tom Gottfried <tom@intevation.de>
parents: 8056
diff changeset
209
bde5f5ec7c72 SCHEMA CHANGE and Importer: get time intervals of SQ-relations from metalines in sediment load files.
Tom Gottfried <tom@intevation.de>
parents: 8056
diff changeset
210
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
211 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
212 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
213
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 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
215 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
216
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 // '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
218 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
219 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
220 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
221 }
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
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 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
224
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 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
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
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 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
229 }
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 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
233 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
234 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
235 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
236 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
237 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
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 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
240 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
241 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
242 );
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 }
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 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
246 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
247 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
248
8856
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8491
diff changeset
249 return new ImportTimeInterval(
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8491
diff changeset
250 DateUtil.getStartDateFromYear(year));
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
251 }
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
252
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
253 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
254 }
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
255 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
256 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
257 }
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
258
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
259 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
260 }
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
261
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
262 }
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
263 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org