commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oliver Heger <heg...@med.uni-marburg.de>
Subject Re: [configuration] getProperties not working as I expect...
Date Tue, 14 Jun 2005 06:21:57 GMT
Poppe, Troy wrote:
> Assuming that I use the example XML document on the "XMLConfiguration HOWTO" page
> (see below), I have a question regarding the use of
> Configuration.getProperties().
> 
> I'd like to get a List of Properties objects that represent the field nodes for a
> given table.
> 
> I started by trying to get a Properties object for one of the field nodes, but
> was unable to.
> 
> Any examples for the use of getProperties or getList that might help me out here?
> 
> Thanks.
> 
> Troy Poppe
> 
> 
> 
> 
> The Example XML file:
> 
> <?xml version="1.0" encoding="ISO-8859-1" ?>
> 
> <database>
>   <tables>
>     <table tableType="system">
>       <name>users</name>
>       <fields>
>         <field>
>           <name>uid</name>
>           <type>long</type>
>         </field>
>         <field>
>           <name>uname</name>
>           <type>java.lang.String</type>
>         </field>
>         <field>
>           <name>firstName</name>
>           <type>java.lang.String</type>
>         </field>
>         <field>
>           <name>lastName</name>
>           <type>java.lang.String</type>
>         </field>
>         <field>
>           <name>email</name>
>           <type>java.lang.String</type>
>         </field>
>       </fields>
>     </table>
>     <table tableType="application">
>       <name>documents</name>
>       <fields>
>         <field>
>           <name>docid</name>
>           <type>long</type>
>         </field>
>         <field>
>           <name>name</name>
>           <type>java.lang.String</type>
>         </field>
>         <field>
>           <name>creationDate</name>
>           <type>java.util.Date</type>
>         </field>
>         <field>
>           <name>authorID</name>
>           <type>long</type>
>         </field>
>         <field>
>           <name>version</name>
>           <type>int</type>
>         </field>
>       </fields>
>     </table>
>   </tables>
> </database>
> 

I had a look at the getProperties() implementation (in 
AbstractConfiguration), but it does not seem to be suitable for your 
needs. AFICT it requires the property values to be queried in a form 
like "key = value", so a supported XML would have to look something like

...
<fields>
   <field>
     <fielddata>name=uid</fielddata>
     <fielddata>type=long</fielddata>
   </field>
   ...
</fields>
...

Then it should be possible to do something like

Properties props = 
config.getProperties("tables.table(0).fields.field(0).fielddata");

for obtaining a properties object with information about the first field 
of the first table (however I didn't test this).

Using getList() allows you to query a single property value at a time 
only. So you can fetch the names of all fields in a table (as shown in 
the howtos), but you cannot retrieve a combination of the fields' names 
and types (or further properties).

IIUYC you would like to do something like

Properties props = config.getProperties("tables.table.fields.field(0)");

and would obtain a Properties object with the keys "name" and "type" and 
the values describing the first field, right? I am sorry, but this is 
not supported ATM. And I am not sure whether it would be possible to 
implement such a feature in a general and intuitive way: this would 
require to parse a property's sub properties and somehow combine them?

Oliver


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