diff artifacts/src/main/java/org/dive4elements/river/artifacts/states/WQSelect.java @ 9277:2323d005f9a5

compile error fix
author gernotbelger
date Fri, 20 Jul 2018 10:39:02 +0200
parents f61bc0c63188
children
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/WQSelect.java	Thu Jul 19 17:54:10 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/WQSelect.java	Fri Jul 20 10:39:02 2018 +0200
@@ -10,37 +10,28 @@
 
 import java.text.NumberFormat;
 
-import gnu.trove.TDoubleArrayList;
-
 import org.apache.log4j.Logger;
-
-import org.w3c.dom.Element;
-
+import org.dive4elements.artifactdatabase.ProtocolUtils;
+import org.dive4elements.artifactdatabase.data.StateData;
 import org.dive4elements.artifacts.Artifact;
 import org.dive4elements.artifacts.CallContext;
-
 import org.dive4elements.artifacts.common.utils.XMLUtils;
 import org.dive4elements.artifacts.common.utils.XMLUtils.ElementCreator;
-
-import org.dive4elements.artifactdatabase.ProtocolUtils;
-import org.dive4elements.artifactdatabase.data.StateData;
-
-import org.dive4elements.river.model.Gauge;
-import org.dive4elements.river.model.River;
-import org.dive4elements.river.model.Wst;
-
 import org.dive4elements.river.artifacts.D4EArtifact;
-
+import org.dive4elements.river.artifacts.access.ComputationRangeAccess;
 import org.dive4elements.river.artifacts.access.RangeAccess;
 import org.dive4elements.river.artifacts.access.RangeAccess.KM_MODE;
-import org.dive4elements.river.artifacts.access.ComputationRangeAccess;
 import org.dive4elements.river.artifacts.model.WstFactory;
 import org.dive4elements.river.artifacts.model.WstValueTable;
 import org.dive4elements.river.artifacts.model.WstValueTableFactory;
 import org.dive4elements.river.artifacts.resources.Resources;
+import org.dive4elements.river.model.Gauge;
+import org.dive4elements.river.model.River;
+import org.dive4elements.river.model.Wst;
+import org.dive4elements.river.utils.RiverUtils;
+import org.w3c.dom.Element;
 
-import org.dive4elements.river.utils.RiverUtils;
-
+import gnu.trove.TDoubleArrayList;
 
 /**
  * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
@@ -80,43 +71,34 @@
     /** The name of the 'single' field. */
     public static final String WQ_SINGLE = "wq_single";
 
-
     /**
      * The default constructor that initializes an empty State object.
      */
     public WQSelect() {
     }
 
-
     @Override
-    protected Element createStaticData(
-        D4EArtifact   flys,
-        ElementCreator creator,
-        CallContext    cc,
-        String         name,
-        String         value,
-        String         type
-    ) {
+    protected Element createStaticData(final D4EArtifact flys, final ElementCreator creator, final CallContext cc, final String name, final String value,
+            final String type) {
         if (!name.equals(WQ_SINGLE)) {
             return super.createStaticData(flys, creator, cc, name, value, type);
         }
 
-        Boolean isQ = flys.getDataAsBoolean(WQ_MODE);
-        Boolean isFree = flys.getDataAsBoolean(WQ_FREE);
+        final Boolean isQ = flys.getDataAsBoolean(WQ_MODE);
+        final Boolean isFree = flys.getDataAsBoolean(WQ_FREE);
 
-        Element dataElement = creator.create("data");
+        final Element dataElement = creator.create("data");
         creator.addAttr(dataElement, "name", name, true);
         creator.addAttr(dataElement, "type", type, true);
 
-        Element itemElement = creator.create("item");
+        final Element itemElement = creator.create("item");
         creator.addAttr(itemElement, "value", value, true);
 
         String label;
 
         if (!isQ || isFree) {
             label = getLabel(flys, cc, value);
-        }
-        else {
+        } else {
             label = getSpecialLabel(flys, cc, value);
         }
 
@@ -127,35 +109,29 @@
         return dataElement;
     }
 
-
-    protected static String getLabel(
-        D4EArtifact winfo,
-        CallContext   cc,
-        String        raw
-    ) {
-        String[] values = raw.split(" ");
+    protected static String getLabel(final D4EArtifact winfo, final CallContext cc, final String raw) {
+        final String[] values = raw.split(" ");
 
         if (values.length < 1) {
             return null;
         }
 
-        StringBuilder label = new StringBuilder();
-
-        NumberFormat nf = NumberFormat.getInstance(
-            Resources.getLocale(cc.getMeta()));
+        final StringBuilder label = new StringBuilder();
 
-        for (String value: values) {
+        final NumberFormat nf = NumberFormat.getInstance(Resources.getLocale(cc.getMeta()));
+
+        for (final String value : values) {
             try {
-                double v = Double.parseDouble(value.trim());
+                final double v = Double.parseDouble(value.trim());
 
-                String formatted = nf.format(v);
+                final String formatted = nf.format(v);
 
                 if (label.length() > 0) {
                     label.append(';');
                 }
                 label.append(formatted);
             }
-            catch (NumberFormatException nfe) {
+            catch (final NumberFormatException nfe) {
                 // do nothing here
             }
         }
@@ -163,33 +139,26 @@
         return label.toString();
     }
 
-
-    protected static String getSpecialLabel(
-        D4EArtifact winfo,
-        CallContext   cc,
-        String        raw
-    ) {
-        String[] values = raw.split(" ");
+    protected static String getSpecialLabel(final D4EArtifact winfo, final CallContext cc, final String raw) {
+        final String[] values = raw.split(" ");
 
         if (values.length < 1) {
             return null;
         }
 
-        NumberFormat nf = NumberFormat.getInstance(
-            Resources.getLocale(cc.getMeta()));
+        final NumberFormat nf = NumberFormat.getInstance(Resources.getLocale(cc.getMeta()));
 
-        RangeAccess rangeAccess = new RangeAccess(winfo);
-        Gauge gauge = rangeAccess.getRiver().determineRefGauge(
-            rangeAccess.getKmRange(), rangeAccess.isRange());
+        final RangeAccess rangeAccess = new RangeAccess(winfo);
+        final Gauge gauge = rangeAccess.getRiver().determineRefGauge(rangeAccess.getKmRange(), rangeAccess.isRange());
 
-        StringBuilder label = new StringBuilder();
+        final StringBuilder label = new StringBuilder();
 
-        for (String value: values) {
+        for (final String value : values) {
             try {
-                double v = Double.parseDouble(value.trim());
+                final double v = Double.parseDouble(value.trim());
 
                 String tmp = nf.format(v);
-                String mv  = RiverUtils.getNamedMainValue(gauge, v);
+                final String mv = RiverUtils.getNamedMainValue(gauge, v);
 
                 if (mv != null && mv.length() > 0) {
                     tmp = mv + ": " + tmp;
@@ -200,7 +169,7 @@
                 }
                 label.append(tmp);
             }
-            catch (NumberFormatException nfe) {
+            catch (final NumberFormatException nfe) {
                 // do nothing here
             }
         }
@@ -208,155 +177,99 @@
         return label.toString();
     }
 
-
     @Override
-    protected Element createData(
-        XMLUtils.ElementCreator cr,
-        Artifact    artifact,
-        StateData   data,
-        CallContext context)
-    {
-        Element select = ProtocolUtils.createArtNode(
-            cr, "select", null, null);
+    protected Element createData(final XMLUtils.ElementCreator cr, final Artifact artifact, final StateData data, final CallContext context) {
+        final Element select = ProtocolUtils.createArtNode(cr, "select", null, null);
 
         cr.addAttr(select, "name", data.getName(), true);
 
-        Element label = ProtocolUtils.createArtNode(
-            cr, "label", null, null);
+        final Element label = ProtocolUtils.createArtNode(cr, "label", null, null);
 
         // XXX: DEAD CODE
         /*
-        Element choices = ProtocolUtils.createArtNode(
-            cr, "choices", null, null);
-        */
+         * Element choices = ProtocolUtils.createArtNode(
+         * cr, "choices", null, null);
+         */
 
-        label.setTextContent(Resources.getMsg(
-            context.getMeta(),
-            data.getName(),
-            data.getName()));
+        label.setTextContent(Resources.getMsg(context.getMeta(), data.getName(), data.getName()));
 
         select.appendChild(label);
 
         return select;
     }
 
-
     @Override
-    protected Element[] createItems(
-        XMLUtils.ElementCreator cr,
-        Artifact    artifact,
-        String      name,
-        CallContext context
-    ){
-        D4EArtifact flys = (D4EArtifact) artifact;
+    protected Element[] createItems(final XMLUtils.ElementCreator cr, final Artifact artifact, final String name, final CallContext context) {
+        final D4EArtifact flys = (D4EArtifact) artifact;
 
-        double[] minmaxW     = determineMinMaxW(flys);
-        double[] minmaxWFree = determineMinMaxWFree(flys);
-        double[] minmaxQ     = determineMinMaxQAtGauge(flys);
-        double[] minmaxQFree = determineMinMaxQ(flys);
+        final double[] minmaxW = determineMinMaxW(flys);
+        final double[] minmaxWFree = determineMinMaxWFree(flys);
+        final double[] minmaxQ = determineMinMaxQAtGauge(flys);
+        final double[] minmaxQFree = determineMinMaxQ(flys);
 
         if (name.equals("wq_from")) {
-            Element minW = createItem(cr, new String[] {
-                "minW",
-                String.valueOf(minmaxW[0])});
+            final Element minW = createItem(cr, new String[] { "minW", String.valueOf(minmaxW[0]) });
 
-            Element minQ = createItem(cr, new String[] {
-                "minQ",
-                String.valueOf(minmaxQ[0])});
+            final Element minQ = createItem(cr, new String[] { "minQ", String.valueOf(minmaxQ[0]) });
 
-            Element minQFree = createItem(cr, new String[] {
-                "minQFree",
-                String.valueOf(minmaxQFree[0])});
+            final Element minQFree = createItem(cr, new String[] { "minQFree", String.valueOf(minmaxQFree[0]) });
 
-            Element minWFree = createItem(cr, new String[] {
-                "minWFree",
-                String.valueOf(minmaxWFree[0])});
+            final Element minWFree = createItem(cr, new String[] { "minWFree", String.valueOf(minmaxWFree[0]) });
 
             return new Element[] { minW, minQ, minQFree, minWFree };
-        }
-        else if (name.equals("wq_to")) {
-            Element maxW = createItem(cr, new String[] {
-                "maxW",
-                String.valueOf(minmaxW[1])});
+        } else if (name.equals("wq_to")) {
+            final Element maxW = createItem(cr, new String[] { "maxW", String.valueOf(minmaxW[1]) });
 
-            Element maxQ = createItem(cr, new String[] {
-                "maxQ",
-                String.valueOf(minmaxQ[1])});
+            final Element maxQ = createItem(cr, new String[] { "maxQ", String.valueOf(minmaxQ[1]) });
 
-            Element maxQFree = createItem(cr, new String[] {
-                "maxQFree",
-                String.valueOf(minmaxQFree[1])});
+            final Element maxQFree = createItem(cr, new String[] { "maxQFree", String.valueOf(minmaxQFree[1]) });
 
-            Element maxWFree = createItem(cr, new String[] {
-                "maxWFree",
-                String.valueOf(minmaxWFree[1])});
+            final Element maxWFree = createItem(cr, new String[] { "maxWFree", String.valueOf(minmaxWFree[1]) });
 
             return new Element[] { maxW, maxQ, maxQFree, maxWFree };
-        }
-        else {
-            Element stepW = createItem(
-                cr, new String[] {
-                    "stepW",
-                    String.valueOf(getStepsW(minmaxW[0], minmaxW[1]))});
-            Element stepQ = createItem(
-                cr, new String[] {
-                    "stepQ",
-                    String.valueOf(getStepsQ(minmaxQ[0], minmaxQ[1]))});
-            Element stepQFree = createItem(
-                cr, new String[] {
-                    "stepQFree",
-                    String.valueOf(getStepsQ(minmaxQFree[0], minmaxQFree[1]))});
-            Element stepWFree = createItem(
-                cr, new String[] {
-                    "stepWFree",
-                    String.valueOf(getStepsW(minmaxWFree[0], minmaxWFree[1]))});
+        } else {
+            final Element stepW = createItem(cr, new String[] { "stepW", String.valueOf(getStepsW(minmaxW[0], minmaxW[1])) });
+            final Element stepQ = createItem(cr, new String[] { "stepQ", String.valueOf(getStepsQ(minmaxQ[0], minmaxQ[1])) });
+            final Element stepQFree = createItem(cr, new String[] { "stepQFree", String.valueOf(getStepsQ(minmaxQFree[0], minmaxQFree[1])) });
+            final Element stepWFree = createItem(cr, new String[] { "stepWFree", String.valueOf(getStepsW(minmaxWFree[0], minmaxWFree[1])) });
 
             return new Element[] { stepW, stepQ, stepQFree, stepWFree };
         }
     }
 
-
-    protected static double getStepsW(double min, double max) {
-        double diff = min < max ? max - min : min - max;
-        double step = diff / MAX_STEPS;
+    protected static double getStepsW(final double min, final double max) {
+        final double diff = min < max ? max - min : min - max;
+        final double step = diff / MAX_STEPS;
 
         if (step < 10) {
             return getSteps(step, 1);
-        }
-        else if (step < 100) {
+        } else if (step < 100) {
             return getSteps(step, 10);
-        }
-        else if (step < 1000) {
+        } else if (step < 1000) {
             return getSteps(step, 100);
-        }
-        else {
+        } else {
             return step;
         }
     }
 
-
-    protected static double getStepsQ(double min, double max) {
-        double diff = min < max ? max - min : min - max;
-        double step = diff / MAX_STEPS;
+    protected static double getStepsQ(final double min, final double max) {
+        final double diff = min < max ? max - min : min - max;
+        final double step = diff / MAX_STEPS;
 
         if (step < 10) {
             return getSteps(step, 1);
-        }
-        else if (step < 100) {
+        } else if (step < 100) {
             return getSteps(step, 10);
-        }
-        else if (step < 1000) {
+        } else if (step < 1000) {
             return getSteps(step, 100);
-        }
-        else {
+        } else {
             return step;
         }
     }
 
-
-    protected static double getSteps(double steps, double factor) {
-        int    fac  = (int) (steps / factor);
-        double diff = steps - fac * factor;
+    protected static double getSteps(final double steps, final double factor) {
+        final int fac = (int) (steps / factor);
+        final double diff = steps - fac * factor;
 
         if (diff == 0) {
             return steps;
@@ -365,141 +278,133 @@
         return factor * (fac + 1);
     }
 
-
-    protected Element createItem(XMLUtils.ElementCreator cr, Object obj) {
-        Element item  = ProtocolUtils.createArtNode(cr, "item", null, null);
-        Element label = ProtocolUtils.createArtNode(cr, "label", null, null);
-        Element value = ProtocolUtils.createArtNode(cr, "value", null, null);
-
-        String[] arr = (String[]) obj;
-
-        label.setTextContent(arr[0]);
-        value.setTextContent(arr[1]);
-
-        item.appendChild(label);
-        item.appendChild(value);
-
-        return item;
-    }
-
+    // ist mit super identisch
+    // protected Element createItem(XMLUtils.ElementCreator cr, Object obj) {
+    // Element item = ProtocolUtils.createArtNode(cr, "item", null, null);
+    // Element label = ProtocolUtils.createArtNode(cr, "label", null, null);
+    // Element value = ProtocolUtils.createArtNode(cr, "value", null, null);
+    //
+    // String[] arr = (String[]) obj;
+    //
+    // label.setTextContent(arr[0]);
+    // value.setTextContent(arr[1]);
+    //
+    // item.appendChild(label);
+    // item.appendChild(value);
+    //
+    // return item;
+    // }
 
     @Override
     protected String getUIProvider() {
         return "wq_panel";
     }
 
-
     /**
      * Determines the min and max W value for the current gauge. If no min and
      * max values could be determined, this method will return
      * [Double.MIN_VALUE, Double.MAX_VALUE].
      *
-     * @param artifact The D4EArtifact.
+     * @param artifact
+     *            The D4EArtifact.
      *
      * @return the min and max W values for the current gauge.
      */
-    protected double[] determineMinMaxW(D4EArtifact winfo) {
+    protected double[] determineMinMaxW(final D4EArtifact winfo) {
         log.debug("WQSelect.determineCurrentGauge");
 
-        RangeAccess rangeAccess = new RangeAccess(winfo);
-        Gauge gauge = rangeAccess.getRiver().determineRefGauge(
-            rangeAccess.getKmRange(), rangeAccess.isRange());
+        final RangeAccess rangeAccess = new RangeAccess(winfo);
+        final Gauge gauge = rangeAccess.getRiver().determineRefGauge(rangeAccess.getKmRange(), rangeAccess.isRange());
 
-        double[] minmaxW = gauge != null ? gauge.determineMinMaxW() : null;
+        final double[] minmaxW = gauge != null ? gauge.determineMinMaxW() : null;
 
-        double minW = minmaxW != null ? minmaxW[0] : Double.MIN_VALUE;
-        double maxW = minmaxW != null ? minmaxW[1] : Double.MAX_VALUE;
+        final double minW = minmaxW != null ? minmaxW[0] : Double.MIN_VALUE;
+        final double maxW = minmaxW != null ? minmaxW[1] : Double.MAX_VALUE;
 
         return new double[] { minW, maxW };
     }
 
-
     /**
      * Determines the min and max W value. If no min and
      * max values could be determined, this method will return
      * [Double.MIN_VALUE, Double.MAX_VALUE].
      *
-     * @param artifact The D4EArtifact.
+     * @param artifact
+     *            The D4EArtifact.
      *
      * @return the min and max W values.
      */
-    protected double[] determineMinMaxWFree(D4EArtifact winfo) {
+    protected double[] determineMinMaxWFree(final D4EArtifact winfo) {
         log.debug("WQSelect.determineMinMaxWFree");
 
-        WstValueTable valueTable = WstValueTableFactory.getTable(
-                RiverUtils.getRiver(winfo));
+        final WstValueTable valueTable = WstValueTableFactory.getTable(RiverUtils.getRiver(winfo));
 
-        ComputationRangeAccess access = new ComputationRangeAccess(winfo);
-        
+        final ComputationRangeAccess access = new ComputationRangeAccess(winfo);
+
         double[] minmaxW = null;
-        if(valueTable != null) {
+        if (valueTable != null) {
 
             final double startKm = access.getStartKm();
             // Use the start km to determine the min max values.
             minmaxW = valueTable.getMinMaxW(startKm);
         }
-        return minmaxW != null
-            ? minmaxW
-            : new double[] { Double.MIN_VALUE, Double.MAX_VALUE };
+        return minmaxW != null ? minmaxW : new double[] { Double.MIN_VALUE, Double.MAX_VALUE };
     }
 
-
     /**
      * Determines the min and max Q value for the current gauge. If no min and
      * max values could be determined, this method will return
      * [Double.MIN_VALUE, Double.MAX_VALUE].
      *
-     * @param artifact The D4EArtifact.
+     * @param artifact
+     *            The D4EArtifact.
      *
      * @return the min and max Q values for the current gauge.
      */
-    protected double[] determineMinMaxQAtGauge(D4EArtifact winfo) {
+    protected double[] determineMinMaxQAtGauge(final D4EArtifact winfo) {
         log.debug("WQSelect.determineMinMaxQAtGauge");
 
-        RangeAccess rangeAccess = new RangeAccess(winfo);
-        River river = rangeAccess.getRiver();
-        Gauge gauge = river.determineRefGauge(
-            rangeAccess.getKmRange(), rangeAccess.isRange());
+        final RangeAccess rangeAccess = new RangeAccess(winfo);
+        final River river = rangeAccess.getRiver();
+        final Gauge gauge = river.determineRefGauge(rangeAccess.getKmRange(), rangeAccess.isRange());
 
-        Wst   wst   = WstFactory.getWst(river);
+        final Wst wst = WstFactory.getWst(river);
 
-        double[] minmaxQ = gauge != null
-            ? wst.determineMinMaxQ(gauge.getRange())
-            : null;
+        final double[] minmaxQ = gauge != null ? wst.determineMinMaxQ(gauge.getRange()) : null;
 
-        double minQ = minmaxQ != null ? minmaxQ[0] : Double.MIN_VALUE;
-        double maxQ = minmaxQ != null ? minmaxQ[1] : Double.MAX_VALUE;
+        final double minQ = minmaxQ != null ? minmaxQ[0] : Double.MIN_VALUE;
+        final double maxQ = minmaxQ != null ? minmaxQ[1] : Double.MAX_VALUE;
 
         return new double[] { minQ, maxQ };
     }
 
-
     /**
      * Determines the min and max Q value for the current kilometer range. If no
      * min and max values could be determined, this method will return
      *
-     * @param artifact The D4EArtifact.
+     * @param artifact
+     *            The D4EArtifact.
      *
      * @return the min and max Q values for the current kilometer range.
      */
-    protected double[] determineMinMaxQ(D4EArtifact winfo) {
+    protected double[] determineMinMaxQ(final D4EArtifact winfo) {
         log.debug("WQSelect.determineMinMaxQ");
 
         final WstValueTable valueTable = WstValueTableFactory.getTable(RiverUtils.getRiver(winfo));
 
         final ComputationRangeAccess access = new ComputationRangeAccess(winfo);
-        
+
         double[] minmaxQ = null;
-        if(valueTable != null) {
-            
+        if (valueTable != null) {
+
             final KM_MODE mode = access.getKmRangeMode();
             switch (mode) {
             case RANGE: {
-                final double[] km =  access.getFromToStep();
+                final double[] km = access.getFromToStep();
                 minmaxQ = valueTable.getMinMaxQ(km[0], km[1], km[2]);
                 break;
             }
-            
+
             case DISTANCE_ONLY: {
                 minmaxQ = valueTable.getMinMaxQ(access.getFrom(), access.getTo(), 0.1);
                 break;
@@ -509,11 +414,11 @@
                 final double[] km = access.getKms();
                 minmaxQ = valueTable.getMinMaxQ(km[0]);
                 for (int i = 1; i < km.length; i++) {
-                    double[] tmp = valueTable.getMinMaxQ(km[i]);
-                    if(tmp[0] < minmaxQ[0]) {
+                    final double[] tmp = valueTable.getMinMaxQ(km[i]);
+                    if (tmp[0] < minmaxQ[0]) {
                         minmaxQ[0] = tmp[0];
                     }
-                    if(tmp[1] > minmaxQ[1]) {
+                    if (tmp[1] > minmaxQ[1]) {
                         minmaxQ[1] = tmp[1];
                     }
                 }
@@ -521,86 +426,66 @@
             }
             }
         }
-        return minmaxQ != null
-            ? minmaxQ
-            : new double[] { Double.MIN_VALUE, Double.MAX_VALUE };
+        return minmaxQ != null ? minmaxQ : new double[] { Double.MIN_VALUE, Double.MAX_VALUE };
     }
 
-
     @Override
-    public boolean validate(Artifact artifact)
-    throws IllegalArgumentException
-    {
+    public boolean validate(final Artifact artifact) throws IllegalArgumentException {
         log.debug("WQSelect.validate");
 
-        D4EArtifact flys = (D4EArtifact) artifact;
+        final D4EArtifact flys = (D4EArtifact) artifact;
 
-        StateData data       = getData(flys, WQ_SELECTION);
-        boolean isRange = data != null
-            ? Boolean.valueOf((String) data.getValue())
-            : false;
-
-
+        final StateData data = getData(flys, WQ_SELECTION);
+        final boolean isRange = data != null ? Boolean.valueOf((String) data.getValue()) : false;
 
         if (!isRange) {
             return validateSingle(flys);
-        }
-        else {
+        } else {
             return validateRange(flys);
         }
     }
 
-
-    protected boolean validateBounds(
-        double fromValid, double toValid,
-        double from,      double to,      double step)
-    throws IllegalArgumentException
-    {
+    protected boolean validateBounds(final double fromValid, final double toValid, final double from, final double to, final double step)
+            throws IllegalArgumentException {
         log.debug("RangeState.validateRange");
 
         if (from < fromValid) {
-            log.error(
-                "Invalid 'from'. " + from + " is smaller than " + fromValid);
+            log.error("Invalid 'from'. " + from + " is smaller than " + fromValid);
             throw new IllegalArgumentException("error_feed_from_out_of_range");
-        }
-        else if (to > toValid) {
-            log.error(
-                "Invalid 'to'. " + to + " is bigger than " + toValid);
+        } else if (to > toValid) {
+            log.error("Invalid 'to'. " + to + " is bigger than " + toValid);
             throw new IllegalArgumentException("error_feed_to_out_of_range");
         }
 
         return true;
     }
 
-
-    protected boolean validateSingle(D4EArtifact artifact)
-    throws    IllegalArgumentException
-    {
+    protected boolean validateSingle(final D4EArtifact artifact) throws IllegalArgumentException {
         log.debug("WQSelect.validateSingle");
 
-        StateData    data = getData(artifact, WQ_SINGLE);
+        final StateData data = getData(artifact, WQ_SINGLE);
 
-        String tmp = data != null ? (String) data.getValue() : null;
+        final String tmp = data != null ? (String) data.getValue() : null;
 
         if (tmp == null || tmp.length() == 0) {
             throw new IllegalArgumentException("error_empty_state");
         }
 
-        String[] strValues = tmp.split(" ");
-        TDoubleArrayList all = new TDoubleArrayList();
+        final String[] strValues = tmp.split(" ");
+        final TDoubleArrayList all = new TDoubleArrayList();
 
-        for (String strValue: strValues) {
+        for (final String strValue : strValues) {
             try {
                 all.add(Double.parseDouble(strValue));
             }
-            catch (NumberFormatException nfe) {
+            catch (final NumberFormatException nfe) {
                 log.warn(nfe, nfe);
             }
         }
 
         all.sort();
 
-        RiverUtils.WQ_MODE mode = RiverUtils.getWQMode(artifact);
+        final RiverUtils.WQ_MODE mode = RiverUtils.getWQMode(artifact);
 
         log.debug("WQ Mode: " + mode);
 
@@ -608,19 +493,16 @@
 
         if (mode == RiverUtils.WQ_MODE.WGAUGE) {
             minmax = determineMinMaxW(artifact);
-        }
-        else if (mode == RiverUtils.WQ_MODE.QGAUGE) {
+        } else if (mode == RiverUtils.WQ_MODE.QGAUGE) {
             minmax = determineMinMaxQAtGauge(artifact);
-        }
-        else if (mode == RiverUtils.WQ_MODE.QFREE) {
+        } else if (mode == RiverUtils.WQ_MODE.QFREE) {
             minmax = determineMinMaxQ(artifact);
-        }
-        else {
+        } else {
             minmax = determineMinMaxWFree(artifact);
         }
 
-        double min = all.get(0);
-        double max = all.get(all.size()-1);
+        final double min = all.get(0);
+        final double max = all.get(all.size() - 1);
 
         log.debug("Inserted min value = " + min);
         log.debug("Inserted max value = " + max);
@@ -628,156 +510,136 @@
         return validateBounds(minmax[0], minmax[1], min, max, 0d);
     }
 
-
-    protected boolean validateRange(D4EArtifact artifact)
-    throws    IllegalArgumentException
-    {
+    protected boolean validateRange(final D4EArtifact artifact) throws IllegalArgumentException {
         log.debug("WQSelect.validateRange");
 
-        RiverUtils.WQ_MODE mode = RiverUtils.getWQMode(artifact);
+        final RiverUtils.WQ_MODE mode = RiverUtils.getWQMode(artifact);
 
         if (mode == null) {
             throw new IllegalArgumentException("error_feed_invalid_wq_mode");
         }
 
-        StateData dFrom = artifact.getData(WQ_FROM);
-        StateData dTo   = artifact.getData(WQ_TO);
-        StateData dStep = artifact.getData(WQ_STEP);
+        final StateData dFrom = artifact.getData(WQ_FROM);
+        final StateData dTo = artifact.getData(WQ_TO);
+        final StateData dStep = artifact.getData(WQ_STEP);
 
-        String fromStr = dFrom != null ? (String) dFrom.getValue() : null;
-        String toStr   = dTo != null ? (String) dTo.getValue() : null;
-        String stepStr = dStep != null ? (String) dStep.getValue() : null;
+        final String fromStr = dFrom != null ? (String) dFrom.getValue() : null;
+        final String toStr = dTo != null ? (String) dTo.getValue() : null;
+        final String stepStr = dStep != null ? (String) dStep.getValue() : null;
 
         if (fromStr == null || toStr == null || stepStr == null) {
             throw new IllegalArgumentException("error_empty_state");
         }
 
         try {
-            double from = Double.parseDouble(fromStr);
-            double to   = Double.parseDouble(toStr);
-            double step = Double.parseDouble(stepStr);
+            final double from = Double.parseDouble(fromStr);
+            final double to = Double.parseDouble(toStr);
+            final double step = Double.parseDouble(stepStr);
 
             if (mode == RiverUtils.WQ_MODE.WGAUGE) {
                 return validateGaugeW(artifact, from, to, step);
-            }
-            else if (mode == RiverUtils.WQ_MODE.QGAUGE) {
+            } else if (mode == RiverUtils.WQ_MODE.QGAUGE) {
                 return validateGaugeQ(artifact, from, to, step);
-            }
-            else if (mode == RiverUtils.WQ_MODE.QFREE) {
+            } else if (mode == RiverUtils.WQ_MODE.QFREE) {
                 return validateFreeQ(artifact, from, to, step);
-            }
-            else if (mode == RiverUtils.WQ_MODE.WFREE) {
+            } else if (mode == RiverUtils.WQ_MODE.WFREE) {
                 return validateFreeW(artifact, from, to, step);
-            }
-            else {
-                throw new IllegalArgumentException(
-                    "error_feed_invalid_wq_mode");
+            } else {
+                throw new IllegalArgumentException("error_feed_invalid_wq_mode");
             }
         }
-        catch (NumberFormatException nfe) {
+        catch (final NumberFormatException nfe) {
             throw new IllegalArgumentException("error_feed_number_format");
         }
     }
 
-
     /**
      * Validates the inserted W values.
      *
-     * @param artifact The owner artifact.
-     * @param from The lower value of the W range.
-     * @param to The upper value of the W range.
-     * @param step The step width.
+     * @param artifact
+     *            The owner artifact.
+     * @param from
+     *            The lower value of the W range.
+     * @param to
+     *            The upper value of the W range.
+     * @param step
+     *            The step width.
      *
      * @return true, if everything was fine, otherwise an exception is thrown.
      */
-    protected boolean validateGaugeW(
-        D4EArtifact    artifact,
-        double from,
-        double to,
-        double step)
-    throws    IllegalArgumentException
-    {
+    protected boolean validateGaugeW(final D4EArtifact artifact, final double from, final double to, final double step) throws IllegalArgumentException {
         log.debug("WQSelect.validateGaugeW");
 
-        double[] minmaxW = determineMinMaxW(artifact);
+        final double[] minmaxW = determineMinMaxW(artifact);
 
         return validateBounds(minmaxW[0], minmaxW[1], from, to, step);
     }
 
-
     /**
      * Validates the inserted Q values based on the Q range for the current
      * gauge.
      *
-     * @param artifact The owner artifact.
-     * @param from The lower value of the Q range.
-     * @param to The upper value of the Q range.
-     * @param step The step width.
+     * @param artifact
+     *            The owner artifact.
+     * @param from
+     *            The lower value of the Q range.
+     * @param to
+     *            The upper value of the Q range.
+     * @param step
+     *            The step width.
      *
      * @return true, if everything was fine, otherwise an exception is thrown.
      */
-    protected boolean validateGaugeQ(
-        D4EArtifact artifact,
-        double   from,
-        double   to,
-        double   step)
-    throws IllegalArgumentException
-    {
+    protected boolean validateGaugeQ(final D4EArtifact artifact, final double from, final double to, final double step) throws IllegalArgumentException {
         log.debug("WQSelect.validateGaugeQ");
 
-        double[] minmaxQ = determineMinMaxQAtGauge(artifact);
+        final double[] minmaxQ = determineMinMaxQAtGauge(artifact);
 
         return validateBounds(minmaxQ[0], minmaxQ[1], from, to, step);
     }
 
-
     /**
      * Validates the inserted Q values based on the Q range for the current
      * kilometer range.
      *
-     * @param artifact The owner artifact.
-     * @param from The lower value of the Q range.
-     * @param to The upper value of the Q range.
-     * @param step The step width.
+     * @param artifact
+     *            The owner artifact.
+     * @param from
+     *            The lower value of the Q range.
+     * @param to
+     *            The upper value of the Q range.
+     * @param step
+     *            The step width.
      *
      * @return true, if everything was fine, otherwise an exception is thrown.
      */
-    protected boolean validateFreeQ(
-        D4EArtifact artifact,
-        double   from,
-        double   to,
-        double   step)
-    throws IllegalArgumentException
-    {
+    protected boolean validateFreeQ(final D4EArtifact artifact, final double from, final double to, final double step) throws IllegalArgumentException {
         log.debug("WQSelect.validateFreeQ");
 
-        double[] minmaxQ = determineMinMaxQ(artifact);
+        final double[] minmaxQ = determineMinMaxQ(artifact);
 
         return validateBounds(minmaxQ[0], minmaxQ[1], from, to, step);
     }
 
-
     /**
      * Validates the inserted W values based on the W range for the current
      * kilometer range.
      *
-     * @param artifact The owner artifact.
-     * @param from The lower value of the W range.
-     * @param to The upper value of the W range.
-     * @param step The step width.
+     * @param artifact
+     *            The owner artifact.
+     * @param from
+     *            The lower value of the W range.
+     * @param to
+     *            The upper value of the W range.
+     * @param step
+     *            The step width.
      *
      * @return true, if everything was fine, otherwise an exception is thrown.
      */
-    protected boolean validateFreeW(
-        D4EArtifact artifact,
-        double   from,
-        double   to,
-        double   step)
-    throws IllegalArgumentException
-    {
+    protected boolean validateFreeW(final D4EArtifact artifact, final double from, final double to, final double step) throws IllegalArgumentException {
         log.debug("WQSelect.validateFreeW");
 
-        double[] minmaxW = determineMinMaxWFree(artifact);
+        final double[] minmaxW = determineMinMaxWFree(artifact);
 
         return validateBounds(minmaxW[0], minmaxW[1], from, to, step);
     }

http://dive4elements.wald.intevation.org