Mercurial > dive4elements > river
comparison flys-backend/src/main/java/de/intevation/flys/importer/parsers/SedimentYieldParser.java @ 5277:2435968b30b1
Use pattern matching for grain fraction in SedimentYieldParser
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Thu, 07 Mar 2013 09:46:11 +0100 |
parents | 1c5370683769 |
children | 8e66a200a0b9 |
comparison
equal
deleted
inserted
replaced
5177:08c5e3a646dc | 5277:2435968b30b1 |
---|---|
30 public static final NumberFormat nf = NumberFormat.getInstance(DEFAULT_LOCALE); | 30 public static final NumberFormat nf = NumberFormat.getInstance(DEFAULT_LOCALE); |
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 Pattern FRACTION_COARSE_STR = |
36 "_Grobkorn.csv"; | 36 Pattern.compile(".*Grobkorn.*"); |
37 | 37 |
38 public static final String FRACTION_FINE_MIDDLE_STR = | 38 public static final Pattern FRACTION_FINE_MIDDLE_STR = |
39 "_Fein-Mittel-Kies.csv"; | 39 Pattern.compile(".*Fein-Mittel-Kies.*"); |
40 | 40 |
41 public static final String FRACTION_SAND = | 41 public static final Pattern FRACTION_SUSP_SAND_BED = |
42 "_Sand.csv"; | 42 Pattern.compile(".*bettbild_Anteil_susp_Sand.*"); |
43 | 43 |
44 public static final String FRACTION_SUSP_SAND = | 44 public static final Pattern FRACTION_SUSP_SAND_BED_EPOCH = |
45 "_susp_Sand.csv"; | 45 Pattern.compile(".*susp_Sand_bettbildAnteil.*"); |
46 | 46 |
47 public static final String FRACTION_SUSP_SAND_BED = | 47 public static final Pattern FRACTION_SUSP_SAND = |
48 "_bettbild_Anteil_susp_Sand.csv"; | 48 Pattern.compile(".*susp_Sand.*"); |
49 | 49 |
50 public static final String FRACTION_SUSP_SAND_BED_EPOCH = | 50 public static final Pattern FRACTION_SAND = |
51 "_susp_Sand_bettbildAnteil.csv"; | 51 Pattern.compile(".*Sand.*"); |
52 | 52 |
53 public static final String FRACTION_SUSPENDED_SEDIMENT = | 53 public static final Pattern FRACTION_SUSPENDED_SEDIMENT = |
54 "_Schwebstoff.csv"; | 54 Pattern.compile(".*Schwebstoff.*"); |
55 | 55 |
56 public static final String FRACTION_TOTAL = | 56 public static final Pattern FRACTION_TOTAL = |
57 "_gesamt.csv"; | 57 Pattern.compile(".*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 |
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 (filename.matches(FRACTION_COARSE_STR)) { |
368 return GrainFraction.COARSE; | 368 return GrainFraction.COARSE; |
369 } | 369 } |
370 else if (filename.endsWith(FRACTION_FINE_MIDDLE_STR)) { | 370 else if (filename.matches(FRACTION_FINE_MIDDLE_STR)) { |
371 return GrainFraction.FINE_MIDDLE; | 371 return GrainFraction.FINE_MIDDLE; |
372 } | 372 } |
373 else if (filename.endsWith(FRACTION_SAND) && | 373 else if (filename.matches(FRACTION_SUSP_SAND_BED) || |
374 !filename.endsWith(FRACTION_SUSP_SAND)) { | 374 filename.matches(FRACTION_SUSP_SAND_BED_EPOCH)) { |
375 return GrainFraction.SUSP_SAND_BED; | |
376 } | |
377 else if (filename.matches(FRACTION_SUSP_SAND) { | |
378 return GrainFraction.SUSP_SAND; | |
379 } | |
380 else if (filename.matches(FRACTION_SAND) { | |
375 return GrainFraction.SAND; | 381 return GrainFraction.SAND; |
376 } | 382 } |
377 else if (filename.endsWith(FRACTION_SUSP_SAND) && | 383 else if (filename.matches(FRACTION_SUSPENDED_SEDIMENT)) { |
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 (filename.matches(FRACTION_TOTAL)) { |
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"; |