diff src/java/de/intevation/mxd/reader/MarkerSymbolReader.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 9ea64427ac7e
children f4eb506499f5
line wrap: on
line diff
--- a/src/java/de/intevation/mxd/reader/MarkerSymbolReader.java	Wed Jun 15 16:13:32 2011 +0200
+++ b/src/java/de/intevation/mxd/reader/MarkerSymbolReader.java	Wed Jun 15 16:48:42 2011 +0200
@@ -51,53 +51,70 @@
         this.markerSymbol = null;
     }
 
-    public Element read()
-    throws Exception {
+    public Element read() {
         logger.debug("read()");
         ISymbolReader sreader = null;
 
         if(symbol != null) {
-            if(symbol instanceof SimpleMarkerSymbol) {
-                sreader = new SimpleMarkerSymbolReader(symbol);
-            }
-            else if(symbol instanceof ArrowMarkerSymbol) {
-                sreader = new ArrowMarkerSymbolReader(symbol);
-            }
-            else if(symbol instanceof CharacterMarkerSymbol) {
-                sreader = new CharacterMarkerSymbolReader(symbol);
+            try {
+                if(symbol instanceof SimpleMarkerSymbol) {
+                    sreader = new SimpleMarkerSymbolReader(symbol);
+                }
+                else if(symbol instanceof ArrowMarkerSymbol) {
+                    sreader = new ArrowMarkerSymbolReader(symbol);
+                }
+                else if(symbol instanceof CharacterMarkerSymbol) {
+                    sreader = new CharacterMarkerSymbolReader(symbol);
+                }
+                else if(symbol instanceof PictureMarkerSymbol) {
+                    sreader = new PictureMarkerSymbolReader(symbol);
+                }
+                else if(symbol instanceof MultiLayerMarkerSymbol) {
+                    sreader = new MultiLayerMarkerSymbolReader(symbol);
+                }
+                else {
+                    logger.debug("The reader for type " + symbol.getClass().toString() +
+                                 " is not implemented!");
+                    return parent;
+                }
             }
-            else if(symbol instanceof PictureMarkerSymbol) {
-                sreader = new PictureMarkerSymbolReader(symbol);
-            }
-            else if(symbol instanceof MultiLayerMarkerSymbol) {
-                sreader = new MultiLayerMarkerSymbolReader(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(markerSymbol != null) {
-            if(markerSymbol instanceof SimpleMarkerSymbol) {
-                sreader = new SimpleMarkerSymbolReader(markerSymbol);
-            }
-            else if(markerSymbol instanceof ArrowMarkerSymbol) {
-                sreader = new ArrowMarkerSymbolReader(markerSymbol);
-            }
-            else if(markerSymbol instanceof CharacterMarkerSymbol) {
-                sreader = new CharacterMarkerSymbolReader(markerSymbol);
+            try {
+                if(markerSymbol instanceof SimpleMarkerSymbol) {
+                    sreader = new SimpleMarkerSymbolReader(markerSymbol);
+                }
+                else if(markerSymbol instanceof ArrowMarkerSymbol) {
+                    sreader = new ArrowMarkerSymbolReader(markerSymbol);
+                }
+                else if(markerSymbol instanceof CharacterMarkerSymbol) {
+                    sreader = new CharacterMarkerSymbolReader(markerSymbol);
+                }
+                else if(markerSymbol instanceof PictureMarkerSymbol) {
+                    sreader = new PictureMarkerSymbolReader(markerSymbol);
+                }
+                else if(markerSymbol instanceof MultiLayerMarkerSymbol) {
+                    sreader = new MultiLayerMarkerSymbolReader(markerSymbol);
+                }
+                else {
+                    logger.debug("The reader for type " + symbol.getClass().toString() +
+                                 " is not implemented!");
+                    return parent;
+                }
             }
-            else if(markerSymbol instanceof PictureMarkerSymbol) {
-                sreader = new PictureMarkerSymbolReader(markerSymbol);
-            }
-            else if(markerSymbol instanceof MultiLayerMarkerSymbol) {
-                sreader = new MultiLayerMarkerSymbolReader(markerSymbol);
-            }
-            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;
+
             }
         }
         if (sreader != null) {
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)