diff src/java/de/intevation/mxd/writer/LineStyleWriter.java @ 145:b2c5a66022f1

Exception handling for number conversions in writer modules.
author Raimund Renkert <rrenkert@intevation.de>
date Mon, 27 Jun 2011 18:22:21 +0200
parents 8f30f7e802d6
children 03daf386f19a
line wrap: on
line diff
--- a/src/java/de/intevation/mxd/writer/LineStyleWriter.java	Mon Jun 27 17:22:52 2011 +0200
+++ b/src/java/de/intevation/mxd/writer/LineStyleWriter.java	Mon Jun 27 18:22:21 2011 +0200
@@ -43,16 +43,27 @@
         logger.debug("write(Element)");
         symbolSetObj symbolSet = map.getSymbolset();
         if(symbolElement.hasAttribute("width")) {
-            double w = Double.parseDouble(symbolElement.getAttribute("width"));
+            double w = 0;
+            try {
+                w = Double.parseDouble(symbolElement.getAttribute("width"));
+            }
+            catch(NumberFormatException nfe) {
+                logger.warn("Error setting width. No line width set.");
+                w = 0;
+            }
             if(w < 1.0) {
                 return false;
             }
-            style.setWidth((int)Double.parseDouble(
-                symbolElement.getAttribute("width")));
+            style.setWidth((int)w);
         }
         if(symbolElement.hasAttribute("angle")) {
-            style.setAngle(
-                Double.parseDouble(symbolElement.getAttribute("angle")));
+            try {
+                style.setAngle(
+                    Double.parseDouble(symbolElement.getAttribute("angle")));
+            }
+            catch(NumberFormatException nfe) {
+                logger.info("Error setting angle. Could not get value.");
+            }
         }
         if(symbolElement.hasAttribute("color")) {
             String c = symbolElement.getAttribute("color");
@@ -66,8 +77,14 @@
         }
 
         if(symbolElement.hasAttribute("size")) {
-            style.setSize((int)Double.parseDouble(
-                symbolElement.getAttribute("size")));
+            try {
+                style.setSize((int)Double.parseDouble(
+                    symbolElement.getAttribute("size")));
+            }
+            catch(NumberFormatException nfe) {
+                logger.warn("Error setting size. Setting size to 1.");
+                style.setSize (1);
+            }
         }
         String type = symbolElement.getAttribute("type");
         if(type.equals("marker")) {
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)