BaseConfiguration, rev 1.3 in the sandbox: http://cvs.apache.org/viewcvs.cgi/jakarta-commons-sandbox/configuration/src/java/org/apache/commons/configuration/Attic/BaseConfiguration.java?rev=1.13&view=markup
public String getString(String key)
{
return getString(key, null);
}AsbtractConfiguration, rev 1.1 in the sandbox: http://cvs.apache.org/viewcvs.cgi/jakarta-commons-sandbox/configuration/src/java/org/apache/commons/configuration/Attic/AbstractConfiguration.java?rev=1.1&view=markup
public String getString(String key)
{
String s = getString(key, null);
if (s != null)
{
return s;
}
else
{
throw new NoSuchElementException(
'\'' + key + "' doesn't map to an existing object");
}
}I'm all for changing this feature for non primitive types, that would be consistent with the behavior of ExtendedProperties in [collections]. However I wouldn't drop it completely, it's still useful in somes cases.
I suggest adding an optional flag to let the users choose between a default value (null or empty values for lists and arrays) and a NoSuchElementException. The default behavior would be to return a default value.
Emmanuel Bourg
Henning P. Schmiedehausen wrote:
Hi,
for a long time, doing this:
--- cut --- import org.apache.commons.configuration.Configuration;
Configuration conf = Turbine.getConfiguration(); String foo = conf.getString("does.not.exist"); --- cut ---
resulted in foo containing null. Somewhere between a random snapshot and the 1.0-rc release, this changed. Now I get
java.util.NoSuchElementException: 'does.not.exist' doesn't map to an existing object at ...
which is bad and upsets a lot of software that uses get<XXX>("property") as a short-cut for get<XXX>("property", null).
I am all for restoring the original behaviour; i.e. returning null instead of throwing an exception.
Regards Henning
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
