Mercurial > dive4elements > river
diff flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/meta/Builder.java @ 972:0c8aca463bd4
Added caching support for the static part of the datacage.
flys-artifacts/trunk@2398 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Fri, 22 Jul 2011 16:55:36 +0000 |
parents | f48cef242e7f |
children | c30ada285d45 |
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/meta/Builder.java Fri Jul 22 11:18:00 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/meta/Builder.java Fri Jul 22 16:55:36 2011 +0000 @@ -1,5 +1,6 @@ package de.intevation.flys.artifacts.services.meta; +import java.util.regex.Pattern; import java.util.regex.Matcher; import java.util.ArrayList; @@ -28,6 +29,9 @@ { private static Logger log = Logger.getLogger(Builder.class); + public static final Pattern STRIP_LINE_INDENT = + Pattern.compile("\\s*\\r?\\n\\s*"); + public static final String DC_NAMESPACE_URI = "http://www.intevation.org/2011/Datacage"; @@ -39,11 +43,6 @@ protected Document template; - protected static Document getOwnerDocument(Node node) { - Document document = node.getOwnerDocument(); - return document != null ? document : (Document)node; - } - public class BuildHelper { @@ -109,7 +108,7 @@ String stmntText = stmntNode.item(0).getTextContent(); if (stmntText == null - || (stmntText = stmntText.trim()).length() == 0) { + || (stmntText = trimStatement(stmntText)).length() == 0) { log.warn("dc:context: no sql statement found -> ignored"); return; } @@ -335,17 +334,23 @@ } else { String localName = current.getLocalName(); - if ("context".equals(localName)) { + if ("attribute".equals(localName)) { + attribute(parent, (Element)current); + } + else if ("context".equals(localName)) { context(parent, (Element)current); } + else if ("if".equals(localName)) { + ifClause(parent, (Element)current); + } else if ("choose".equals(localName)) { choose(parent, (Element)current); } - else if ("if".equals(localName)) { - ifClause(parent, (Element)current); + else if ("call-macro".equals(localName)) { + callMacro(parent, (Element)current); } - else if ("attribute".equals(localName)) { - attribute(parent, (Element)current); + else if ("macro".equals(localName)) { + // simply ignore the definition. } else if ("element".equals(localName)) { element(parent, (Element)current); @@ -356,12 +361,6 @@ else if ("convert".equals(localName)) { convert(parent, (Element)current); } - else if ("call-macro".equals(localName)) { - callMacro(parent, (Element)current); - } - else if ("macro".equals(localName)) { - // simply ignore the definition. - } else { log.warn("unknown '" + localName + "' -> ignore"); } @@ -411,6 +410,16 @@ return elements; } + protected static final String trimStatement(String stmnt) { + //XXX: Maybe a bit to radical for multiline strings? + return STRIP_LINE_INDENT.matcher(stmnt.trim()).replaceAll(" "); + } + + protected static Document getOwnerDocument(Node node) { + Document document = node.getOwnerDocument(); + return document != null ? document : (Document)node; + } + public void build( Connection connection, Node output,