[Dive4elements-commits] [PATCH 1 of 3] Use pattern matching for grain fraction in SedimentYieldParser
Wald Commits
scm-commit at wald.intevation.org
Wed Mar 13 19:08:24 CET 2013
# HG changeset patch
# User Tom Gottfried <tom at intevation.de>
# Date 1362645971 -3600
# Node ID 2435968b30b164812858d3dfa6d61c3bf2cbf497
# Parent 08c5e3a646dc789cd78b6dc8fc133af088866ec9
Use pattern matching for grain fraction in SedimentYieldParser
diff -r 08c5e3a646dc -r 2435968b30b1 flys-backend/src/main/java/de/intevation/flys/importer/parsers/SedimentYieldParser.java
--- a/flys-backend/src/main/java/de/intevation/flys/importer/parsers/SedimentYieldParser.java Wed Mar 06 16:28:04 2013 +0100
+++ b/flys-backend/src/main/java/de/intevation/flys/importer/parsers/SedimentYieldParser.java Thu Mar 07 09:46:11 2013 +0100
@@ -32,29 +32,29 @@
public static final String FRAKTION_START = "Fraktion:";
- public static final String FRACTION_COARSE_STR =
- "_Grobkorn.csv";
+ public static final Pattern FRACTION_COARSE_STR =
+ Pattern.compile(".*Grobkorn.*");
- public static final String FRACTION_FINE_MIDDLE_STR =
- "_Fein-Mittel-Kies.csv";
+ public static final Pattern FRACTION_FINE_MIDDLE_STR =
+ Pattern.compile(".*Fein-Mittel-Kies.*");
- public static final String FRACTION_SAND =
- "_Sand.csv";
+ public static final Pattern FRACTION_SUSP_SAND_BED =
+ Pattern.compile(".*bettbild_Anteil_susp_Sand.*");
- public static final String FRACTION_SUSP_SAND =
- "_susp_Sand.csv";
+ public static final Pattern FRACTION_SUSP_SAND_BED_EPOCH =
+ Pattern.compile(".*susp_Sand_bettbildAnteil.*");
- public static final String FRACTION_SUSP_SAND_BED =
- "_bettbild_Anteil_susp_Sand.csv";
+ public static final Pattern FRACTION_SUSP_SAND =
+ Pattern.compile(".*susp_Sand.*");
- public static final String FRACTION_SUSP_SAND_BED_EPOCH =
- "_susp_Sand_bettbildAnteil.csv";
+ public static final Pattern FRACTION_SAND =
+ Pattern.compile(".*Sand.*");
- public static final String FRACTION_SUSPENDED_SEDIMENT =
- "_Schwebstoff.csv";
+ public static final Pattern FRACTION_SUSPENDED_SEDIMENT =
+ Pattern.compile(".*Schwebstoff.*");
- public static final String FRACTION_TOTAL =
- "_gesamt.csv";
+ public static final Pattern FRACTION_TOTAL =
+ Pattern.compile(".*gesamt.*");
public static final Pattern TIMEINTERVAL_SINGLE =
@@ -364,28 +364,26 @@
public static String getGrainFractionTypeName(String filename) {
- if (filename.endsWith(FRACTION_COARSE_STR)) {
+ if (filename.matches(FRACTION_COARSE_STR)) {
return GrainFraction.COARSE;
}
- else if (filename.endsWith(FRACTION_FINE_MIDDLE_STR)) {
+ else if (filename.matches(FRACTION_FINE_MIDDLE_STR)) {
return GrainFraction.FINE_MIDDLE;
}
- else if (filename.endsWith(FRACTION_SAND) &&
- !filename.endsWith(FRACTION_SUSP_SAND)) {
+ else if (filename.matches(FRACTION_SUSP_SAND_BED) ||
+ filename.matches(FRACTION_SUSP_SAND_BED_EPOCH)) {
+ return GrainFraction.SUSP_SAND_BED;
+ }
+ else if (filename.matches(FRACTION_SUSP_SAND) {
+ return GrainFraction.SUSP_SAND;
+ }
+ else if (filename.matches(FRACTION_SAND) {
return GrainFraction.SAND;
}
- else if (filename.endsWith(FRACTION_SUSP_SAND) &&
- !filename.endsWith(FRACTION_SUSP_SAND_BED)) {
- return GrainFraction.SUSP_SAND;
- }
- else if (filename.endsWith(FRACTION_SUSP_SAND_BED) ||
- filename.endsWith(FRACTION_SUSP_SAND_BED_EPOCH)) {
- return GrainFraction.SUSP_SAND_BED;
- }
- else if (filename.endsWith(FRACTION_SUSPENDED_SEDIMENT)) {
+ else if (filename.matches(FRACTION_SUSPENDED_SEDIMENT)) {
return GrainFraction.SUSPENDED_SEDIMENT;
}
- else if (filename.endsWith(FRACTION_TOTAL)) {
+ else if (filename.matches(FRACTION_TOTAL)) {
return GrainFraction.TOTAL;
}
else {
More information about the Dive4elements-commits
mailing list