Settings.java 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. // Settings
  2. //
  3. // Douglas Thrift
  4. //
  5. // Settings.java
  6. /* Copyright 2011 Douglas Thrift
  7. *
  8. * This file is part of Big Screen Bot.
  9. *
  10. * Big Screen Bot is free software: you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation, either version 3 of the License, or
  13. * (at your option) any later version.
  14. *
  15. * Big Screen Bot is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with Big Screen Bot. If not, see <http://www.gnu.org/licenses/>.
  22. */
  23. package net.douglasthrift.bigscreenbot;
  24. import java.util.Arrays;
  25. import java.util.List;
  26. import java.util.Properties;
  27. public class Settings extends Properties
  28. {
  29. public boolean getBooleanProperty(String key, boolean defaultValue)
  30. {
  31. String value = getProperty(key);
  32. if (value != null)
  33. return Boolean.parseBoolean(value);
  34. else
  35. return defaultValue;
  36. }
  37. public int getIntegerProperty(String key, int defaultValue)
  38. {
  39. String value = getProperty(key);
  40. if (value != null)
  41. return Integer.parseInt(value);
  42. else
  43. return defaultValue;
  44. }
  45. public List<String> getListProperty(String key)
  46. {
  47. String value = getProperty(key);
  48. if (value != null)
  49. return Arrays.asList(value.split("\\s"));
  50. else
  51. return null;
  52. }
  53. }
  54. // vim: expandtab