Mercurial > mxd2map
diff src/java/de/intevation/mxd/reader/ClassBreakRendererReader.java @ 116:c8a1361ddd38
Improved exceptionhandlin for renderer reader.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Wed, 15 Jun 2011 18:37:27 +0200 |
parents | 59e06c405a9a |
children | 0f5819732288 |
line wrap: on
line diff
--- a/src/java/de/intevation/mxd/reader/ClassBreakRendererReader.java Wed Jun 15 16:48:42 2011 +0200 +++ b/src/java/de/intevation/mxd/reader/ClassBreakRendererReader.java Wed Jun 15 18:37:27 2011 +0200 @@ -11,6 +11,7 @@ import org.w3c.dom.Element; import de.intevation.mxd.utils.MapToXMLUtils; +import java.io.IOException; /** * Reads the ClassBreaksRender Object Attributes. @@ -66,53 +67,72 @@ * * @return The XML node. */ - public Element read() - throws Exception { + public Element read() { logger.debug("read()"); - for(int i = 0; i < renderer.getBreakCount(); i++){ - Element rendererElement = util.addRenderer(layer); - rendererElement.setAttribute("value", - String.valueOf(renderer.getBreak(i))); - rendererElement.setAttribute( - "field_count", - String.valueOf(renderer.getFieldCount())); - for(int j = 0; j < renderer.getFieldCount(); j++) { - rendererElement.setAttribute( - "expression_field_" + j, - renderer.getField(j)); - - } - rendererElement.setAttribute( - "min_value", - String.valueOf(renderer.getMinimumBreak())); - rendererElement.setAttribute("expression_operator", "<="); + int count = 0; + try { + count = renderer.getBreakCount(); + } + catch(IOException ioe) { + logger.warn( + "No break symbols found in renderer." + + " Stopped reading this renderer."); + return layer; + } - ISymbol sym = renderer.getSymbol(i); - MarkerSymbolReader markerReader = new MarkerSymbolReader(); - LineSymbolReader lineReader = new LineSymbolReader(); - FillSymbolReader fillReader = new FillSymbolReader(); - if(markerReader.canRead(sym)) { - markerReader.setSymbol(sym); - markerReader.setUtil(util); - markerReader.setParent(rendererElement); - markerReader.read(); + for(int i = 0; i < count; i++){ + Element rendererElement = util.addRenderer(layer); + try { + rendererElement.setAttribute("value", + String.valueOf(renderer.getBreak(i))); + + rendererElement.setAttribute( + "field_count", + String.valueOf(renderer.getFieldCount())); + for(int j = 0; j < renderer.getFieldCount(); j++) { + rendererElement.setAttribute( + "expression_field_" + j, + renderer.getField(j)); + + } + rendererElement.setAttribute( + "min_value", + String.valueOf(renderer.getMinimumBreak())); + rendererElement.setAttribute("expression_operator", "<="); + + ISymbol sym = renderer.getSymbol(i); + MarkerSymbolReader markerReader = new MarkerSymbolReader(); + LineSymbolReader lineReader = new LineSymbolReader(); + FillSymbolReader fillReader = new FillSymbolReader(); + if(markerReader.canRead(sym)) { + markerReader.setSymbol(sym); + markerReader.setUtil(util); + markerReader.setParent(rendererElement); + markerReader.read(); + } + else if(lineReader.canRead(sym)) { + lineReader.setSymbol(sym); + lineReader.setUtil(util); + lineReader.setParent(rendererElement); + lineReader.read(); + } + else if(fillReader.canRead(sym)) { + fillReader.setSymbol(sym); + fillReader.setUtil(util); + fillReader.setParent(rendererElement); + fillReader.read(); + } + else { + logger.debug("Not a known symbol type: " + + sym.getClass().toString()); + } } - else if(lineReader.canRead(sym)) { - lineReader.setSymbol(sym); - lineReader.setUtil(util); - lineReader.setParent(rendererElement); - lineReader.read(); - } - else if(fillReader.canRead(sym)) { - fillReader.setSymbol(sym); - fillReader.setUtil(util); - fillReader.setParent(rendererElement); - fillReader.read(); - } - else { - logger.debug("Not a known symbol type: " + - sym.getClass().toString()); + catch(Exception e) { + logger.error( + "Could not read data for " + i + + ". break of renderer. Stopped reading this renderer."); + return layer; } } return layer;