commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oliver Heger <oliver.he...@oliver-heger.de>
Subject Re: [configuration] How to read an INI Configuration with brackets as list separator
Date Wed, 26 Aug 2015 19:32:57 GMT


Am 25.08.2015 um 17:33 schrieb Thomas Vandahl:
> On 25.08.15 07:55, Patrick Brunmayr wrote:
>> Hello
>>
>> How can i read a configuration like that ?
>>
>> [RESPONSE]
>> code = 200
>> description = Command completed successfully
>> queuetime = 0
>> runtime = 0.006
>> property[count][0] = 164
>> property[domain][0] = xxx
>> property[domain][1] = xxx
>> property[domain][2] = xxx
>>
> 
> Hi Patrick,
> 
> list separators are for values, not keys. See the JavaDoc for
> HierarchicalINIConfiguration for a way to handle files like this. You
> may want to check out the section
> http://commons.apache.org/proper/commons-configuration/userguide_v1.10/howto_xml.html#Accessing_structured_properties
> of the users guide for possibilities to access your data. Using the
> XPathExpressionEngine might cover your case but that's just a wild guess.
> 
> HTH
> Bye, Thomas.

As Thomas said, there is no mechanism to group keys following a specific
pattern to lists or something like that.

As long as the keys do not contain the configurable separator character,
they are processed in the usual way and can be queried verbatim. If you
want to fetch for instance all values assigned to a property like
'property[domain]', you have to construct the keys yourself and do the
necessary looping. Maybe you can use the getKeys() method which expects
a prefix to select a specific subset of keys.

Oliver

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

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


Mime
View raw message