1 |
alfonx |
802 |
package skrueger.lang; |
2 |
|
|
|
3 |
|
|
import java.io.InputStream; |
4 |
|
|
import java.net.URL; |
5 |
|
|
import java.util.Properties; |
6 |
|
|
|
7 |
|
|
import org.apache.log4j.Logger; |
8 |
|
|
|
9 |
|
|
/** |
10 |
|
|
* Erlaubt es eine {@link Properties} Instanz mit einer Zeile zu initialisieren |
11 |
|
|
* und mit den Werten einer Datei zu befüllen. ALle Exceptions werden zu |
12 |
|
|
* {@link RuntimeException}s. |
13 |
|
|
* |
14 |
|
|
* @author Stefan A. Tzeggai |
15 |
|
|
* |
16 |
|
|
*/ |
17 |
|
|
public class PropertiesLoaded extends Properties { |
18 |
|
|
private static Logger log = Logger.getLogger(PropertiesLoaded.class); |
19 |
|
|
|
20 |
|
|
/** |
21 |
|
|
* Erlaubt es eine {@link Properties} Instanz mit einer Zeile zu |
22 |
|
|
* initialisieren und mit den Werten einer Datei zu befüllen. ALle |
23 |
|
|
* Exceptions werden zu {@link RuntimeException}s. |
24 |
|
|
* |
25 |
|
|
* @author Stefan A. Tzeggai |
26 |
|
|
* |
27 |
|
|
*/ |
28 |
|
|
public PropertiesLoaded(URL loadFrom) { |
29 |
|
|
super(); |
30 |
|
|
|
31 |
|
|
load(loadFrom); |
32 |
|
|
} |
33 |
|
|
|
34 |
|
|
/** |
35 |
|
|
* Erlaubt es eine {@link Properties} Instanz mit einer Zeile zu |
36 |
|
|
* initialisieren und mit den Werten einer Datei zu befüllen. ALle |
37 |
|
|
* Exceptions werden zu {@link RuntimeException}s. |
38 |
|
|
* |
39 |
|
|
* @author Stefan A. Tzeggai |
40 |
|
|
* |
41 |
|
|
*/ |
42 |
|
|
public PropertiesLoaded(URL loadFrom, Properties defaults) { |
43 |
|
|
super(defaults); |
44 |
|
|
load(loadFrom); |
45 |
|
|
} |
46 |
|
|
|
47 |
|
|
/** |
48 |
|
|
* Erlaubt es eine {@link Properties} Instanz mit einer Zeile zu |
49 |
|
|
* initialisieren und mit den Werten einer Datei zu befüllen. ALle |
50 |
|
|
* Exceptions werden zu {@link RuntimeException}s. |
51 |
|
|
* |
52 |
|
|
* @author Stefan A. Tzeggai |
53 |
|
|
* |
54 |
|
|
*/ |
55 |
|
|
public PropertiesLoaded() { |
56 |
|
|
super(); |
57 |
|
|
} |
58 |
|
|
|
59 |
|
|
/** |
60 |
|
|
* Erlaubt es eine {@link Properties} Instanz mit einer Zeile zu |
61 |
|
|
* initialisieren und mit den Werten einer Datei zu befüllen. ALle |
62 |
|
|
* Exceptions werden zu {@link RuntimeException}s. |
63 |
|
|
* |
64 |
|
|
* @author Stefan A. Tzeggai |
65 |
|
|
* |
66 |
|
|
*/ |
67 |
|
|
public PropertiesLoaded(Properties defaults) { |
68 |
|
|
super(defaults); |
69 |
|
|
} |
70 |
|
|
|
71 |
|
|
/** |
72 |
|
|
* Erlaubt es eine {@link Properties} Instanz mit einer Zeile zu |
73 |
|
|
* initialisieren und mit den Werten einer Datei zu befüllen. ALle |
74 |
|
|
* Exceptions werden zu {@link RuntimeException}s. |
75 |
|
|
* |
76 |
|
|
* @author Stefan A. Tzeggai |
77 |
|
|
* |
78 |
|
|
*/ |
79 |
|
|
public void load(URL loadFrom) { |
80 |
|
|
try { |
81 |
|
|
|
82 |
|
|
InputStream openStream = null; |
83 |
|
|
try { |
84 |
|
|
openStream = loadFrom.openStream(); |
85 |
|
|
load(openStream); |
86 |
|
|
} finally { |
87 |
|
|
if (openStream != null) |
88 |
|
|
openStream.close(); |
89 |
|
|
} |
90 |
|
|
|
91 |
|
|
} catch (Exception e) { |
92 |
|
|
throw new RuntimeException(e); |
93 |
|
|
} |
94 |
|
|
} |
95 |
|
|
|
96 |
|
|
} |