123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- // Settings
- //
- // Douglas Thrift
- //
- // Settings.java
- /* Copyright 2011 Douglas Thrift
- *
- * This file is part of Big Screen Bot.
- *
- * Big Screen Bot is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Big Screen Bot is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Big Screen Bot. If not, see <http://www.gnu.org/licenses/>.
- */
- package net.douglasthrift.bigscreenbot;
- import java.io.FileNotFoundException;
- import java.io.FileReader;
- import java.io.IOException;
- import java.util.Arrays;
- import java.util.List;
- import java.util.Properties;
- public class Settings extends Properties
- {
- private static final String SETTINGS = "bigscreenbot.properties";
- public boolean getBooleanProperty(String key, boolean defaultValue)
- {
- String value = getProperty(key);
- if (value != null)
- return Boolean.parseBoolean(value);
- else
- return defaultValue;
- }
- public int getIntegerProperty(String key, int defaultValue)
- {
- String value = getProperty(key);
- if (value != null)
- return Integer.parseInt(value);
- else
- return defaultValue;
- }
- public List<String> getListProperty(String key)
- {
- String value = getProperty(key);
- if (value != null)
- return Arrays.asList(value.split("\\s"));
- else
- return null;
- }
- public void load() throws FileNotFoundException, IOException
- {
- FileReader reader = null;
- try
- {
- reader = new FileReader(SETTINGS);
- load(reader);
- }
- finally
- {
- if (reader != null)
- reader.close();
- }
- }
- }
- // vim: expandtab
|