You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Patrick Brunmayr <p....@linzag.at> on 2015/08/25 16:55:05 UTC

[configuration] How to read an INI Configuration with brackets as list separator

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

Thx




LINZ AG für Energie, Telekommunikation, Verkehr und Kommunale Dienste
A-4021 Linz, Wiener Straße 151, Postfach 1300, Tel. +43/732/3400-0, E-Mail: info@linzag.at



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


Re: [configuration] How to read an INI Configuration with brackets as list separator

Posted by Oliver Heger <ol...@oliver-heger.de>.

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


Re: [configuration] How to read an INI Configuration with brackets as list separator

Posted by Thomas Vandahl <tv...@apache.org>.
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.


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