[PATCH 3 of 4] issue1465: Do not allow null ranges for fraction values, logger.error instead

Wald Commits scm-commit at wald.intevation.org
Fri Sep 13 16:01:29 CEST 2013


# HG changeset patch
# User Felix Wolfsteller <felix.wolfsteller at intevation.de>
# Date 1379081266 -7200
# Node ID 998a9710007e5709e2a0b415d1b5af097851b4db
# Parent  9f45c17e8fdab4de9fcf91af39c206ace698ed02
issue1465: Do not allow null ranges for fraction values, logger.error instead.

diff -r 9f45c17e8fda -r 998a9710007e artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoad.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoad.java	Fri Sep 13 16:03:05 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoad.java	Fri Sep 13 16:07:46 2013 +0200
@@ -17,11 +17,17 @@
 import org.dive4elements.river.artifacts.model.Range;
 import org.dive4elements.river.utils.EpsilonComparator;
 
+import org.apache.log4j.Logger;
+
 
 /** Gives access to Fractions (at kms). */
 public class SedimentLoad
 extends NamedObjectImpl
 {
+    /** Private logger. */
+    private static final Logger logger = Logger
+        .getLogger(SedimentLoad.class);
+
     protected String description;
     protected Date start;
     protected Date end;
@@ -99,12 +105,20 @@
     }
 
     public void setCoarse(double km, double coarse, Range range) {
+        if (range == null) {
+            logger.error("coarse/range is null!");
+            return;
+        }
         SedimentLoadFraction f = getFraction(km);
         f.setCoarse(coarse);
         f.setCoarseRange(range);
     }
 
     public void setFineMiddle(double km, double fine_middle, Range range) {
+        if (range == null) {
+            logger.error("finemiddle/range is null!");
+            return;
+        }
         SedimentLoadFraction f = getFraction(km);
         f.setFineMiddle(fine_middle);
         f.setFineMiddleRange(range);
@@ -112,24 +126,40 @@
 
 
     public void setSand(double km, double sand, Range range) {
+        if (range == null) {
+            logger.error("sand/range is null!");
+            return;
+        }
         SedimentLoadFraction f = getFraction(km);
         f.setSand(sand);
         f.setSandRange(range);
     }
 
     public void setSuspSand(double km, double susp_sand, Range range) {
+        if (range == null) {
+            logger.error("suspsand/range is null!");
+            return;
+        }
         SedimentLoadFraction f = getFraction(km);
         f.setSuspSand(susp_sand);
         f.setSuspSandRange(range);
     }
 
     public void setSuspSandBed(double km, double susp_sand_bed, Range range) {
+        if (range == null) {
+            logger.error("suspsandbed/range is null!");
+            return;
+        }
         SedimentLoadFraction f = getFraction(km);
         f.setSuspSandBed(susp_sand_bed);
         f.setSuspSandBedRange(range);
     }
 
     public void setSuspSediment(double km, double susp_sediment, Range range) {
+        if (range == null) {
+            logger.error("suspsed/range is null!");
+            return;
+        }
         SedimentLoadFraction f = getFraction(km);
         f.setSuspSediment(susp_sediment);
         f.setSuspSedimentRange(range);
@@ -140,18 +170,30 @@
     }
 
     public void setLoadTotal(double km, double total, Range range) {
+        if (range == null) {
+            logger.error("loadtotal/range is null!");
+            return;
+        }
         SedimentLoadFraction f = getFraction(km);
         f.setLoadTotal(total);
         f.setLoadTotalRange(range);
     }
 
     public void setTotal(double km, double total, Range range) {
+        if (range == null) {
+            logger.error("total/range is null!");
+            return;
+        }
         SedimentLoadFraction f = getFraction(km);
         f.setTotal(total);
         f.setTotalRange(range);
     }
 
     public void setUnknown(double km, double unknown, Range range) {
+        if (range == null) {
+            logger.error("unknown/range is null!");
+            return;
+        }
         SedimentLoadFraction f = getFraction(km);
         f.setUnknown(unknown);
         f.setUnknownRange(range);


More information about the Dive4elements-commits mailing list