Mercurial > dive4elements > river
view flys-artifacts/src/main/java/de/intevation/flys/exports/ATExporter.java @ 1072:80aecb01d79a
Let MainValuesArtifact have a state, outputmode and facet.
flys-artifacts/trunk@2556 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Wed, 24 Aug 2011 12:07:33 +0000 |
parents | 97d774d58e24 |
children | 7d11ad5a52d5 |
line wrap: on
line source
package de.intevation.flys.exports; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.IOException; import org.w3c.dom.Document; import org.apache.log4j.Logger; import de.intevation.artifacts.Artifact; import de.intevation.artifacts.CallContext; import de.intevation.flys.artifacts.FLYSArtifact; import de.intevation.artifactdatabase.state.Facet; import de.intevation.flys.artifacts.model.WQ; public class ATExporter implements OutGenerator { private static Logger logger = Logger.getLogger(ATExporter.class); public static final String DEFAULT_ENCODING = "UTF-8"; protected WQ data; protected CallContext context; protected OutputStream out; public ATExporter() { } @Override public void init(Document request, OutputStream out, CallContext context) { this.context = context; this.out = out; } @Override public void setMasterArtifact(Artifact master) { // not needed } @Override public void doOut(Artifact artifact, Facet facet, Document attr) { FLYSArtifact flys = (FLYSArtifact)artifact; if ((facet = flys.getNativeFacet(facet)) == null) { logger.debug("native facet not found."); return; } data = (WQ)facet.getData(flys, context); } @Override public void generate() throws IOException { if (data == null) { logger.debug("no W/Q data"); return; } ATWriter at; try { at = new ATWriter(data); } catch (IllegalArgumentException iae) { logger.error("creating ATWriter failed", iae); throw new IOException(iae); } at.write(new OutputStreamWriter(out, DEFAULT_ENCODING)); } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :