Mercurial > mxd2map
diff src/java/de/intevation/mxd/reader/UniqueValueRendererReader.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 | 6c3d880db7c5 |
line wrap: on
line diff
--- a/src/java/de/intevation/mxd/reader/UniqueValueRendererReader.java Wed Jun 15 16:48:42 2011 +0200 +++ b/src/java/de/intevation/mxd/reader/UniqueValueRendererReader.java Wed Jun 15 18:37:27 2011 +0200 @@ -7,6 +7,7 @@ import com.esri.arcgis.carto.UniqueValueRenderer; import org.w3c.dom.Element; +import java.io.IOException; import de.intevation.mxd.utils.MapToXMLUtils; @@ -66,53 +67,68 @@ * * @return The parent XML node. */ - public Element read() - throws Exception { + public Element read() { logger.debug("read()"); - for(int i = 0; i < renderer.getClassCount() - 1; i++) { + int count = 0; + try { + count = renderer.getClassCount(); + } + catch(IOException ioe) { + logger.error("Could not read class count. Stopped reading renderer."); + return layer; + } + for(int i = 0; i < count - 1; i++) { Element rendererElement = util.addRenderer(layer); - String value = renderer.getValue(i); - rendererElement.setAttribute("name", renderer.esri_getClass(i)); - rendererElement.setAttribute("description", - renderer.getDescription(value)); - rendererElement.setAttribute("value", value); - rendererElement.setAttribute("label", renderer.getLabel(value)); - rendererElement.setAttribute( - "field_count", - String.valueOf(renderer.getFieldCount())); - for(int j = 0; j < renderer.getFieldCount(); j++) { + try { + String value = renderer.getValue(i); + rendererElement.setAttribute("name", renderer.esri_getClass(i)); + rendererElement.setAttribute("description", + renderer.getDescription(value)); + rendererElement.setAttribute("value", value); + rendererElement.setAttribute("label", renderer.getLabel(value)); rendererElement.setAttribute( - "expression_field_" + j, - renderer.getField(j)); - } - rendererElement.setAttribute("expression_operator", "="); + "field_count", + String.valueOf(renderer.getFieldCount())); + for(int j = 0; j < renderer.getFieldCount(); j++) { + rendererElement.setAttribute( + "expression_field_" + j, + renderer.getField(j)); + } + rendererElement.setAttribute("expression_operator", "="); - ISymbol sym = renderer.getSymbol(value); - 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(); + ISymbol sym = renderer.getSymbol(value); + 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 unique value data." + + e.toString()); + return layer; } } return layer;