# HG changeset patch # User Sascha L. Teichmann # Date 1341146600 0 # Node ID 06ae0258269b3cc155c8677463257824fab2664c # Parent 0c8a6145098b0b015e2a35ec879245238df677f2 More braindead code removal. flys-artifacts/trunk@4844 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 0c8a6145098b -r 06ae0258269b flys-artifacts/ChangeLog --- a/flys-artifacts/ChangeLog Sun Jul 01 11:18:59 2012 +0000 +++ b/flys-artifacts/ChangeLog Sun Jul 01 12:43:20 2012 +0000 @@ -1,3 +1,9 @@ +2012-07-01 Sascha L. Teichmann + + * src/main/java/de/intevation/flys/exports/fixings/FixChartGenerator.java: + Remove some evidence that the authors of this software + do not know Java at all. + 2012-07-01 Sascha L. Teichmann Part of flys/issue687 diff -r 0c8a6145098b -r 06ae0258269b flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixChartGenerator.java --- a/flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixChartGenerator.java Sun Jul 01 11:18:59 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixChartGenerator.java Sun Jul 01 12:43:20 2012 +0000 @@ -1,14 +1,11 @@ package de.intevation.flys.exports.fixings; -import org.w3c.dom.Element; import org.w3c.dom.Document; import org.apache.log4j.Logger; import java.io.OutputStream; -import javax.xml.xpath.XPathConstants; - import de.intevation.artifacts.ArtifactNamespaceContext; import de.intevation.artifacts.common.utils.XMLUtils; import de.intevation.artifacts.CallContext; @@ -20,39 +17,41 @@ { private static Logger logger = Logger.getLogger(FixChartGenerator.class); + public static final Double INVALID_KM = Double.valueOf(-1d); + public static final String XPATH_CHART_CURRENTKM = - "/art:action/art:attributes/art:currentKm"; - + "/art:action/art:attributes/art:currentKm/@art:km"; @Override 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(request); + + if (logger.isDebugEnabled()) { + logger.debug("currentKm = " + currentKm); + } + + context.putContextValue("currentKm", currentKm); } - public double getCurrentKmFromRequest() { - Element km = (Element)XMLUtils.xpath( + public static Double getCurrentKmFromRequest(Document request) { + + String km = XMLUtils.xpathString( request, XPATH_CHART_CURRENTKM, - XPathConstants.NODE, ArtifactNamespaceContext.INSTANCE); if (km == null) { - return -1d; + return INVALID_KM; } - String uri = ArtifactNamespaceContext.NAMESPACE_URI; - - String currentKm = km.getAttributeNS(uri, "km"); try { - double d = Double.valueOf(currentKm).doubleValue(); - return d; + return Double.valueOf(km); } - catch(NumberFormatException nfe) { - return -1d; + catch (NumberFormatException nfe) { + return INVALID_KM; } } } - +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :