diff flys-artifacts/src/main/java/de/intevation/flys/artifacts/HYKArtifact.java @ 2701:c553d4fa3957

Moved the implementation of getDataAsDouble() from concrete Artifacts into FLYSArtifact. flys-artifacts/trunk@4417 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Wed, 16 May 2012 08:21:02 +0000
parents 79044646f4eb
children 64dc2997b2dd
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/HYKArtifact.java	Tue May 15 15:31:39 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/HYKArtifact.java	Wed May 16 08:21:02 2012 +0000
@@ -76,29 +76,18 @@
     }
 
 
-    /**
-     * Get a DataItem casted to double (0 if fails).
-     * TODO move to FlysArtifact.
-     */
-    public double getDataAsDouble(String dataName) {
-        String val = getDataAsString(dataName);
-        if (val == null) {
-            logger.warn("Data not available.");
-            return 0d;
-        }
-        try {
-            return Double.valueOf(val);
-        }
-        catch (NumberFormatException e) {
-            logger.warn("Could not get data " + dataName + " as double", e);
+    /** Get km from state data. */
+    public double getKm() {
+        Double km = getDataAsDouble(HYK_KM);
+        if (km == null) {
+            // XXX returning 0 is to be compatible to older versions that had an
+            // own method getDataAsDouble that returned 0 if parsing the
+            // parameter failed.
             return 0;
         }
-    }
-
-
-    /** Get km from state data. */
-    public double getKm() {
-        return getDataAsDouble(HYK_KM);
+        else {
+            return km;
+        }
     }
 
 

http://dive4elements.wald.intevation.org