commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oliver Siegmar <oli...@siegmar.net>
Subject Re: [configuration] IniFile support
Date Thu, 14 Apr 2005 09:52:09 GMT
On Thursday 14 April 2005 11:32, Jörg Schaible wrote:
> > Many application ini files have some kind of default-section.
> > Consider the following ini-file:
>
> [snip]
>
> well, such a behaviour would be different from all other configuration
> implemnetations and I don't think it is worth the hassle. You can have the
> same functionality with CompositeConfiguration either by using two files or
> two subsections:

You're right when it comes to new configuration files / new applications. But 
then, I wouldn't use ini-files. I think of existing applications and existing 
ini-files with this schema.

Another approach could be to write a facade for this - something like:

public Object getProperty(String key)
{
    Object o = super.getProperty(key);
    if (o == null)
    {
        int pos = key.indexOf(".");
        if (pos == -1)
        {
            key = this.defaultSection + "." + key;
        }
        else
        {
            key = this.defaultSection + key.substring(0, pos);
        }
        o = super.getProperty(key);
    }

    return o;
}


...just an idea...


Best,
Oliver

---------------------------------------------------------------------
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