Mercurial > dive4elements > framework
view artifact-database/src/main/java/de/intevation/artifactdatabase/ProxyArtifact.java @ 79:f69e5b87f05f
Implementation to export artifacts as xml (applied patch from issue208 by SLT).
artifacts/trunk@792 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Tue, 16 Mar 2010 16:03:06 +0000 |
parents | 48d1a9a082c2 |
children | e9c80fdfee13 |
line wrap: on
line source
package de.intevation.artifactdatabase; import org.w3c.dom.Document; import de.intevation.artifacts.Artifact; import de.intevation.artifacts.CallContext; import org.apache.log4j.Logger; import java.io.IOException; import java.io.OutputStream; /** * @author <a href="mailto:sascha.teichmann@intevation.de">Sascha L. Teichmann</a> */ public class ProxyArtifact extends DefaultArtifact { public static final Object REPLACE_PROXY = new Object(); private static Logger logger = Logger.getLogger(ProxyArtifact.class); protected Artifact proxied; public ProxyArtifact() { } public ProxyArtifact(Artifact proxied) { this.proxied = proxied; } public Artifact getProxied() { return proxied; } public void setProxied(Artifact proxied) { this.proxied = proxied; } protected void checkReplacement(CallContext callContext) { Object replacement = callContext.getContextValue(REPLACE_PROXY); if (replacement instanceof Artifact) { setProxied((Artifact)replacement); } } public String hash() { return proxied != null ? proxied.hash() : super.hash(); } public Document describe(Document data, CallContext context) { try { return proxied != null ? proxied.describe(data, context) : super.describe(data, context); } finally { checkReplacement(context); } } public Document advance(Document target, CallContext context) { try { return proxied != null ? proxied.advance(target, context) : super.advance(target, context); } finally { checkReplacement(context); } } public Document feed(Document target, CallContext context) { try { return proxied != null ? proxied.feed(target, context) : super.feed(target, context); } finally { checkReplacement(context); } } public void out( Document format, OutputStream out, CallContext context ) throws IOException { try { if (proxied != null) { proxied.out(format, out, context); } else { super.out(format, out, context); } } finally { checkReplacement(context); } } public void endOfLife(Object context) { if (proxied != null) { proxied.endOfLife(context); } else { super.endOfLife(context); } } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8: