changeset 1655:d251e5929860

Extracted StringUtil.unbracket from WaterlevelSelectState.strip . flys-artifacts/trunk@2849 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Wed, 28 Sep 2011 08:20:29 +0000
parents 33ade8153d74
children 94732906b094
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WDifferencesState.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WaterlevelSelectState.java
diffstat 3 files changed, 22 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Tue Sep 27 15:19:59 2011 +0000
+++ b/flys-artifacts/ChangeLog	Wed Sep 28 08:20:29 2011 +0000
@@ -1,3 +1,11 @@
+2011-09-28  Felix Wolfsteller <felix.wolfsteller@intevation.de>
+
+	Extracted StringUtil.unbracket from WaterlevelSelectState.strip.
+
+	* src/main/java/de/intevation/flys/artifacts/states/WDifferencesState.java,
+	  src/main/java/de/intevation/flys/artifacts/states/WaterlevelSelectState.java:
+	  Extract and use StringUtil.unbracket, minor doc.
+
 2011-09-27  Ingo Weinzierl <ingo@intevation.de>
 
 	* src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java,
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WDifferencesState.java	Tue Sep 27 15:19:59 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WDifferencesState.java	Wed Sep 28 08:20:29 2011 +0000
@@ -24,6 +24,7 @@
 import de.intevation.flys.artifacts.model.WQKms;
 
 import de.intevation.flys.utils.FLYSUtils;
+import de.intevation.flys.utils.StringUtil;
 
 
 public class WDifferencesState
@@ -100,8 +101,8 @@
         for(int i = 0; i < datas.length /2; i++) {
             // e.g.:
             // 42537f1e-3522-42ef-8968-635b03d8e9c6;longitudinal_section.w;1
-            String[] def1  = WaterlevelSelectState.strip(datas[i+0]).split(";");
-            String[] def2  = WaterlevelSelectState.strip(datas[i+1]).split(";");
+            String[] def1  = StringUtil.unbracket(datas[i+0]).split(";");
+            String[] def2  = StringUtil.unbracket(datas[i+1]).split(";");
             String   uuid1 = def1[0];
             String   uuid2 = def2[0];
             int      idx1  = Integer.parseInt(def1[2]);
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WaterlevelSelectState.java	Tue Sep 27 15:19:59 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WaterlevelSelectState.java	Wed Sep 28 08:20:29 2011 +0000
@@ -17,6 +17,7 @@
 import de.intevation.flys.artifacts.model.WQKms;
 import de.intevation.flys.artifacts.resources.Resources;
 import de.intevation.flys.utils.FLYSUtils;
+import de.intevation.flys.utils.StringUtil;
 
 
 /**
@@ -40,6 +41,10 @@
     }
 
 
+    /**
+     * @param flys ignored
+     * @param cc   ignrored
+     */
     @Override
     public StateData transform(
         FLYSArtifact flys,
@@ -52,7 +57,7 @@
             return null;
         }
 
-        return new DefaultStateData(name, null, null, strip(val));
+        return new DefaultStateData(name, null, null, StringUtil.unbracket(val));
     }
 
 
@@ -100,6 +105,10 @@
     }
 
 
+    /**
+     * Get name to display for selected watelerlevel (for example "Q=123")
+     * from the CalculationResult. 
+     */
     public static String[] getLabels(CallContext cc, String value) {
         String[] parts = value.split(SPLIT_CHAR);
 
@@ -124,20 +133,6 @@
     }
 
 
-    public static String strip(String value) {
-        int start = value.indexOf("[");
-        int end   = value.indexOf("]");
-
-        if (start < 0 || end < 0) {
-            return value;
-        }
-
-        value = value.substring(start+1, end);
-
-        return value;
-    }
-
-
     /**
      * Validates the given String. A valid string for this state requires the
      * format: "UUID;FACETNAME;FACETINDEX".
@@ -150,7 +145,7 @@
     public static boolean isValueValid(String value) {
         logger.debug("Validate string: '" + value + "'");
 
-        value = strip(value);
+        value = StringUtil.unbracket(value);
 
         logger.debug("Validate substring: '" + value + "'");
 

http://dive4elements.wald.intevation.org