[Schmitzm-commits] r391 - branches/1.0-gt2-2.6/src/schmitzm/geotools/styling
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Sun Sep 13 11:09:06 CEST 2009
Author: alfonx
Date: 2009-09-13 11:09:05 +0200 (Sun, 13 Sep 2009)
New Revision: 391
Modified:
branches/1.0-gt2-2.6/src/schmitzm/geotools/styling/StylingUtil.java
Log:
* One more stream found to close in a finally block
Modified: branches/1.0-gt2-2.6/src/schmitzm/geotools/styling/StylingUtil.java
===================================================================
--- branches/1.0-gt2-2.6/src/schmitzm/geotools/styling/StylingUtil.java 2009-09-13 08:52:13 UTC (rev 390)
+++ branches/1.0-gt2-2.6/src/schmitzm/geotools/styling/StylingUtil.java 2009-09-13 09:09:05 UTC (rev 391)
@@ -891,9 +891,14 @@
*/
public static Style createStyleFromSLD(Element element) {
String xmlDefinition = new XMLOutputter().outputString(element);
- Style[] style = loadSLD(new ByteArrayInputStream(xmlDefinition
- .getBytes()));
- return style == null || style.length == 0 ? null : style[0];
+ ByteArrayInputStream inputStream = null;
+ try {
+ inputStream = new ByteArrayInputStream(xmlDefinition.getBytes());
+ Style[] style = loadSLD(inputStream);
+ return style == null || style.length == 0 ? null : style[0];
+ } finally {
+ IOUtils.closeQuietly(inputStream);
+ }
}
/**
@@ -1030,16 +1035,12 @@
stylereader = new SLDParser(StylingUtil.STYLE_FACTORY, inputStream);
Style[] styles = stylereader.readXML();
- if (styles[0] == null) {
+ if (styles == null || styles[0] == null) {
LOGGER
- .warn(" ... no Styles recognized in inputStream. Will return empty styles[] array!");
- } else {
- // LOGGER.debug(" ... loaded " + styles.length
- // + " styles from inputStream, first style's name= "
- // + styles[0].getName());
+ .warn(" ... no styles recognized. Return 'new Style[] { null }' ");
+ return new Style[] { null };
}
- // This is the main successful exit form loadSLD
return styles;
}
@@ -1453,22 +1454,6 @@
DuplicatingStyleVisitor duplicatingStyleVisitor = new DuplicatingStyleVisitor();
style.accept(duplicatingStyleVisitor);
return (Style) duplicatingStyleVisitor.getCopy();
-
- //
- // String xml;
- // try {
- // xml = SLDTRANSFORMER.transform(style);
- //
- // SLDParser stylereader;
- // stylereader = new SLDParser(StylingUtil.STYLE_FACTORY,
- // new StringInputStream(xml));
- // Style[] styles = stylereader.readXML();
- //
- // return styles[0];
- // } catch (TransformerException e) {
- // ExceptionMonitor.show(null, e);
- // return null;
- // }
}
/**
@@ -1478,33 +1463,6 @@
DuplicatingStyleVisitor duplicatingStyleVisitor = new DuplicatingStyleVisitor();
sym.accept(duplicatingStyleVisitor);
return (Symbolizer) duplicatingStyleVisitor.getCopy();
-
- // Style style = STYLE_BUILDER.createStyle(sym); // TODO Mag ich das?
- //
- // Filter allwaysTrueFilter = FilterUtil.FILTER_FAC2.equals(
- // FilterUtil.FILTER_FAC2.literal("1"), FilterUtil.FILTER_FAC2
- // .literal("1"));
- //
- // style.getFeatureTypeStyles()[0].getRules()[0]
- // .setFilter(allwaysTrueFilter);
- //
- // String xml;
- // try {
- // xml = SLDTRANSFORMER.transform(style);
- //
- // SLDParser stylereader;
- // stylereader = new SLDParser(StylingUtil.STYLE_FACTORY,
- // new StringInputStream(xml));
- // Style[] styles = stylereader.readXML();
- //
- // return (Symbolizer) styles[0].getFeatureTypeStyles()[0].getRules()[0]
- // .getSymbolizers()[0];
- // } catch (TransformerException e) {
- // ExceptionMonitor.show(null, e);
- // return STYLE_FACTORY.createPointSymbolizer(); // TODO Abhängig vom
- // // sym geometry type
- // }
-
}
/**
@@ -1519,31 +1477,6 @@
DuplicatingStyleVisitor duplicatingStyleVisitor = new DuplicatingStyleVisitor();
graphic.accept(duplicatingStyleVisitor);
return (Graphic) duplicatingStyleVisitor.getCopy();
-
- // try {
- // PointSymbolizer ps = STYLE_FACTORY.createPointSymbolizer(graphic,
- // "ACHTUNG");
- //
- // Style style = STYLE_BUILDER.createStyle(ps);
- //
- // final String xml = SLDTRANSFORMER.transform(style);
- //
- // SLDParser stylereader;
- // stylereader = new SLDParser(StylingUtil.STYLE_FACTORY,
- // new StringInputStream(xml));
- // Style[] styles = stylereader.readXML();
- //
- // PointSymbolizer clonedPs = (PointSymbolizer) styles[0]
- // .getFeatureTypeStyles()[0].getRules()[0].getSymbolizers()[0];
- //
- // Graphic clonedG = clonedPs.getGraphic();
- //
- // return clonedG;
- //
- // } catch (TransformerException e) {
- // LOGGER.error("Cloning a Graphic", e);
- // }
- // return null;
}
/**
More information about the Schmitzm-commits
mailing list