changeset 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 08c5e3a646dc
children 8e66a200a0b9
files flys-backend/src/main/java/de/intevation/flys/importer/parsers/SedimentYieldParser.java
diffstat 1 files changed, 31 insertions(+), 33 deletions(-) [+]
line wrap: on
line diff
--- 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 String FRACTION_FINE_MIDDLE_STR =
-        "_Fein-Mittel-Kies.csv";
-
-    public static final String FRACTION_SAND =
-        "_Sand.csv";
+    public static final Pattern FRACTION_COARSE_STR =
+        Pattern.compile(".*Grobkorn.*");
 
-    public static final String FRACTION_SUSP_SAND =
-        "_susp_Sand.csv";
-
-    public static final String FRACTION_SUSP_SAND_BED =
-        "_bettbild_Anteil_susp_Sand.csv";
+    public static final Pattern FRACTION_FINE_MIDDLE_STR =
+        Pattern.compile(".*Fein-Mittel-Kies.*");
 
-    public static final String FRACTION_SUSP_SAND_BED_EPOCH =
-        "_susp_Sand_bettbildAnteil.csv";
+    public static final Pattern FRACTION_SUSP_SAND_BED =
+        Pattern.compile(".*bettbild_Anteil_susp_Sand.*");
 
-    public static final String FRACTION_SUSPENDED_SEDIMENT =
-        "_Schwebstoff.csv";
+    public static final Pattern FRACTION_SUSP_SAND_BED_EPOCH =
+        Pattern.compile(".*susp_Sand_bettbildAnteil.*");
 
-    public static final String FRACTION_TOTAL =
-        "_gesamt.csv";
+    public static final Pattern FRACTION_SUSP_SAND =
+        Pattern.compile(".*susp_Sand.*");
+
+    public static final Pattern FRACTION_SAND =
+        Pattern.compile(".*Sand.*");
+
+    public static final Pattern FRACTION_SUSPENDED_SEDIMENT =
+        Pattern.compile(".*Schwebstoff.*");
+
+    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 {

http://dive4elements.wald.intevation.org