Mercurial > dive4elements > river
comparison backend/src/main/java/org/dive4elements/river/importer/parsers/BedHeightParser.java @ 8989:2693bfaf503d
Fixed several BigDecimal(double) creations by BigDecimal(String) parsing to avoid unnecessary decimal digits
author | mschaefer |
---|---|
date | Mon, 09 Apr 2018 09:07:00 +0200 |
parents | a0a0a7f912ab |
children | 8aa7d9eaaa21 |
comparison
equal
deleted
inserted
replaced
8988:ae76f618d990 | 8989:2693bfaf503d |
---|---|
35 import org.dive4elements.river.importer.ImportLocationSystem; | 35 import org.dive4elements.river.importer.ImportLocationSystem; |
36 import org.dive4elements.river.importer.ImportRange; | 36 import org.dive4elements.river.importer.ImportRange; |
37 import org.dive4elements.river.importer.ImportTimeInterval; | 37 import org.dive4elements.river.importer.ImportTimeInterval; |
38 import org.dive4elements.river.importer.ImportUnit; | 38 import org.dive4elements.river.importer.ImportUnit; |
39 import org.dive4elements.river.importer.ImporterSession; | 39 import org.dive4elements.river.importer.ImporterSession; |
40 import org.dive4elements.river.importer.common.AbstractParser; | |
40 import org.dive4elements.river.model.BedHeightType; | 41 import org.dive4elements.river.model.BedHeightType; |
41 | 42 |
42 public class BedHeightParser { | 43 public class BedHeightParser { |
43 | 44 |
44 private static final Logger log = | 45 private static final Logger log = |
282 final Matcher m = META_RANGE.matcher(line); | 283 final Matcher m = META_RANGE.matcher(line); |
283 if (m.matches() && m.groupCount() >= 2) { | 284 if (m.matches() && m.groupCount() >= 2) { |
284 final String a = m.group(1).replace(";", "").trim(); | 285 final String a = m.group(1).replace(";", "").trim(); |
285 final String b = m.group(2).replace(";", "").trim(); | 286 final String b = m.group(2).replace(";", "").trim(); |
286 try { | 287 try { |
287 final BigDecimal lower = new BigDecimal(nf.parse(a).doubleValue()); | 288 final BigDecimal lower = AbstractParser.parseDecimal(a); |
288 final BigDecimal upper = new BigDecimal(nf.parse(b).doubleValue()); | 289 final BigDecimal upper = AbstractParser.parseDecimal(b); |
289 obj.setRange(new ImportRange(lower, upper)); | 290 obj.setRange(new ImportRange(lower, upper)); |
290 return true; | 291 return true; |
291 } | 292 } |
292 catch (final ParseException e) { | 293 catch (final Exception e) { |
293 log.warn("BHP: could not parse range", e); | 294 log.warn("BHP: could not parse range", e); |
294 } | 295 } |
295 } | 296 } |
296 return false; | 297 return false; |
297 } | 298 } |