Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/exports/AbstractExporter.java @ 8202:e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Fri, 05 Sep 2014 12:58:17 +0200 |
parents | 705f8b92fd66 |
children | 5e38e2924c07 |
comparison
equal
deleted
inserted
replaced
8201:4b8c5a08de04 | 8202:e4606eae8ea5 |
---|---|
42 * | 42 * |
43 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> | 43 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
44 */ | 44 */ |
45 public abstract class AbstractExporter implements OutGenerator { | 45 public abstract class AbstractExporter implements OutGenerator { |
46 | 46 |
47 /** The logger used in this exporter.*/ | 47 /** The log used in this exporter.*/ |
48 private static Logger logger = Logger.getLogger(AbstractExporter.class); | 48 private static Logger log = Logger.getLogger(AbstractExporter.class); |
49 | 49 |
50 /* XXX: Why does AbstractExporter do not implement FacetTypes? */ | 50 /* XXX: Why does AbstractExporter do not implement FacetTypes? */ |
51 public static String FIX_PARAMETERS = "fix_parameters"; | 51 public static String FIX_PARAMETERS = "fix_parameters"; |
52 | 52 |
53 /** The name of the CSV facet which triggers the CSV creation. */ | 53 /** The name of the CSV facet which triggers the CSV creation. */ |
138 * exported. | 138 * exported. |
139 */ | 139 */ |
140 protected abstract void addData(Object data); | 140 protected abstract void addData(Object data); |
141 | 141 |
142 public void setup(Object config) { | 142 public void setup(Object config) { |
143 logger.debug("AbstractExporter.setup"); | 143 log.debug("AbstractExporter.setup"); |
144 } | 144 } |
145 | 145 |
146 | 146 |
147 @Override | 147 @Override |
148 public void init( | 148 public void init( |
149 String outName, | 149 String outName, |
150 Document request, | 150 Document request, |
151 OutputStream out, | 151 OutputStream out, |
152 CallContext context | 152 CallContext context |
153 ) { | 153 ) { |
154 logger.debug("AbstractExporter.init"); | 154 log.debug("AbstractExporter.init"); |
155 | 155 |
156 this.outName = outName; | 156 this.outName = outName; |
157 this.request = request; | 157 this.request = request; |
158 this.out = out; | 158 this.out = out; |
159 this.context = context; | 159 this.context = context; |
196 ThemeDocument attr, | 196 ThemeDocument attr, |
197 boolean visible | 197 boolean visible |
198 ) { | 198 ) { |
199 String name = artifactFacet.getFacetName(); | 199 String name = artifactFacet.getFacetName(); |
200 | 200 |
201 logger.debug("AbstractExporter.doOut: " + name); | 201 log.debug("AbstractExporter.doOut: " + name); |
202 | 202 |
203 if (!isFacetValid(name)) { | 203 if (!isFacetValid(name)) { |
204 logger.warn("Facet '" + name + "' not valid. No output created!"); | 204 log.warn("Facet '" + name + "' not valid. No output created!"); |
205 return; | 205 return; |
206 } | 206 } |
207 | 207 |
208 addData(artifactFacet.getData(context)); | 208 addData(artifactFacet.getData(context)); |
209 } | 209 } |
214 */ | 214 */ |
215 @Override | 215 @Override |
216 public void generate() | 216 public void generate() |
217 throws IOException | 217 throws IOException |
218 { | 218 { |
219 logger.debug("AbstractExporter.generate"); | 219 log.debug("AbstractExporter.generate"); |
220 | 220 |
221 if (facet == null) { | 221 if (facet == null) { |
222 throw new IOException("invalid (null) facet for exporter"); | 222 throw new IOException("invalid (null) facet for exporter"); |
223 } | 223 } |
224 | 224 |
242 * @param facet The desired facet. | 242 * @param facet The desired facet. |
243 * | 243 * |
244 * @return true, if <i>facet</i> is valid, otherwise false. | 244 * @return true, if <i>facet</i> is valid, otherwise false. |
245 */ | 245 */ |
246 protected boolean isFacetValid(String facet) { | 246 protected boolean isFacetValid(String facet) { |
247 logger.debug("AbstractExporter.isFacetValid : " + facet + " (" + getFacet() + ")" ); | 247 log.debug("AbstractExporter.isFacetValid : " + facet + " (" + getFacet() + ")" ); |
248 | 248 |
249 String thisFacet = getFacet(); | 249 String thisFacet = getFacet(); |
250 | 250 |
251 if (thisFacet == null || thisFacet.length() == 0) { | 251 if (thisFacet == null || thisFacet.length() == 0) { |
252 return false; | 252 return false; |
306 * to be implemented by concrete subclasses. | 306 * to be implemented by concrete subclasses. |
307 */ | 307 */ |
308 protected void generateCSV() | 308 protected void generateCSV() |
309 throws IOException | 309 throws IOException |
310 { | 310 { |
311 logger.info("AbstractExporter.generateCSV"); | 311 log.info("AbstractExporter.generateCSV"); |
312 | 312 |
313 char quote = '"'; | 313 char quote = '"'; |
314 char escape = '\\'; | 314 char escape = '\\'; |
315 | 315 |
316 CSVWriter writer = new CSVWriter( | 316 CSVWriter writer = new CSVWriter( |
329 * This method starts PDF creation. | 329 * This method starts PDF creation. |
330 */ | 330 */ |
331 protected void generatePDF() | 331 protected void generatePDF() |
332 throws IOException | 332 throws IOException |
333 { | 333 { |
334 logger.info("AbstractExporter.generatePDF"); | 334 log.info("AbstractExporter.generatePDF"); |
335 writePDF(this.out); | 335 writePDF(this.out); |
336 } | 336 } |
337 | 337 |
338 | 338 |
339 /** | 339 /** |