diff src/java/de/intevation/mxd/reader/LineSymbolReader.java @ 115:fb93f20478cc

Improved exception handling for symbol reader.
author Raimund Renkert <rrenkert@intevation.de>
date Wed, 15 Jun 2011 16:48:42 +0200
parents 2cbe423b1fda
children f4eb506499f5
line wrap: on
line diff
--- a/src/java/de/intevation/mxd/reader/LineSymbolReader.java	Wed Jun 15 16:13:32 2011 +0200
+++ b/src/java/de/intevation/mxd/reader/LineSymbolReader.java	Wed Jun 15 16:48:42 2011 +0200
@@ -50,56 +50,72 @@
         this.symbol= null;
     }
 
-    public Element read() throws Exception {
+    public Element read() {
         ISymbolReader sreader = null;
         if(symbol != null) {
-            if(symbol instanceof SimpleLineSymbol) {
-                sreader = new SimpleLineSymbolReader(symbol);
-            }
-            else if(symbol instanceof MarkerLineSymbol) {
-                sreader = new MarkerLineSymbolReader(symbol);
-            }
-            else if(symbol instanceof PictureLineSymbol) {
-                sreader = new PictureLineSymbolReader(symbol);
+            try {
+                if(symbol instanceof SimpleLineSymbol) {
+                    sreader = new SimpleLineSymbolReader(symbol);
+                }
+                else if(symbol instanceof MarkerLineSymbol) {
+                    sreader = new MarkerLineSymbolReader(symbol);
+                }
+                else if(symbol instanceof PictureLineSymbol) {
+                    sreader = new PictureLineSymbolReader(symbol);
+                }
+                else if(symbol instanceof MultiLayerLineSymbol) {
+                    sreader = new MultiLayerLineSymbolReader(symbol);
+                }
+                else if(symbol instanceof CartographicLineSymbol) {
+                    sreader = new CartoLineSymbolReader(symbol);
+                }
+                else if(symbol instanceof HashLineSymbol) {
+                    sreader = new HashLineSymbolReader(symbol);
+                }
+                else {
+                    logger.debug("The reader for type " + symbol.getClass().toString() +
+                                 " is not implemented!");
+                    return parent;
+                }
             }
-            else if(symbol instanceof MultiLayerLineSymbol) {
-                sreader = new MultiLayerLineSymbolReader(symbol);
-            }
-            else if(symbol instanceof CartographicLineSymbol) {
-                sreader = new CartoLineSymbolReader(symbol);
-            }
-            else if(symbol instanceof HashLineSymbol) {
-                sreader = new HashLineSymbolReader(symbol);
-            }
-            else {
-                logger.debug("The reader for type " + symbol.getClass().toString() +
-                             " is not implemented!");
+            catch(Exception e) {
+                logger.error(
+                    "Could not read the symbol " +
+                    symbol.getClass().toString());
                 return parent;
             }
         }
         else if(lineSymbol != null) {
-            if(lineSymbol instanceof SimpleLineSymbol) {
-                sreader = new SimpleLineSymbolReader(lineSymbol);
-            }
-            else if(lineSymbol instanceof MarkerLineSymbol) {
-                sreader = new MarkerLineSymbolReader(lineSymbol);
-            }
-            else if(lineSymbol instanceof PictureLineSymbol) {
-                sreader = new PictureLineSymbolReader(lineSymbol);
+            try {
+                if(lineSymbol instanceof SimpleLineSymbol) {
+                    sreader = new SimpleLineSymbolReader(lineSymbol);
+                }
+                else if(lineSymbol instanceof MarkerLineSymbol) {
+                    sreader = new MarkerLineSymbolReader(lineSymbol);
+                }
+                else if(lineSymbol instanceof PictureLineSymbol) {
+                    sreader = new PictureLineSymbolReader(lineSymbol);
+                }
+                else if(lineSymbol instanceof MultiLayerLineSymbol) {
+                    sreader = new MultiLayerLineSymbolReader(lineSymbol);
+                }
+                else if(lineSymbol instanceof CartographicLineSymbol) {
+                    sreader = new CartoLineSymbolReader(lineSymbol);
+                }
+                else if(lineSymbol instanceof HashLineSymbol) {
+                    sreader = new HashLineSymbolReader(lineSymbol);
+                }
+                else {
+                    logger.debug("The reader for type " +
+                                 lineSymbol.getClass().toString() +
+                                 " is not implemented!");
+                    return parent;
+                }
             }
-            else if(lineSymbol instanceof MultiLayerLineSymbol) {
-                sreader = new MultiLayerLineSymbolReader(lineSymbol);
-            }
-            else if(lineSymbol instanceof CartographicLineSymbol) {
-                sreader = new CartoLineSymbolReader(lineSymbol);
-            }
-            else if(lineSymbol instanceof HashLineSymbol) {
-                sreader = new HashLineSymbolReader(lineSymbol);
-            }
-            else {
-                logger.debug("The reader for type " +
-                             lineSymbol.getClass().toString() +
-                             " is not implemented!");
+            catch(Exception e) {
+                logger.error(
+                    "Could not read the symbol " +
+                    symbol.getClass().toString());
                 return parent;
             }
         }
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)