Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/datacage/templating/Builder.java @ 1890:9144e5a5027b
(Picky) cosmetics.
flys-artifacts/trunk@3250 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Tue, 15 Nov 2011 14:15:31 +0000 |
parents | 755d9763928f |
children | 5642a83420f2 |
comparison
equal
deleted
inserted
replaced
1889:ad22fc70bdab | 1890:9144e5a5027b |
---|---|
128 csi.close(); | 128 csi.close(); |
129 } | 129 } |
130 statements.clear(); | 130 statements.clear(); |
131 } | 131 } |
132 | 132 |
133 /** | |
134 * Handle a \<context\> node. | |
135 */ | |
133 protected void context(Node parent, Element current) | 136 protected void context(Node parent, Element current) |
134 throws SQLException | 137 throws SQLException |
135 { | 138 { |
136 log.debug("dc:context"); | 139 log.debug("dc:context"); |
137 | 140 |
142 Node stmntNode = null; | 145 Node stmntNode = null; |
143 for (int i = 0; i < S; ++i) { | 146 for (int i = 0; i < S; ++i) { |
144 Node node = subs.item(i); | 147 Node node = subs.item(i); |
145 String ns; | 148 String ns; |
146 if (node.getNodeType() == Node.ELEMENT_NODE | 149 if (node.getNodeType() == Node.ELEMENT_NODE |
147 && node.getLocalName().equals("statement") | 150 && node.getLocalName().equals("statement") |
148 && (ns = node.getNamespaceURI()) != null | 151 && (ns = node.getNamespaceURI()) != null |
149 && ns.equals(DC_NAMESPACE_URI)) { | 152 && ns.equals(DC_NAMESPACE_URI)) { |
150 stmntNode = node; | 153 stmntNode = node; |
151 break; | 154 break; |
152 } | 155 } |
155 if (stmntNode == null) { | 158 if (stmntNode == null) { |
156 log.warn("dc:context: cannot find statement"); | 159 log.warn("dc:context: cannot find statement"); |
157 return; | 160 return; |
158 } | 161 } |
159 | 162 |
163 String stmntText = stmntNode.getTextContent(); | |
164 | |
160 String con = current.getAttribute("connection"); | 165 String con = current.getAttribute("connection"); |
161 | |
162 String stmntText = stmntNode.getTextContent(); | |
163 | 166 |
164 String key = con + "-" + stmntText; | 167 String key = con + "-" + stmntText; |
165 | 168 |
166 CompiledStatement.Instance csi = statements.get(key); | 169 CompiledStatement.Instance csi = statements.get(key); |
167 | 170 |
201 connectionsStack.pop(); | 204 connectionsStack.pop(); |
202 } | 205 } |
203 } | 206 } |
204 } | 207 } |
205 | 208 |
209 /** | |
210 * Kind of foreach over results of a statement within a context. | |
211 */ | |
206 protected void elements(Node parent, Element current) | 212 protected void elements(Node parent, Element current) |
207 throws SQLException | 213 throws SQLException |
208 { | 214 { |
209 log.debug("dc:elements"); | 215 log.debug("dc:elements"); |
210 | 216 |
245 frames.leave(); | 251 frames.leave(); |
246 } | 252 } |
247 } | 253 } |
248 } | 254 } |
249 | 255 |
256 /** | |
257 * Create element. | |
258 */ | |
250 protected void element(Node parent, Element current) | 259 protected void element(Node parent, Element current) |
251 throws SQLException | 260 throws SQLException |
252 { | 261 { |
253 String attr = expand(current.getAttribute("name")); | 262 String attr = expand(current.getAttribute("name")); |
254 | 263 |
277 log.debug("dc:text"); | 286 log.debug("dc:text"); |
278 String value = expand(current.getTextContent()); | 287 String value = expand(current.getTextContent()); |
279 parent.appendChild(owner.createTextNode(value)); | 288 parent.appendChild(owner.createTextNode(value)); |
280 } | 289 } |
281 | 290 |
282 | 291 /** |
292 * Add attribute to an element | |
293 * @see element | |
294 */ | |
283 protected void attribute(Node parent, Element current) { | 295 protected void attribute(Node parent, Element current) { |
284 | 296 |
285 if (parent.getNodeType() != Node.ELEMENT_NODE) { | 297 if (parent.getNodeType() != Node.ELEMENT_NODE) { |
286 log.warn("need element here"); | 298 log.warn("need element here"); |
287 return; | 299 return; |
307 | 319 |
308 NodeList macros = template.getElementsByTagNameNS( | 320 NodeList macros = template.getElementsByTagNameNS( |
309 DC_NAMESPACE_URI, "macro"); | 321 DC_NAMESPACE_URI, "macro"); |
310 | 322 |
311 for (int i = 0, N = macros.getLength(); i < N; ++i) { | 323 for (int i = 0, N = macros.getLength(); i < N; ++i) { |
312 Element macro = (Element)macros.item(i); | 324 Element macro = (Element) macros.item(i); |
313 if (name.equals(macro.getAttribute("name"))) { | 325 if (name.equals(macro.getAttribute("name"))) { |
314 NodeList subs = macro.getChildNodes(); | 326 NodeList subs = macro.getChildNodes(); |
315 for (int j = 0, M = subs.getLength(); j < M; ++j) { | 327 for (int j = 0, M = subs.getLength(); j < M; ++j) { |
316 build(parent, subs.item(j)); | 328 build(parent, subs.item(j)); |
317 } | 329 } |