01: /*
02: * Copyright 2007 Roy van der Kuil (roy@vanderkuil.nl)
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package nl.improved.sqlclient;
17:
18: import java.util.Map;
19: import java.util.Properties;
20:
21: public class SQLProperties {
22:
23: public static enum PropertyName {
24: VERSION
25: };
26:
27: private static SQLProperties instance;
28:
29: private Properties props;
30:
31: private SQLProperties() {
32: props = new Properties();
33: try {
34: props
35: .load(getClass()
36: .getResourceAsStream(
37: "/META-INF/maven/nl.improved/sqlshell/pom.properties"));
38: props.put(PropertyName.VERSION, props.get("version"));
39: } catch (Exception e) {
40: //System.err.println("Failed to load pom.properties");
41: }
42: }
43:
44: private static SQLProperties getInstance() {
45: if (instance == null) {
46: instance = new SQLProperties();
47: }
48: return instance;
49: }
50:
51: public static String getProperty(PropertyName property) {
52: return (String) getInstance().props.get(property);
53: }
54:
55: public static String getProperty(PropertyName property,
56: String defaultValue) {
57: String prop = getProperty(property);
58: if (prop == null) {
59: return defaultValue;
60: }
61: return prop;
62: }
63: }
|