Mercurial > dive4elements > river
diff flys-artifacts/src/main/java/de/intevation/flys/artifacts/datacage/templating/Builder.java @ 1818:e3eb1ea885a7
Simplified code in Datacage builder by using the new pair.
flys-artifacts/trunk@3147 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Thu, 03 Nov 2011 09:58:04 +0000 |
parents | 3ca999f507b7 |
children | 755d9763928f |
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/datacage/templating/Builder.java Thu Nov 03 09:47:52 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/datacage/templating/Builder.java Thu Nov 03 09:58:04 2011 +0000 @@ -26,6 +26,8 @@ import de.intevation.artifacts.common.utils.XMLUtils; +import de.intevation.flys.utils.Pair; + import org.apache.log4j.Logger; public class Builder @@ -82,13 +84,12 @@ public class BuildHelper { - protected Node output; - protected Document owner; - protected StackFrames frames; - protected List<NamedConnection> connections; - protected Map<String, CompiledStatement.Instance> statements; - protected Deque<NamedConnection> connectionsStack; - protected Deque<ResultData> resultsStack; + protected Node output; + protected Document owner; + protected StackFrames frames; + protected List<NamedConnection> connections; + protected Map<String, CompiledStatement.Instance> statements; + protected Deque<Pair<NamedConnection, ResultData>> connectionsStack; public BuildHelper( Node output, @@ -100,8 +101,8 @@ } this.connections = connections; - connectionsStack = new ArrayDeque<NamedConnection>(); - resultsStack = new ArrayDeque<ResultData>(); + connectionsStack = + new ArrayDeque<Pair<NamedConnection, ResultData>>(); this.output = output; frames = new StackFrames(parameters); owner = getOwnerDocument(output); @@ -172,7 +173,7 @@ NamedConnection connection = connectionsStack.isEmpty() ? connections.get(0) - : connectionsStack.peek(); + : connectionsStack.peek().getA(); if (con.length() > 0) { for (NamedConnection nc: connections) { @@ -190,8 +191,7 @@ // only descent if there are results if (!rd.isEmpty()) { - resultsStack.push(rd); - connectionsStack.push(connection); + connectionsStack.push(new Pair(connection, rd)); try { for (int i = 0; i < S; ++i) { build(parent, subs.item(i)); @@ -199,7 +199,6 @@ } finally { connectionsStack.pop(); - resultsStack.pop(); } } } @@ -209,7 +208,7 @@ { log.debug("dc:elements"); - if (resultsStack.isEmpty()) { + if (connectionsStack.isEmpty()) { log.warn("dc:elements without having results"); return; } @@ -222,7 +221,7 @@ return; } - ResultData rd = resultsStack.peek(); + ResultData rd = connectionsStack.peek().getB(); String [] columns = rd.getColumnLabels();