Mercurial > dive4elements > river
comparison flys-backend/src/main/java/de/intevation/flys/importer/parsers/SedimentYieldParser.java @ 5184:e8e092c00791
use pattern matching for grain fraction in SedimentYieldParser
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Thu, 07 Mar 2013 11:20:52 +0100 |
parents | 1c5370683769 |
children | 8e66a200a0b9 |
comparison
equal
deleted
inserted
replaced
5182:8aac391871f9 | 5184:e8e092c00791 |
---|---|
31 | 31 |
32 | 32 |
33 public static final String FRAKTION_START = "Fraktion:"; | 33 public static final String FRAKTION_START = "Fraktion:"; |
34 | 34 |
35 public static final String FRACTION_COARSE_STR = | 35 public static final String FRACTION_COARSE_STR = |
36 "_Grobkorn.csv"; | 36 ".*Grobkorn.*"; |
37 | 37 |
38 public static final String FRACTION_FINE_MIDDLE_STR = | 38 public static final String FRACTION_FINE_MIDDLE_STR = |
39 "_Fein-Mittel-Kies.csv"; | 39 ".*Fein-Mittel-Kies.*"; |
40 | 40 |
41 public static final String FRACTION_SAND = | 41 public static final String FRACTION_SAND = |
42 "_Sand.csv"; | 42 ".*Sand.*"; |
43 | 43 |
44 public static final String FRACTION_SUSP_SAND = | 44 public static final String FRACTION_SUSP_SAND = |
45 "_susp_Sand.csv"; | 45 ".*susp_Sand.*"; |
46 | 46 |
47 public static final String FRACTION_SUSP_SAND_BED = | 47 public static final String FRACTION_SUSP_SAND_BED = |
48 "_bettbild_Anteil_susp_Sand.csv"; | 48 ".*bettbild_Anteil_susp_Sand.*"; |
49 | 49 |
50 public static final String FRACTION_SUSP_SAND_BED_EPOCH = | 50 public static final String FRACTION_SUSP_SAND_BED_EPOCH = |
51 "_susp_Sand_bettbildAnteil.csv"; | 51 ".*susp_Sand_bettbildAnteil.*"; |
52 | 52 |
53 public static final String FRACTION_SUSPENDED_SEDIMENT = | 53 public static final String FRACTION_SUSPENDED_SEDIMENT = |
54 "_Schwebstoff.csv"; | 54 ".*Schwebstoff.*"; |
55 | 55 |
56 public static final String FRACTION_TOTAL = | 56 public static final String FRACTION_TOTAL = |
57 "_gesamt.csv"; | 57 ".*gesamt.*"; |
58 | 58 |
59 | 59 |
60 public static final Pattern TIMEINTERVAL_SINGLE = | 60 public static final Pattern TIMEINTERVAL_SINGLE = |
61 Pattern.compile("\\D*([0-9]+?)\\D*"); | 61 Pattern.compile("\\D*([0-9]+?)\\D*"); |
62 | 62 |
355 catch (ParseException pe) { | 355 catch (ParseException pe) { |
356 log.warn("SYP: Error while parsing ranges of: '" + gfStr + "'"); | 356 log.warn("SYP: Error while parsing ranges of: '" + gfStr + "'"); |
357 } | 357 } |
358 } | 358 } |
359 | 359 |
360 log.warn("SYP: Unknow grain fraction: '" + gfStr + "'"); | 360 log.warn("SYP: Unknown grain fraction: '" + gfStr + "'"); |
361 | 361 |
362 return null; | 362 return null; |
363 } | 363 } |
364 | 364 |
365 | 365 |
366 public static String getGrainFractionTypeName(String filename) { | 366 public static String getGrainFractionTypeName(String filename) { |
367 if (filename.endsWith(FRACTION_COARSE_STR)) { | 367 if (Pattern.matches(FRACTION_COARSE_STR, filename)) { |
368 return GrainFraction.COARSE; | 368 return GrainFraction.COARSE; |
369 } | 369 } |
370 else if (filename.endsWith(FRACTION_FINE_MIDDLE_STR)) { | 370 else if (Pattern.matches(FRACTION_FINE_MIDDLE_STR, filename)) { |
371 return GrainFraction.FINE_MIDDLE; | 371 return GrainFraction.FINE_MIDDLE; |
372 } | 372 } |
373 else if (filename.endsWith(FRACTION_SAND) && | 373 else if (Pattern.matches(FRACTION_SUSP_SAND_BED, filename) || |
374 !filename.endsWith(FRACTION_SUSP_SAND)) { | 374 Pattern.matches(FRACTION_SUSP_SAND_BED_EPOCH, filename)) { |
375 return GrainFraction.SUSP_SAND_BED; | |
376 } | |
377 else if (Pattern.matches(FRACTION_SUSP_SAND, filename)) { | |
378 return GrainFraction.SUSP_SAND; | |
379 } | |
380 else if (Pattern.matches(FRACTION_SAND, filename)) { | |
375 return GrainFraction.SAND; | 381 return GrainFraction.SAND; |
376 } | 382 } |
377 else if (filename.endsWith(FRACTION_SUSP_SAND) && | 383 else if (Pattern.matches(FRACTION_SUSPENDED_SEDIMENT, filename)) { |
378 !filename.endsWith(FRACTION_SUSP_SAND_BED)) { | |
379 return GrainFraction.SUSP_SAND; | |
380 } | |
381 else if (filename.endsWith(FRACTION_SUSP_SAND_BED) || | |
382 filename.endsWith(FRACTION_SUSP_SAND_BED_EPOCH)) { | |
383 return GrainFraction.SUSP_SAND_BED; | |
384 } | |
385 else if (filename.endsWith(FRACTION_SUSPENDED_SEDIMENT)) { | |
386 return GrainFraction.SUSPENDED_SEDIMENT; | 384 return GrainFraction.SUSPENDED_SEDIMENT; |
387 } | 385 } |
388 else if (filename.endsWith(FRACTION_TOTAL)) { | 386 else if (Pattern.matches(FRACTION_TOTAL, filename)) { |
389 return GrainFraction.TOTAL; | 387 return GrainFraction.TOTAL; |
390 } | 388 } |
391 else { | 389 else { |
392 log.warn("SYP: Unknown grain fraction '" + filename + "'"); | 390 log.warn("SYP: Unknown grain fraction '" + filename + "'"); |
393 return "unknown"; | 391 return "unknown"; |