changeset 3404:d7b065b88f10

Simplified code. flys-artifacts/trunk@5056 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Thu, 19 Jul 2012 09:11:56 +0000
parents 04d090d06d3f
children b0ba96bbf01d
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixDeltaWtGenerator.java
diffstat 2 files changed, 20 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Wed Jul 18 16:37:41 2012 +0000
+++ b/flys-artifacts/ChangeLog	Thu Jul 19 09:11:56 2012 +0000
@@ -1,3 +1,9 @@
+2012-07-19	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
+
+	* src/main/java/de/intevation/flys/exports/fixings/FixDeltaWtGenerator.java:
+	  Replaced "string -> object -> native -> object" by simple "string -> object".
+	  Removed stupid duplicate XPathing.
+
 2012-07-18	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
 
 	* src/main/java/de/intevation/flys/artifacts/services/QWSeriesCollection.java:
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixDeltaWtGenerator.java	Wed Jul 18 16:37:41 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixDeltaWtGenerator.java	Thu Jul 19 09:11:56 2012 +0000
@@ -446,14 +446,19 @@
     public void init(Document request, OutputStream out, CallContext context) {
         super.init(request, out, context);
 
-        logger.debug("currentKm = " + new Double(getCurrentKmFromRequest()));
-        context.putContextValue("currentKm", new Double(getCurrentKmFromRequest()));
+        Double currentKm = getCurrentKmFromRequest();
+
+        if (logger.isDebugEnabled()) {
+            logger.debug("currentKm = " + currentKm);
+        }
+
+        context.putContextValue("currentKm", currentKm);
 
         StyledValueMarker marker = new StyledValueMarker(0, request);
         valueMarker.add(marker);
     }
 
-    public double getCurrentKmFromRequest() {
+    public Double getCurrentKmFromRequest() {
         Element km = (Element)XMLUtils.xpath(
             request,
             XPATH_CHART_CURRENTKM,
@@ -461,21 +466,19 @@
             ArtifactNamespaceContext.INSTANCE);
 
         if (km == null) {
-            return -1d;
+            return Double.valueOf(-1d);
         }
 
         String uri = ArtifactNamespaceContext.NAMESPACE_URI;
-
+        // XXX: When using XPath already why is the 'km'
+        //      attribute not fetched directly?
         String currentKm = km.getAttributeNS(uri, "km");
         try {
-            double d = Double.valueOf(currentKm).doubleValue();
-            return d;
+            return Double.valueOf(currentKm);
         }
-        catch(NumberFormatException nfe) {
-            return -1d;
+        catch (NumberFormatException nfe) {
+            return Double.valueOf(-1d);
         }
     }
-
-
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org