commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rishikesh.Mall...@atradius.com
Subject RE: XMLConfiguration: Keyname list
Date Tue, 28 Mar 2006 09:50:03 GMT
Thanks Oliver.

> For which purpose do you need these keys?

I need a functionality to convert an "XMLConfiguration" object to a
"Properties" object.

Given that there is no direct support (including
ConfigurationConverter.getProperties(..)) I decided to build the Properties 
and hence required the list of keys.

I was thinking of going down the route of HierarchicalConfiguration.Node,
but seems a bit too much work to perform the task, given that we can access
individual keys using indices. Do you know the thinking behind this
approach?

Any other ideas? 

Another thing I wanted to add to my wish list for commons config is to have
the concept of using a file name as a namespace.

So if I were to use ConfigurationFactory and I wanted to retrieve all the
configuration information in a particular file (.xml, .properties etc),
there is nothing directly supported (pls correct me if I am wrong). DO you
have any ideas on this? I am currently loading individual files to get
information from a specific file.

Any ideas?




-----Original Message-----
From: Oliver Heger [mailto:oliver.heger@t-online.de] 
Sent: 27 March 2006 20:15
To: Jakarta Commons Users List
Subject: Re: XMLConfiguration: Keyname list

Rishikesh.Mallesh@atradius.com wrote:

>Hi 
>
> 
>
>Question regarding XMLConfiguration. How could I get the list of keynames
>stored in an XMLConfiguration object?
>
> 
>
>Say for instance my XML file looks like - 
>
><database>
>  <tables>
>    <table tableType="system">
>      <name>users</name>
>      <fields>
>        <field>
>          <name>uid</name>
>          <type>long</type>
>        </field>
>        <field>
>          <name>uid</name>
>          <type>long</type>
>        </field>
> 
>.
>.
>.
>.
></database>
>
> 
>
>Is there an  API which would return a Collection of containing the
following
>keynames?
>
> 
>
>tables.table(0).fields(0).field.name
>
>tables.table(0).fields(1).field.name
>
> 
>
> 
>
>If not an API is there a standard way of doing this.
>
> 
>
This is not directly supported. The getKeys() method defined in the
Configuration interface only returns the defined keys without indices.

For which purpose do you need these keys? If it is only for a convenient
way of iterating over a hierarchical configuration, the latest code in
SVN contains the method
HierarchicalConfiguration.configurationsAt(String key), which gives you
access to sub structures of the configuration.

If you really need keys with indices, I fear you will have to traverse
the HierarchicalConfiguration.Node objects by yourself and construct the
keys.

HTH
Oliver

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


------------------------------------------------------------------------------------------------------------
This message is intended for the addressee or its representative only. 
Any form of unauthorized use, publication, reproduction, copying or 
disclosure of the content of this e-mail is not permitted. If you are 
not the intended recipient of this e-mail message and its contents, 
please notify the sender immediately and delete this message and 
all its attachments subsequently.


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


Mime
View raw message