commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Emmanuel Bourg <ebo...@apache.org>
Subject Re: [configuration] IniFile support
Date Thu, 14 Apr 2005 09:42:53 GMT
Oliver Siegmar wrote:

> Many application ini files have some kind of default-section. Consider the 
> following ini-file:
> 
> --------------------------------
> [default]
> foo = 30
> val = 50
> 
> [section1]
> foo = 10
> --------------------------------

Ok I see your point. There was a support for default values in 
PropertiesConfiguration some time ago but we removed it in favor of 
CompositeConfiguration. For consistency I think we will apply the same 
reasoning for INIConfiguration, that means you can emulate a similar 
behaviour with:

Configuration iniconf = new INIConfiguration("config.ini");
CompositeConfiguration conf = new CompositeConfiguration();
conf.addConfiguration(iniconf.subset("section1"));
conf.addConfiguration(iniconf.subset("default"));

conf.getString("val") -> returns 50


To make it easier I could add a method in INIConfiguration that build 
this CompositeConfiguration automatically. Something like:

Configuration conf = iniconf.getSection("section1", "default");
conf.getString("val");

Emmanuel Bourg

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message