Mercurial > dive4elements > river
comparison backend/src/main/java/org/dive4elements/river/importer/parsers/SedimentDensityParser.java @ 8991:c43d8c1a4455
Parse via decimalformat instead of bigdecimal constructor (to cope with strings with chars after the actual number)
author | mschaefer |
---|---|
date | Tue, 10 Apr 2018 16:43:32 +0200 |
parents | 2693bfaf503d |
children |
comparison
equal
deleted
inserted
replaced
8990:07dcedddf839 | 8991:c43d8c1a4455 |
---|---|
10 | 10 |
11 import java.io.File; | 11 import java.io.File; |
12 import java.io.IOException; | 12 import java.io.IOException; |
13 import java.math.BigDecimal; | 13 import java.math.BigDecimal; |
14 import java.text.NumberFormat; | 14 import java.text.NumberFormat; |
15 import java.text.ParseException; | |
15 import java.util.ArrayList; | 16 import java.util.ArrayList; |
16 import java.util.List; | 17 import java.util.List; |
17 import java.util.regex.Matcher; | 18 import java.util.regex.Matcher; |
18 import java.util.regex.Pattern; | 19 import java.util.regex.Pattern; |
19 | 20 |
111 | 112 |
112 this.current.setDepth(depth); | 113 this.current.setDepth(depth); |
113 | 114 |
114 return true; | 115 return true; |
115 } | 116 } |
116 catch (final NumberFormatException pe) { | 117 catch (final ParseException pe) { |
117 log.warn("Unparseable numbers in: '" + line + "'"); | 118 log.warn("Unparseable numbers in: '" + line + "'"); |
118 } | 119 } |
119 } | 120 } |
120 else { | 121 else { |
121 log.debug("Meta line doesn't contain depth information: " + line); | 122 log.debug("Meta line doesn't contain depth information: " + line); |
157 density = AbstractParser.parseDecimal(vals[2]); | 158 density = AbstractParser.parseDecimal(vals[2]); |
158 if (!vals[1].isEmpty()) { | 159 if (!vals[1].isEmpty()) { |
159 shoreOffset = AbstractParser.parseDecimal(vals[1]); | 160 shoreOffset = AbstractParser.parseDecimal(vals[1]); |
160 } | 161 } |
161 } | 162 } |
162 catch (final NumberFormatException pe) { | 163 catch (final ParseException pe) { |
163 log.warn("Unparseable numbers in '" + line + "'"); | 164 log.warn("Unparseable numbers in '" + line + "'"); |
164 } | 165 } |
165 | 166 |
166 if (km == null || density == null) { | 167 if (km == null || density == null) { |
167 log.warn("SDP: No km nor density given. Skip line"); | 168 log.warn("SDP: No km nor density given. Skip line"); |
171 BigDecimal year = null; | 172 BigDecimal year = null; |
172 if (this.yearString != null) { | 173 if (this.yearString != null) { |
173 try { | 174 try { |
174 year = AbstractParser.parseDecimal(this.yearString); | 175 year = AbstractParser.parseDecimal(this.yearString); |
175 } | 176 } |
176 catch (final NumberFormatException pe) { | 177 catch (final ParseException pe) { |
177 log.warn("Unparseable year string"); | 178 log.warn("Unparseable year string"); |
178 } | 179 } |
179 } | 180 } |
180 | 181 |
181 this.current.addValue(new ImportSedimentDensityValue( | 182 this.current.addValue(new ImportSedimentDensityValue( |