1 package de.fhdw.wtf.persistence.utils;
2
3 import java.util.Enumeration;
4 import java.util.HashMap;
5 import java.util.MissingResourceException;
6 import java.util.ResourceBundle;
7
8
9
10
11
12
13
14
15 public class PropertiesReaderRessource implements PropertiesReader {
16
17
18
19
20 private final HashMap<String, String> propValues = new HashMap<>();
21
22
23
24
25 public void reset() {
26 this.propValues.clear();
27 }
28
29 @Override
30 public void initialize(final String propFile) throws MissingResourceException {
31 this.reset();
32 final ResourceBundle rb = ResourceBundle.getBundle(propFile);
33 final Enumeration<String> keys = rb.getKeys();
34 while (keys.hasMoreElements()) {
35 final String key = keys.nextElement();
36 final String value = rb.getString(key);
37 this.propValues.put(key, value);
38 }
39 }
40
41 @Override
42 public String getProperty(final String key) {
43 if (!this.propValues.containsKey(key)) {
44 return "";
45 }
46 return this.propValues.get(key);
47 }
48 }