Support long[] values.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@1541 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
@@ -436,6 +436,51 @@ public class Config
|
|||||||
_propsup.firePropertyChange(name, oldValue, value);
|
_propsup.firePropertyChange(name, oldValue, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetches and returns the value for the specified configuration
|
||||||
|
* property. If the value is not specified in the associated
|
||||||
|
* properties file, the supplied default value is returned instead. If
|
||||||
|
* the property specified in the file is poorly formatted (not and
|
||||||
|
* integer, not in proper array specification), a warning message will
|
||||||
|
* be logged and the default value will be returned.
|
||||||
|
*
|
||||||
|
* @param name the name of the property to be fetched.
|
||||||
|
* @param defval the value to return if the property is not specified
|
||||||
|
* in the config file.
|
||||||
|
*
|
||||||
|
* @return the value of the requested property.
|
||||||
|
*/
|
||||||
|
public long[] getValue (String name, long[] defval)
|
||||||
|
{
|
||||||
|
// look up the value in the configuration file and use that to
|
||||||
|
// look up any overridden value
|
||||||
|
String val = _prefs.get(name, _props.getProperty(name));
|
||||||
|
long[] result = defval;
|
||||||
|
|
||||||
|
// parse it into an array of longs
|
||||||
|
if (val != null) {
|
||||||
|
result = StringUtil.parseLongArray(val);
|
||||||
|
if (result == null) {
|
||||||
|
Log.warning("Malformed int array property [name=" + name +
|
||||||
|
", value=" + val + "].");
|
||||||
|
return defval;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the value of the specified preference, overriding the value
|
||||||
|
* defined in the configuration files shipped with the application.
|
||||||
|
*/
|
||||||
|
public void setValue (String name, long[] value)
|
||||||
|
{
|
||||||
|
long[] oldValue = getValue(name, (long[])null);
|
||||||
|
_prefs.put(name, StringUtil.toString(value, "", ""));
|
||||||
|
_propsup.firePropertyChange(name, oldValue, value);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetches and returns the value for the specified configuration
|
* Fetches and returns the value for the specified configuration
|
||||||
* property. If the value is not specified in the associated
|
* property. If the value is not specified in the associated
|
||||||
|
|||||||
Reference in New Issue
Block a user