changeset 7013:998a9710007e

issue1465: Do not allow null ranges for fraction values, logger.error instead.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Fri, 13 Sep 2013 16:07:46 +0200
parents 9f45c17e8fda
children 56891f61e534
files artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoad.java
diffstat 1 files changed, 42 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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);

http://dive4elements.wald.intevation.org