Mercurial > dive4elements > framework
view artifact-database/src/main/java/de/intevation/artifactdatabase/ProxyArtifact.java @ 62:76abf0c64d3b
Added XML utils method to load XML file from file.
artifacts/trunk@438 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Wed, 16 Dec 2009 08:08:56 +0000 |
parents | 85d996328c8a |
children | 48d1a9a082c2 |
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 Sascha L. Teichmann (sascha.teichmann@intevation.de) */ 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: