Added support for float values.

git-svn-id: https://samskivert.googlecode.com/svn/trunk@934 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
ray
2002-11-13 07:12:31 +00:00
parent 2a35b7cd2a
commit 19bc14ce45
@@ -1,5 +1,5 @@
//
// $Id: Config.java,v 1.15 2002/10/14 00:23:09 mdb Exp $
// $Id: Config.java,v 1.16 2002/11/13 07:12:31 ray Exp $
//
// samskivert library - useful routines for java programs
// Copyright (C) 2001 Michael Bayne
@@ -175,6 +175,46 @@ public class Config
_prefs.putLong(name, 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 name of the property.
* @param defval the value to return if the property is not specified
* in the config file.
*
* @return the value of the requested property.
*/
public float getValue (String name, float defval)
{
// if there is a value, parse it into an integer
String val = _props.getProperty(name);
if (val != null) {
try {
defval = Float.parseFloat(val);
} catch (NumberFormatException nfe) {
Log.warning("Malformed float property [name=" + name +
", value=" + val + "].");
}
}
// finally look for an overridden value
return _prefs.getFloat(name, defval);
}
/**
* Sets the value of the specified preference, overriding the value
* defined in the configuration files shipped with the application.
*/
public void setValue (String name, float value)
{
_prefs.putFloat(name, value);
}
/**
* Fetches and returns the value for the specified configuration
* property. If the value is not specified in the associated