Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class Configuration {
- public int interval;
- public int duration;
- public int departure;
- public void load(Properties props) throws ConfigurationException {
- String valueString;
- int value;
- valueString = props.getProperty("interval");
- if (valueString == null) {
- throw new ConfigurationException("monitor interval");
- }
- value = Integer.parseInt(valueString);
- if (value <= 0) {
- throw new ConfigurationException("monitor interval > 0");
- }
- interval = value;
- valueString = props.getProperty("duration");
- if (valueString == null) {
- throw new ConfigurationException("duration");
- }
- value = Integer.parseInt(valueString);
- if (value <= 0) {
- throw new ConfigurationException("duration > 0");
- }
- if ((value % interval) != 0) {
- throw new ConfigurationException("duration % interval");
- }
- duration = value;
- valueString = props.getProperty("departure");
- if (valueString == null) {
- throw new ConfigurationException("departure offset");
- }
- value = Integer.parseInt(valueString);
- if (value <= 0) {
- throw new ConfigurationException("departure > 0");
- }
- if ((value % interval) != 0) {
- throw new ConfigurationException("departure % interval");
- }
- departure = value;
- }
- }
- //duzo sie powtaza
- //co jesci trzeba wczytac cos nowego
- //pojedyncze wywolanie jesli chcey kolejne prpoerty
- // podzielic na metody
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement