annotate backend/src/main/java/org/dive4elements/river/importer/parsers/AbstractSedimentLoadParser.java @ 8059:bde5f5ec7c72

SCHEMA CHANGE and Importer: get time intervals of SQ-relations from metalines in sediment load files.
author Tom Gottfried <tom@intevation.de>
date Fri, 18 Jul 2014 18:01:49 +0200
parents d86cc6a17b7a
children 3ae11daff343
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
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and 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 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
29
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and 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 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
31 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
32
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and 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 /** 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
34 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
35
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and 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 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
37 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
38
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and 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 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
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
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and 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 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
44 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
45
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and 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 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
47 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
48
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and 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 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
50 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
51
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and 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 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
53 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
54
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
55 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
56 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
57
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
58 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
59 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
60
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and 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 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
62 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
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
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and 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 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
66
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and 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 /** 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
68 * 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
69 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
70
8056
d86cc6a17b7a Importer: Import sediment load at measurement stations.
Tom Gottfried <tom@intevation.de>
parents: 8043
diff changeset
71 protected abstract void handleMetaLine(String line)
d86cc6a17b7a Importer: Import sediment load at measurement stations.
Tom Gottfried <tom@intevation.de>
parents: 8043
diff changeset
72 throws LineParserException;
d86cc6a17b7a Importer: Import sediment load at measurement stations.
Tom Gottfried <tom@intevation.de>
parents: 8043
diff changeset
73
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
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 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
76
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
77 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
78
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
79 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
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 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
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 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
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 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
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
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and 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 @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
89 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
90 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
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 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
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
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and 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 @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
97 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
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
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and 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 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
131 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
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 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
134 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
135
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and 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 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
138
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and 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 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
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 (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
142 // 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
143 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
144 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
145 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
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 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
148 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
149 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
150 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
151 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
152 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
153 }
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and 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 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
156 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
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 }
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and 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 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
161 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
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 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
165 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
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
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and 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 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
169 }
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and 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
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
172 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
173 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
174
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
175 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
176 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
177
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 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
179 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
180 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
181 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
182 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
183
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 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
185 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
186 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
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 }
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 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
190 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
191 "'. 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
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 }
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 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
195 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
196 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
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
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 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
200
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 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
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
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
207 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
208 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
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 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
211 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
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 // '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
214 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
215 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
216 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
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 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
220
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and 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 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
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
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and 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 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
225 }
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and 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 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
229 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
230 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
231 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
232 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
233 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
234
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and 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 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
236 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
237 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
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
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and 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 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
242 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
243 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
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 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
246 }
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and 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 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
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 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
251 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
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
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and 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 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
255 }
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and 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
bd0dea643440 Divide SedimentLoadLSParser into AbstractSedimentLoadParser and 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 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org