Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2019
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. import java.util.*;
  2.  
  3. public class Configuration {
  4. public int interval;
  5.  
  6. public int duration;
  7.  
  8. public int departure;
  9.  
  10. public void load(Properties props) throws ConfigurationException {
  11. String valueString;
  12. int value;
  13.  
  14. valueString = props.getProperty("interval");
  15. if (valueString == null) {
  16. throw new ConfigurationException("monitor interval");
  17. }
  18. value = Integer.parseInt(valueString);
  19. if (value <= 0) {
  20. throw new ConfigurationException("monitor interval > 0");
  21. }
  22. interval = value;
  23.  
  24. valueString = props.getProperty("duration");
  25. if (valueString == null) {
  26. throw new ConfigurationException("duration");
  27. }
  28. value = Integer.parseInt(valueString);
  29. if (value <= 0) {
  30. throw new ConfigurationException("duration > 0");
  31. }
  32. if ((value % interval) != 0) {
  33. throw new ConfigurationException("duration % interval");
  34. }
  35. duration = value;
  36.  
  37. valueString = props.getProperty("departure");
  38. if (valueString == null) {
  39. throw new ConfigurationException("departure offset");
  40. }
  41. value = Integer.parseInt(valueString);
  42. if (value <= 0) {
  43. throw new ConfigurationException("departure > 0");
  44. }
  45. if ((value % interval) != 0) {
  46. throw new ConfigurationException("departure % interval");
  47. }
  48. departure = value;
  49. }
  50. }
  51.  
  52. //duzo sie powtaza
  53. //co jesci trzeba wczytac cos nowego
  54. //pojedyncze wywolanie jesli chcey kolejne prpoerty
  55. // podzielic na metody
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement