commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Vanaja Ravi (vanaja)" <van...@cisco.com>
Subject RE: [Commons Configuration]Clearing a specific node in XMLConfiguration
Date Tue, 08 Jul 2008 20:43:06 GMT
I will take a look at the XPathExpressionEngine. Thank you for the
suggestion and heads up on anticipated changes.

thanks,
vanaja 

ps: Since you get a delivery failure when posting, let me see if I have
any success archiving this.

-----Original Message-----
From: Oliver Heger [mailto:oliver.heger@oliver-heger.de] 
Sent: Tuesday, July 08, 2008 1:36 PM
To: Vanaja Ravi (vanaja)
Cc: Jakarta Commons Users List
Subject: Re: [Commons Configuration]Clearing a specific node in
XMLConfiguration

Vanaja Ravi (vanaja) schrieb:
> Thank you Oliver!
> 
> I did consider using indices but here is the issue - I do not know 
> upfront the index that I want to delete. I have to now query for all 
> values of the key and loop through the result to locate the index that

> matches the value that I wish to delete and then invoke
clearProperty().
> The clearNode() approach seemed to do this for me in 1 step.
> 
> If you do recommend that I use the clearProperty() approach as I 
> described above for my purpose, then I'd go with it. As an 
> alternative, I thought of extending the XMLConfiguration and making 
> clearNode() public for my usage. Do you see any issues with this?
> 
> Thanks!
> vanaja

Would the XPathExpressionEngine be an option for you? Here you can
specify very complex keys with comparisons and other conditions.

Your approach with extending XMLConfiguration will certainly work. 
However, we are currently working on a version 2.0 of the Configuration
API, which will differ to some extent from the current API. I cannot
guarantee that this solution will still work with the new version (there
might be changes in the way nodes are handled). But there is nothing too
concrete yet.

Oliver

> 
> -----Original Message-----
> From: Oliver Heger [mailto:oliver.heger@oliver-heger.de]
> Sent: Tuesday, July 08, 2008 1:10 PM
> To: Vanaja Ravi (vanaja)
> Subject: Re: [Commons Configuration]Clearing a specific node in 
> XMLConfiguration
> 
> (I tried to send this reply to the commons user list, but always get a

> mail delivery failure.)
> 
> Vanaja Ravi (vanaja) schrieb:
>> Hi,
>>  
>> I am looking to delete a specific node in a list entry(key being the
>> same) and am using XMLConfiguration to read my configuration file.
>> clearNode() seems to be appropriate but is protected. Any reason why 
>> it should not be exposed?
>>  
>> thanks!
>> Vanaja
>>
> 
> The nodes are more or less an implementation detail and should not be 
> used directly to modify a configuration.
> 
> You should be able to achieve the same results using the "official"
> methods defined by the Configuration interface or by 
> HierarchicalConfiguration. For instance if you have a structure like
> this:
> 
> <servers>
>    <server>http://url1.com</server>
>    <server>http://url2.com</server>
>    ...
> </servers>
> 
> 
> you can use the clearProperty() method with an index for deleting a 
> specific <server> element:
> config.clearProperty("servers.server(0)");
> This would delete the first <server> element (indices start with 0).
> 
> For complex list structures the clearTree() method can be used. 
> Consider the following fragment:
> 
> <users>
>    <user>
>      <key>user1</key>
>      <name>Test user 1</name>
>    </user>
>    <user>
>      ...
>    </user>
>    ...
> </users>
> 
> To delete a specific user you can use clearTree() as follows:
> config.clearTree("users.user(1)");
> for deleting the second user record in this list.
> 
> HTH
> Oliver
> 
> 


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


Mime
View raw message