-
Notifications
You must be signed in to change notification settings - Fork 0
/
SimpleConfig.java
71 lines (56 loc) · 1.59 KB
/
SimpleConfig.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/**
*
*/
package com.gootrip.util;
import java.net.URL;
import java.util.Iterator;
import nl.chess.it.util.config.Config;
import nl.chess.it.util.config.ConfigValidationResult;
/**
* @author advance
*
*/
public class SimpleConfig extends Config {
/**
* Name of the file we are looking for to read the configuration.
*/
public static final String RESOURCE_NAME = "simpleconfig.properties";
/**
* Creates a new SimpleConfig object.
*/
public SimpleConfig(String resourceName) {
super(resourceName);
}
public boolean isThisANiceClass() {
return getBoolean("doIlikeThisClass");
}
public String getWelcomeText() {
return getString("property.welcome");
}
public URL getNiceWebsite() {
return getURL("property.nicewebsite");
}
public int getNumberOfDays() {
return getInt("property.numberofdays");
}
/**
* @param args
*/
public static void main(String[] args) {
Config config = new SimpleConfig(SimpleConfig.RESOURCE_NAME);
ConfigValidationResult configResult = config.validateConfiguration();
if (configResult.thereAreErrors()) {
System.out.println("Errors in configuration");
for (Iterator iter = configResult.getErrors().iterator(); iter.hasNext();) {
System.out.println(" > " + iter.next());
}
System.exit(1);
}
if (configResult.thereAreUnusedProperties()) {
System.out.println("Unused properties");
for (Iterator iter = configResult.getUnusedProperties().iterator(); iter.hasNext();) {
System.out.println(" > " + iter.next());
}
}
}
}