completed setup for installation, fixed robustness problem.
[upnpmonitor] / monitor / src / main / java / org / wamblee / upnpmonitor / Config.java
1 package org.wamblee.upnpmonitor;
2
3 import java.util.Properties;
4
5 public class Config {
6
7     public static final String INTERVAL_SECONDS = "org.wamblee.upnpmonitor.intervalSeconds";
8     public static final String STARTUP_COMMAND = "org.wamblee.upnpmonitor.startupCommand";
9     public static final String SHUTDOWN_COMMAND = "org.wamblee.upnpmonitor.shutdownCommand";
10     public static final String PATTERN = "org.wamblee.upnpmonitor.pattern";
11
12     private int intervalSeconds;
13     private String startupCommand;
14     private String shutdownCommand;
15     private String pattern;
16
17     public static Config parse(Properties aProperties) {
18         return new Config(Integer.parseInt(aProperties.getProperty(
19             INTERVAL_SECONDS, "30")), aProperties.getProperty(STARTUP_COMMAND),
20             aProperties.getProperty(SHUTDOWN_COMMAND),
21             aProperties.getProperty(PATTERN));
22     }
23
24     public Config(int aIntervalSeconds, String aStartupCommand,
25         String aShutdownCommand, String aPattern) {
26         intervalSeconds = aIntervalSeconds;
27         startupCommand = aStartupCommand;
28         shutdownCommand = aShutdownCommand;
29         pattern = aPattern;
30     }
31
32     public int getIntervalSeconds() {
33         return intervalSeconds;
34     }
35
36     public String getStartupCommand() {
37         return startupCommand;
38     }
39
40     public String getShutdownCommand() {
41         return shutdownCommand;
42     }
43
44     public String getPattern() {
45         return pattern;
46     }
47
48     @Override
49     public String toString() {
50         return "Config [intervalSeconds=" + intervalSeconds +
51             ", startupCommand=" + startupCommand + ", shutdownCommand=" +
52             shutdownCommand + ", pattern=" + pattern + "]";
53     }
54
55 }