Mercurial > dive4elements > framework
view artifact-database/src/main/java/de/intevation/artifactdatabase/ProxyArtifact.java @ 87:0f48188a6e02
Added some javadoc to the artifactdatabase module. Not done yet.
artifacts/trunk@839 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Fri, 26 Mar 2010 11:40:28 +0000 |
parents | b2e0cb83631c |
children | d348fe1fd822 |
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; } public void setIdentifier(String identifier) { this.identifier = identifier; if (proxied != null) proxied.setIdentifier(identifier); } 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); } } public void cleanup(Object context) { if (proxied != null) proxied.cleanup(context); else super.cleanup(context); } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8: