Corrected a few bugs in Settings.

This commit is contained in:
Anthony Whitford
2015-10-08 00:39:57 -07:00
parent 832d54300a
commit 274ac339ad

View File

@@ -460,12 +460,7 @@ public final class Settings {
* @param value the value for the property * @param value the value for the property
*/ */
public static void setBoolean(String key, boolean value) { public static void setBoolean(String key, boolean value) {
if (value) { setString(key, Boolean.toString(value));
localSettings.get().props.setProperty(key, Boolean.TRUE.toString());
} else {
localSettings.get().props.setProperty(key, Boolean.FALSE.toString());
}
LOGGER.debug("Setting: {}='{}'", key, value);
} }
/** /**
@@ -708,7 +703,7 @@ public final class Settings {
try { try {
value = Long.parseLong(Settings.getString(key)); value = Long.parseLong(Settings.getString(key));
} catch (NumberFormatException ex) { } catch (NumberFormatException ex) {
throw new InvalidSettingException("Could not convert property '" + key + "' to an int.", ex); throw new InvalidSettingException("Could not convert property '" + key + "' to a long.", ex);
} }
return value; return value;
} }
@@ -723,13 +718,7 @@ public final class Settings {
* @throws InvalidSettingException is thrown if there is an error retrieving the setting * @throws InvalidSettingException is thrown if there is an error retrieving the setting
*/ */
public static boolean getBoolean(String key) throws InvalidSettingException { public static boolean getBoolean(String key) throws InvalidSettingException {
boolean value; return Boolean.parseBoolean(Settings.getString(key));
try {
value = Boolean.parseBoolean(Settings.getString(key));
} catch (NumberFormatException ex) {
throw new InvalidSettingException("Could not convert property '" + key + "' to an int.", ex);
}
return value;
} }
/** /**
@@ -743,17 +732,7 @@ public final class Settings {
* @throws InvalidSettingException is thrown if there is an error retrieving the setting * @throws InvalidSettingException is thrown if there is an error retrieving the setting
*/ */
public static boolean getBoolean(String key, boolean defaultValue) throws InvalidSettingException { public static boolean getBoolean(String key, boolean defaultValue) throws InvalidSettingException {
boolean value; return Boolean.parseBoolean(Settings.getString(key, Boolean.toString(defaultValue)));
try {
final String strValue = Settings.getString(key);
if (strValue == null) {
return defaultValue;
}
value = Boolean.parseBoolean(strValue);
} catch (NumberFormatException ex) {
throw new InvalidSettingException("Could not convert property '" + key + "' to an int.", ex);
}
return value;
} }
/** /**