Mercurial > dive4elements > river
comparison backend/src/main/java/org/dive4elements/river/importer/parsers/SedimentLoadLSParser.java @ 8056:d86cc6a17b7a
Importer: Import sediment load at measurement stations.
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Fri, 18 Jul 2014 15:37:26 +0200 |
parents | bd0dea643440 |
children | bde5f5ec7c72 |
comparison
equal
deleted
inserted
replaced
8055:cd35b76f1ef8 | 8056:d86cc6a17b7a |
---|---|
14 import java.text.NumberFormat; | 14 import java.text.NumberFormat; |
15 import java.text.ParseException; | 15 import java.text.ParseException; |
16 | 16 |
17 import java.util.ArrayList; | 17 import java.util.ArrayList; |
18 import java.util.List; | 18 import java.util.List; |
19 import java.util.regex.Matcher; | |
20 import java.util.regex.Pattern; | |
19 | 21 |
20 import org.apache.log4j.Logger; | 22 import org.apache.log4j.Logger; |
21 | 23 |
22 import org.dive4elements.river.importer.ImportGrainFraction; | 24 import org.dive4elements.river.importer.ImportGrainFraction; |
23 import org.dive4elements.river.importer.ImportSedimentLoadLS; | 25 import org.dive4elements.river.importer.ImportSedimentLoadLS; |
32 | 34 |
33 private static final Logger log = | 35 private static final Logger log = |
34 Logger.getLogger(SedimentLoadLSParser.class); | 36 Logger.getLogger(SedimentLoadLSParser.class); |
35 | 37 |
36 | 38 |
39 public static final Pattern META_UNIT = | |
40 Pattern.compile("^Einheit: \\[(.*)\\].*"); | |
41 | |
42 | |
37 protected List<ImportSedimentLoadLS> sedimentLoadLSs; | 43 protected List<ImportSedimentLoadLS> sedimentLoadLSs; |
38 | 44 |
39 protected ImportSedimentLoadLS[] current; | 45 protected ImportSedimentLoadLS[] current; |
46 | |
47 protected ImportUnit unit; | |
40 | 48 |
41 | 49 |
42 public SedimentLoadLSParser() { | 50 public SedimentLoadLSParser() { |
43 sedimentLoadLSs = new ArrayList<ImportSedimentLoadLS>(); | 51 sedimentLoadLSs = new ArrayList<ImportSedimentLoadLS>(); |
44 } | 52 } |
59 sedimentLoadLSs.add(isy); | 67 sedimentLoadLSs.add(isy); |
60 } | 68 } |
61 } | 69 } |
62 | 70 |
63 description = null; | 71 description = null; |
72 } | |
73 | |
74 | |
75 @Override | |
76 protected void handleMetaLine(String line) throws LineParserException { | |
77 if (handleMetaUnit(line)) { | |
78 return; | |
79 } | |
80 if (handleMetaFraction(line)) { | |
81 return; | |
82 } | |
83 if (handleMetaFractionName(line)) { | |
84 return; | |
85 } | |
86 if (handleColumnNames(line)) { | |
87 return; | |
88 } | |
89 log.warn("ASLP: Unknown meta line: '" + line + "'"); | |
90 } | |
91 | |
92 | |
93 protected boolean handleMetaUnit(String line) { | |
94 Matcher m = META_UNIT.matcher(line); | |
95 | |
96 if (m.matches()) { | |
97 unit = new ImportUnit(m.group(1)); | |
98 return true; | |
99 } | |
100 | |
101 return false; | |
64 } | 102 } |
65 | 103 |
66 | 104 |
67 @Override | 105 @Override |
68 protected void handleDataLine(String line) { | 106 protected void handleDataLine(String line) { |