Return-Path: Delivered-To: apmail-commons-issues-archive@locus.apache.org Received: (qmail 59158 invoked from network); 7 Sep 2007 06:33:56 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 7 Sep 2007 06:33:56 -0000 Received: (qmail 93107 invoked by uid 500); 7 Sep 2007 06:33:49 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 92608 invoked by uid 500); 7 Sep 2007 06:33:48 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 92599 invoked by uid 99); 7 Sep 2007 06:33:48 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 06 Sep 2007 23:33:48 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO brutus.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 07 Sep 2007 06:35:14 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 067637141F2 for ; Thu, 6 Sep 2007 23:33:31 -0700 (PDT) Message-ID: <2839880.1189146810991.JavaMail.jira@brutus> Date: Thu, 6 Sep 2007 23:33:30 -0700 (PDT) From: "Oliver Heger (JIRA)" To: issues@commons.apache.org Subject: [jira] Commented: (CONFIGURATION-292) removeChild() doen't trigger auto saving In-Reply-To: <12245707.1186784142964.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/CONFIGURATION-292?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12525608 ] Oliver Heger commented on CONFIGURATION-292: -------------------------------------------- I am very reluctant to make the removeNode() method public and add the event for the following reasons: - This would add a new method to the public API of HierarchicalConfiguration with a semantic that somewhat conflicts with the clearProperty()/clearTree() methods. - The method was originally intended to do some cleanup after a property was deleted (to remove empty nodes without children). This is more an implementation detail rather than a feature to be exposed. - What would be the relation between an EVENT_REMOVE_NODE event and an EVENT_CLEAR_PROPERTY? Would either event trigger the other one or not? For event listeners it would be harder to properly react on these events. Having said that, what other options are there to solve your problem. As I understand it, you have a parent node and want to remove some of its children matching a certain condition. You could do the following: - Use the XPathExpressionEngine. Here you can use the full power of XPath to specify your condition when defining the key for clearProperty() or clearTree(). - Construct the keys on your own using indices. This could look roughly like the following pseudo code: ConfigurationNode parent = ... String parentKey = ... boolean found = false; do { for(Iterator it = parent.getChildren(); it.hasNext()) { ConfigurationNode node = (ConfigurationNode) it.next(); if(node meets my condition) { // construct a key for the first node with this name by using index 0 String nodeKey = parentKey + "." + node.getName() + "(0)"; config.clearTree(nodeKey); found = true; break; } }while(found); Here you create unambiguous keys for every single node to be removed. Does this help you? > removeChild() doen't trigger auto saving > ---------------------------------------- > > Key: CONFIGURATION-292 > URL: https://issues.apache.org/jira/browse/CONFIGURATION-292 > Project: Commons Configuration > Issue Type: Bug > Affects Versions: 1.4 > Environment: I am using Nightly build dated July 19, 2007 > Reporter: irina fridkina > Fix For: 2.0 > > > When I remove nodes from the XMLConfiguration with autoSave enabled the file doesn't change. Here is an example > XMLConfiguration config = new XMLConfiguration("c:\\conf.xml"); > config.setAutoSave(true) ; > ConfigurationNode parentNode = config.getRootNode(); > parentNode.removeChild(childName); > config.xml didn't change to reflect the changes -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.