annotate artifact-database/src/main/java/de/intevation/artifactdatabase/Config.java @ 91:730ff077a58c

More javadoc, some code formatting. artifacts/trunk@847 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Sun, 28 Mar 2010 10:01:03 +0000
parents 8447467cef86
children e27cf9c84eb8
rev   line source
5
8f2de197bce2 Added config to artifact database and modelled bootstap of artifact factories on top of this.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1 package de.intevation.artifactdatabase;
8f2de197bce2 Added config to artifact database and modelled bootstap of artifact factories on top of this.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
2
8f2de197bce2 Added config to artifact database and modelled bootstap of artifact factories on top of this.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
3 import java.io.File;
8f2de197bce2 Added config to artifact database and modelled bootstap of artifact factories on top of this.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
4 import java.io.IOException;
8f2de197bce2 Added config to artifact database and modelled bootstap of artifact factories on top of this.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
5
8f2de197bce2 Added config to artifact database and modelled bootstap of artifact factories on top of this.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
6 import org.w3c.dom.Document;
8f2de197bce2 Added config to artifact database and modelled bootstap of artifact factories on top of this.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
7 import org.w3c.dom.NodeList;
9
a5a279a0ee35 Laid tracks for artifacts being removed from artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 5
diff changeset
8 import org.w3c.dom.Node;
5
8f2de197bce2 Added config to artifact database and modelled bootstap of artifact factories on top of this.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
9
8f2de197bce2 Added config to artifact database and modelled bootstap of artifact factories on top of this.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
10 import org.xml.sax.SAXException;
8f2de197bce2 Added config to artifact database and modelled bootstap of artifact factories on top of this.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
11
8f2de197bce2 Added config to artifact database and modelled bootstap of artifact factories on top of this.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
12 import javax.xml.parsers.DocumentBuilderFactory;
8f2de197bce2 Added config to artifact database and modelled bootstap of artifact factories on top of this.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
13 import javax.xml.parsers.ParserConfigurationException;
8f2de197bce2 Added config to artifact database and modelled bootstap of artifact factories on top of this.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
14
8f2de197bce2 Added config to artifact database and modelled bootstap of artifact factories on top of this.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
15 import javax.xml.namespace.QName;
8f2de197bce2 Added config to artifact database and modelled bootstap of artifact factories on top of this.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
16
8f2de197bce2 Added config to artifact database and modelled bootstap of artifact factories on top of this.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
17 import javax.xml.xpath.XPathConstants;
8f2de197bce2 Added config to artifact database and modelled bootstap of artifact factories on top of this.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
18
17
5a6b6a3debc7 Integrated logging into artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 13
diff changeset
19 import org.apache.log4j.Logger;
5a6b6a3debc7 Integrated logging into artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 13
diff changeset
20
10
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 9
diff changeset
21 /**
91
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
22 * The central access to the configuration of the artifact database.
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
23 * This class provides some static methods to access the central
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
24 * configuration XML file via XPath.
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
25 *
80
8447467cef86 Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 61
diff changeset
26 * @author <a href="mailto:sascha.teichmann@intevation.de">Sascha L. Teichmann</a>
10
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 9
diff changeset
27 */
5
8f2de197bce2 Added config to artifact database and modelled bootstap of artifact factories on top of this.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
28 public final class Config
8f2de197bce2 Added config to artifact database and modelled bootstap of artifact factories on top of this.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
29 {
17
5a6b6a3debc7 Integrated logging into artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 13
diff changeset
30 private static Logger logger = Logger.getLogger(Config.class);
5a6b6a3debc7 Integrated logging into artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 13
diff changeset
31
91
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
32 /**
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
33 * System property name where to find the configuration directory.
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
34 */
19
1259d192e3c3 * New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 17
diff changeset
35 public static final String CONFIG_DIR = "artifact.database.dir";
5
8f2de197bce2 Added config to artifact database and modelled bootstap of artifact factories on top of this.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
36
91
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
37 /**
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
38 * Default path to the configuration directory if none
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
39 * was specified by the CONFIG_DIR system property.
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
40 */
19
1259d192e3c3 * New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 17
diff changeset
41 public static final File CONFIG_DIR_DEFAULT =
1259d192e3c3 * New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 17
diff changeset
42 new File(new File(System.getProperty("user.home",
1259d192e3c3 * New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 17
diff changeset
43 System.getProperty("user.dir", "."))), ".artifactdb");
1259d192e3c3 * New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 17
diff changeset
44
91
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
45 /**
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
46 * Name of the central configuration XML file.
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
47 */
19
1259d192e3c3 * New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 17
diff changeset
48 public static final String CONFIG_FILE = "conf.xml";
5
8f2de197bce2 Added config to artifact database and modelled bootstap of artifact factories on top of this.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
49
91
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
50 /**
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
51 * Name of the configuration filename alias to be use
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
52 * within the configuration. This alias is replaced by
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
53 * the real path.
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
54 */
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
55 public static final String CONFIG_DIR_PLACEHOLDER =
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
56 "${artifacts.config.dir}";
54
c2fc85e55f9f Applied patch from slt to set the Configuration Folder into the AbsoluteFileName issue59
Tim Englich <tim.englich@intevation.de>
parents: 25
diff changeset
57
5
8f2de197bce2 Added config to artifact database and modelled bootstap of artifact factories on top of this.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
58 private static Document config;
8f2de197bce2 Added config to artifact database and modelled bootstap of artifact factories on top of this.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
59
8f2de197bce2 Added config to artifact database and modelled bootstap of artifact factories on top of this.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
60 private Config() {
8f2de197bce2 Added config to artifact database and modelled bootstap of artifact factories on top of this.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
61 }
8f2de197bce2 Added config to artifact database and modelled bootstap of artifact factories on top of this.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
62
91
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
63 /**
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
64 * Singleton access to the central XML configuration document.
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
65 * @return The central XML configuration document.
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
66 */
5
8f2de197bce2 Added config to artifact database and modelled bootstap of artifact factories on top of this.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
67 public static synchronized final Document getConfig() {
8f2de197bce2 Added config to artifact database and modelled bootstap of artifact factories on top of this.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
68 if (config == null) {
61
911c684c8a1c Removed config path of chart template which doesn't belong here from Config.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 59
diff changeset
69 config = loadConfig();
5
8f2de197bce2 Added config to artifact database and modelled bootstap of artifact factories on top of this.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
70 }
8f2de197bce2 Added config to artifact database and modelled bootstap of artifact factories on top of this.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
71 return config;
8f2de197bce2 Added config to artifact database and modelled bootstap of artifact factories on top of this.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
72 }
8f2de197bce2 Added config to artifact database and modelled bootstap of artifact factories on top of this.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
73
91
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
74 /**
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
75 * Returns the path to the configuartion directory. If a path
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
76 * was specified via the CONFIG_DIR system property this one
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
77 * is used. Else it falls back to default configuration path.
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
78 * @return The path to the configuartion directory.
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
79 */
19
1259d192e3c3 * New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 17
diff changeset
80 public static File getConfigDirectory() {
1259d192e3c3 * New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 17
diff changeset
81 String configDirString = System.getProperty(CONFIG_DIR);
1259d192e3c3 * New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 17
diff changeset
82
1259d192e3c3 * New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 17
diff changeset
83 File configDir = configDirString != null
1259d192e3c3 * New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 17
diff changeset
84 ? new File(configDirString)
1259d192e3c3 * New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 17
diff changeset
85 : CONFIG_DIR_DEFAULT;
1259d192e3c3 * New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 17
diff changeset
86
1259d192e3c3 * New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 17
diff changeset
87 if (!configDir.isDirectory()) {
1259d192e3c3 * New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 17
diff changeset
88 logger.warn("'" + configDir + "' is not a directory.");
1259d192e3c3 * New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 17
diff changeset
89 configDir = CONFIG_DIR_DEFAULT;
1259d192e3c3 * New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 17
diff changeset
90 }
1259d192e3c3 * New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 17
diff changeset
91
1259d192e3c3 * New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 17
diff changeset
92 return configDir;
1259d192e3c3 * New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 17
diff changeset
93 }
1259d192e3c3 * New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 17
diff changeset
94
91
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
95 /**
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
96 * Replaces the CONFIG_DIR_PLACEHOLDER alias with the real path
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
97 * of the configuration directory.
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
98 * @param path The path containing the CONFIG_DIR_PLACEHOLDER placeholder.
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
99 * @return The path where the CONFIG_DIR_PLACEHOLDER placeholders are
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
100 * replaced by the real path name.
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
101 */
54
c2fc85e55f9f Applied patch from slt to set the Configuration Folder into the AbsoluteFileName issue59
Tim Englich <tim.englich@intevation.de>
parents: 25
diff changeset
102 public static String replaceConfigDir(String path) {
c2fc85e55f9f Applied patch from slt to set the Configuration Folder into the AbsoluteFileName issue59
Tim Englich <tim.englich@intevation.de>
parents: 25
diff changeset
103 String configDir = getConfigDirectory().getAbsolutePath();
c2fc85e55f9f Applied patch from slt to set the Configuration Folder into the AbsoluteFileName issue59
Tim Englich <tim.englich@intevation.de>
parents: 25
diff changeset
104 return path.replace(CONFIG_DIR_PLACEHOLDER, configDir);
c2fc85e55f9f Applied patch from slt to set the Configuration Folder into the AbsoluteFileName issue59
Tim Englich <tim.englich@intevation.de>
parents: 25
diff changeset
105 }
c2fc85e55f9f Applied patch from slt to set the Configuration Folder into the AbsoluteFileName issue59
Tim Englich <tim.englich@intevation.de>
parents: 25
diff changeset
106
61
911c684c8a1c Removed config path of chart template which doesn't belong here from Config.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 59
diff changeset
107 private static Document loadConfig() {
19
1259d192e3c3 * New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 17
diff changeset
108
1259d192e3c3 * New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 17
diff changeset
109 File configDir = getConfigDirectory();
1259d192e3c3 * New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 17
diff changeset
110
61
911c684c8a1c Removed config path of chart template which doesn't belong here from Config.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 59
diff changeset
111 File file = new File(configDir, CONFIG_FILE);
5
8f2de197bce2 Added config to artifact database and modelled bootstap of artifact factories on top of this.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
112
8f2de197bce2 Added config to artifact database and modelled bootstap of artifact factories on top of this.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
113 if (!file.canRead() && !file.isFile()) {
17
5a6b6a3debc7 Integrated logging into artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 13
diff changeset
114 logger.error("Cannot read config file '"
5
8f2de197bce2 Added config to artifact database and modelled bootstap of artifact factories on top of this.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
115 + file + "'.");
8f2de197bce2 Added config to artifact database and modelled bootstap of artifact factories on top of this.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
116 return null;
8f2de197bce2 Added config to artifact database and modelled bootstap of artifact factories on top of this.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
117 }
8f2de197bce2 Added config to artifact database and modelled bootstap of artifact factories on top of this.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
118
8f2de197bce2 Added config to artifact database and modelled bootstap of artifact factories on top of this.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
119 try {
91
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
120 DocumentBuilderFactory factory =
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
121 DocumentBuilderFactory.newInstance();
5
8f2de197bce2 Added config to artifact database and modelled bootstap of artifact factories on top of this.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
122 factory.setValidating(false); // XXX: This may change in future.
8f2de197bce2 Added config to artifact database and modelled bootstap of artifact factories on top of this.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
123 return factory.newDocumentBuilder().parse(file);
8f2de197bce2 Added config to artifact database and modelled bootstap of artifact factories on top of this.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
124 }
8f2de197bce2 Added config to artifact database and modelled bootstap of artifact factories on top of this.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
125 catch (SAXException se) {
17
5a6b6a3debc7 Integrated logging into artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 13
diff changeset
126 logger.error(se.getLocalizedMessage(), se);
5
8f2de197bce2 Added config to artifact database and modelled bootstap of artifact factories on top of this.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
127 }
8f2de197bce2 Added config to artifact database and modelled bootstap of artifact factories on top of this.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
128 catch (ParserConfigurationException pce) {
17
5a6b6a3debc7 Integrated logging into artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 13
diff changeset
129 logger.error(pce.getLocalizedMessage(), pce);
5
8f2de197bce2 Added config to artifact database and modelled bootstap of artifact factories on top of this.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
130 }
8f2de197bce2 Added config to artifact database and modelled bootstap of artifact factories on top of this.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
131 catch (IOException ioe) {
17
5a6b6a3debc7 Integrated logging into artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 13
diff changeset
132 logger.error(ioe.getLocalizedMessage());
5
8f2de197bce2 Added config to artifact database and modelled bootstap of artifact factories on top of this.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
133 }
8f2de197bce2 Added config to artifact database and modelled bootstap of artifact factories on top of this.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
134
8f2de197bce2 Added config to artifact database and modelled bootstap of artifact factories on top of this.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
135 return null;
8f2de197bce2 Added config to artifact database and modelled bootstap of artifact factories on top of this.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
136 }
8f2de197bce2 Added config to artifact database and modelled bootstap of artifact factories on top of this.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
137
91
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
138 /**
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
139 * Convenience method to search within a given document tree via XPath.
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
140 * See {@link XMLUtils#xpath(Object, String, QName) } for details.
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
141 * @param root The object which is used as the root of the tree to
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
142 * be searched in.
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
143 * @param query The XPath query.
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
144 * @param returnType The type of the result.
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
145 * @return The result of type 'returnTyp' or null if something went
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
146 * wrong during XPath evaluation.
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
147 */
10
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 9
diff changeset
148 public static final Object getXPath(
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 9
diff changeset
149 Object root, String query, QName returnType
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 9
diff changeset
150 ) {
25
ccc6aae25585 Moved some XPath stuff from Config into XMLUtils.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 23
diff changeset
151 return XMLUtils.xpath(root, query, returnType);
10
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 9
diff changeset
152 }
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 9
diff changeset
153
91
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
154 /**
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
155 * Convenience method to search within the central configuration via XPath.
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
156 * See {@link XMLUtils#xpath(Object, String, QName) } for details.
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
157 * @param query The XPath query.
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
158 * @param returnType The type of the result.
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
159 * @return The result of type 'returnTyp' or null if something went
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
160 * wrong during XPath evaluation.
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
161 */
10
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 9
diff changeset
162 public static final Object getXPath(String query, QName returnType) {
25
ccc6aae25585 Moved some XPath stuff from Config into XMLUtils.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 23
diff changeset
163 return XMLUtils.xpath(getConfig(), query, returnType);
10
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 9
diff changeset
164 }
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 9
diff changeset
165
91
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
166 /**
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
167 * Convenience method to search for a node list within the central
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
168 * configuation document via XPath.
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
169 * @param query The XPath query.
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
170 * @return The queried node list or null if something went
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
171 * wrong during XPath evaluation.
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
172 */
10
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 9
diff changeset
173 public static final NodeList getNodeSetXPath(String query) {
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 9
diff changeset
174 return (NodeList)getXPath(query, XPathConstants.NODESET);
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 9
diff changeset
175 }
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 9
diff changeset
176
91
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
177 /**
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
178 * Convenience method to search for a node within the central
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
179 * configuation document via XPath.
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
180 * @param query The XPath query.
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
181 * @return The queried node or null if something went
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
182 * wrong during XPath evaluation.
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
183 */
10
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 9
diff changeset
184 public static final Node getNodeXPath(String query) {
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 9
diff changeset
185 return (Node)getXPath(query, XPathConstants.NODE);
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 9
diff changeset
186 }
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 9
diff changeset
187
91
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
188 /**
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
189 * Convenience method to search for a string within the central
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
190 * configuation document via XPath.
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
191 * @param xpath The XPath query.
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
192 * @return The queried string or null if something went
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
193 * wrong during XPath evaluation.
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
194 */
5
8f2de197bce2 Added config to artifact database and modelled bootstap of artifact factories on top of this.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
195 public static final String getStringXPath(String xpath) {
8f2de197bce2 Added config to artifact database and modelled bootstap of artifact factories on top of this.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
196 return getStringXPath(xpath, null);
8f2de197bce2 Added config to artifact database and modelled bootstap of artifact factories on top of this.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
197 }
8f2de197bce2 Added config to artifact database and modelled bootstap of artifact factories on top of this.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
198
91
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
199 /**
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
200 * Convenience method to search for a string within the central
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
201 * configuation document via XPath.
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
202 * @param query The XPath query.
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
203 * @param def The string to be returned if the search has no results.
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
204 * @return The queried string or the default value if something went
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
205 * wrong during XPath evaluation.
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
206 */
5
8f2de197bce2 Added config to artifact database and modelled bootstap of artifact factories on top of this.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
207 public static final String getStringXPath(String query, String def) {
8f2de197bce2 Added config to artifact database and modelled bootstap of artifact factories on top of this.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
208 String s = (String)getXPath(query, XPathConstants.STRING);
8f2de197bce2 Added config to artifact database and modelled bootstap of artifact factories on top of this.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
209 return s == null || s.length() == 0
8f2de197bce2 Added config to artifact database and modelled bootstap of artifact factories on top of this.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
210 ? def
8f2de197bce2 Added config to artifact database and modelled bootstap of artifact factories on top of this.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
211 : s;
8f2de197bce2 Added config to artifact database and modelled bootstap of artifact factories on top of this.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
212 }
8f2de197bce2 Added config to artifact database and modelled bootstap of artifact factories on top of this.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
213
91
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
214 /**
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
215 * Convenience method to search for a node list within a given tree
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
216 * via XPath.
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
217 * @param root The root of the tree to be searched in.
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
218 * @param query The XPath query.
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
219 * @return The queried node list or null if something went
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
220 * wrong during XPath evaluation.
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
221 */
10
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 9
diff changeset
222 public static final NodeList getNodeSetXPath(Object root, String query) {
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 9
diff changeset
223 return (NodeList)getXPath(root, query, XPathConstants.NODESET);
5
8f2de197bce2 Added config to artifact database and modelled bootstap of artifact factories on top of this.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
224 }
8f2de197bce2 Added config to artifact database and modelled bootstap of artifact factories on top of this.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
225
91
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
226 /**
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
227 * Convenience method to search for a node within a given tree
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
228 * via XPath.
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
229 * @param root The root of the tree to be searched in.
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
230 * @param query The XPath query.
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
231 * @return The queried node or null if something went
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
232 * wrong during XPath evaluation.
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
233 */
10
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 9
diff changeset
234 public static final Node getNodeXPath(Object root, String query) {
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 9
diff changeset
235 return (Node)getXPath(root, query, XPathConstants.NODE);
5
8f2de197bce2 Added config to artifact database and modelled bootstap of artifact factories on top of this.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
236 }
9
a5a279a0ee35 Laid tracks for artifacts being removed from artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 5
diff changeset
237
91
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
238 /**
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
239 * Convenience method to search for a string within a given tree
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
240 * via XPath.
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
241 * @param root The root of the tree to be searched in.
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
242 * @param xpath The XPath query.
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
243 * @return The queried string or null if something went
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
244 * wrong during XPath evaluation.
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
245 */
10
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 9
diff changeset
246 public static final String getStringXPath(Object root, String xpath) {
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 9
diff changeset
247 return getStringXPath(root, xpath, null);
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 9
diff changeset
248 }
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 9
diff changeset
249
91
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
250 /**
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
251 * Convenience method to search for a string within a given tree
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
252 * via XPath.
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
253 * @param root The root of the tree to be searched in.
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
254 * @param query xpath The XPath query.
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
255 * @param def The string to be returned if the search has no results.
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
256 * @return The queried string or the default value if something went
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
257 * wrong during XPath evaluation.
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
258 */
10
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 9
diff changeset
259 public static final String getStringXPath(
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 9
diff changeset
260 Object root, String query, String def
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 9
diff changeset
261 ) {
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 9
diff changeset
262 String s = (String)getXPath(root, query, XPathConstants.STRING);
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 9
diff changeset
263 return s == null || s.length() == 0
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 9
diff changeset
264 ? def
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 9
diff changeset
265 : s;
9
a5a279a0ee35 Laid tracks for artifacts being removed from artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 5
diff changeset
266 }
5
8f2de197bce2 Added config to artifact database and modelled bootstap of artifact factories on top of this.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
267 }
91
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 80
diff changeset
268 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org