Mercurial > dive4elements > framework
comparison artifact-database/src/main/java/de/intevation/artifactdatabase/SQL.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 | 8447467cef86 |
children | e27cf9c84eb8 |
comparison
equal
deleted
inserted
replaced
86:b2e0cb83631c | 87:0f48188a6e02 |
---|---|
6 import java.io.InputStream; | 6 import java.io.InputStream; |
7 | 7 |
8 import org.apache.log4j.Logger; | 8 import org.apache.log4j.Logger; |
9 | 9 |
10 /** | 10 /** |
11 * Singleton to provide SQL statement strings as key/value pairs. | |
12 * This mechanism is used to encapsulate database specific SQL | |
13 * dialects. | |
14 * | |
11 * @author <a href="mailto:sascha.teichmann@intevation.de">Sascha L. Teichmann</a> | 15 * @author <a href="mailto:sascha.teichmann@intevation.de">Sascha L. Teichmann</a> |
12 */ | 16 */ |
13 public final class SQL | 17 public final class SQL |
14 { | 18 { |
15 private static Logger logger = Logger.getLogger(SQL.class); | 19 private static Logger logger = Logger.getLogger(SQL.class); |
17 private SQL() { | 21 private SQL() { |
18 } | 22 } |
19 | 23 |
20 private static Properties statements; | 24 private static Properties statements; |
21 | 25 |
26 /** | |
27 * Returns key/value pairs of SQL statements for the used database | |
28 * backend. | |
29 * The concrete set of SQL statements is determined by the | |
30 * used JDBC database driver which is configured in conf.xml. | |
31 * The class name of the driver is transformed by replacing | |
32 * all '.' with '_' and lower case the resulting string. | |
33 * The transformed string is used to load a properties file | |
34 * in '/sql/' which should contain the statements. | |
35 * Example:<br> | |
36 * <code>org.postgresql.Driver</code> results in loading of | |
37 * <code>/sql/org-postgresql-driver.properties</code>. | |
38 * @return The key/value pairs of SQL statements. | |
39 */ | |
22 public static final synchronized Properties getStatements() { | 40 public static final synchronized Properties getStatements() { |
23 if (statements == null) { | 41 if (statements == null) { |
24 statements = loadStatements(); | 42 statements = loadStatements(); |
25 } | 43 } |
26 return statements; | 44 return statements; |
59 } | 77 } |
60 | 78 |
61 return properties; | 79 return properties; |
62 } | 80 } |
63 | 81 |
82 /** | |
83 * Returns a particular SQL statement for a given key. | |
84 * @param key The key of the statement. | |
85 * @return The corresponing SQL statement or null if none | |
86 * is found. | |
87 */ | |
64 public static final String get(String key) { | 88 public static final String get(String key) { |
65 return getStatements().getProperty(key); | 89 return getStatements().getProperty(key); |
66 } | 90 } |
67 } | 91 } |
68 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8: | 92 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |