Mercurial > dive4elements > river
comparison backend/src/main/java/org/dive4elements/river/importer/parsers/AbstractSedimentLoadParser.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 |
---|---|
22 import org.apache.log4j.Logger; | 22 import org.apache.log4j.Logger; |
23 | 23 |
24 import org.dive4elements.river.importer.ImporterSession; | 24 import org.dive4elements.river.importer.ImporterSession; |
25 import org.dive4elements.river.importer.ImportGrainFraction; | 25 import org.dive4elements.river.importer.ImportGrainFraction; |
26 import org.dive4elements.river.importer.ImportTimeInterval; | 26 import org.dive4elements.river.importer.ImportTimeInterval; |
27 import org.dive4elements.river.importer.ImportUnit; | |
28 | 27 |
29 import org.dive4elements.river.model.GrainFraction; | 28 import org.dive4elements.river.model.GrainFraction; |
30 | 29 |
31 import org.dive4elements.river.utils.DateUtil; | 30 import org.dive4elements.river.utils.DateUtil; |
32 import org.dive4elements.river.utils.EpsilonComparator; | 31 import org.dive4elements.river.utils.EpsilonComparator; |
50 public static final Pattern META_FRACTION = | 49 public static final Pattern META_FRACTION = |
51 Pattern.compile("^Fraktion: (.*)"); | 50 Pattern.compile("^Fraktion: (.*)"); |
52 | 51 |
53 public static final Pattern META_FRACTION_NAME = | 52 public static final Pattern META_FRACTION_NAME = |
54 Pattern.compile("^Fraktionsname: (.*)"); | 53 Pattern.compile("^Fraktionsname: (.*)"); |
55 | |
56 public static final Pattern META_UNIT = | |
57 Pattern.compile("^Einheit: \\[(.*)\\].*"); | |
58 | 54 |
59 public static final Pattern META_COLUMN_NAMES = | 55 public static final Pattern META_COLUMN_NAMES = |
60 Pattern.compile("^Fluss-km.*"); | 56 Pattern.compile("^Fluss-km.*"); |
61 | 57 |
62 public static final Pattern META_GRAIN_SIZE = | 58 public static final Pattern META_GRAIN_SIZE = |
67 | 63 |
68 /** Initialize SedimentLoadLSs from columns, set the kind | 64 /** Initialize SedimentLoadLSs from columns, set the kind |
69 * with respect to file location (offical epoch or not?) */ | 65 * with respect to file location (offical epoch or not?) */ |
70 protected abstract void initializeSedimentLoads(); | 66 protected abstract void initializeSedimentLoads(); |
71 | 67 |
68 protected abstract void handleMetaLine(String line) | |
69 throws LineParserException; | |
70 | |
72 | 71 |
73 protected ImportGrainFraction grainFraction; | 72 protected ImportGrainFraction grainFraction; |
74 | |
75 protected ImportUnit unit; | |
76 | 73 |
77 protected String description; | 74 protected String description; |
78 | 75 |
79 protected String[] columnNames; | 76 protected String[] columnNames; |
80 | 77 |
97 handleMetaLine(stripMetaLine(line)); | 94 handleMetaLine(stripMetaLine(line)); |
98 } | 95 } |
99 else { | 96 else { |
100 handleDataLine(line); | 97 handleDataLine(line); |
101 } | 98 } |
102 } | |
103 | |
104 | |
105 protected void handleMetaLine(String line) throws LineParserException { | |
106 if (handleMetaUnit(line)) { | |
107 return; | |
108 } | |
109 if (handleMetaFraction(line)) { | |
110 return; | |
111 } | |
112 if (handleMetaFractionName(line)) { | |
113 return; | |
114 } | |
115 if (handleColumnNames(line)) { | |
116 return; | |
117 } | |
118 log.warn("ASLP: Unknown meta line: '" + line + "'"); | |
119 } | |
120 | |
121 | |
122 protected boolean handleMetaUnit(String line) { | |
123 Matcher m = META_UNIT.matcher(line); | |
124 | |
125 if (m.matches()) { | |
126 unit = new ImportUnit(m.group(1)); | |
127 return true; | |
128 } | |
129 | |
130 return false; | |
131 } | 99 } |
132 | 100 |
133 | 101 |
134 public boolean handleMetaFraction(String line) { | 102 public boolean handleMetaFraction(String line) { |
135 Matcher m = META_FRACTION.matcher(line); | 103 Matcher m = META_FRACTION.matcher(line); |