commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Wesley Miaw (JIRA)" <j...@apache.org>
Subject [jira] Commented: (CONFIGURATION-293) HierarchicalConfiguration.clearTree() does not remove named property
Date Thu, 23 Aug 2007 17:02:32 GMT

    [ https://issues.apache.org/jira/browse/CONFIGURATION-293?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12522195
] 

Wesley Miaw commented on CONFIGURATION-293:
-------------------------------------------

So I reimplemented clearTree() as follows, and it does what I expect it to do this way.

  Iterator<String> keys = getKeys(key);
  while (keys.hasNext()) {
    clearProperty(keys.next());
  }
  if (containsKey(key)) {
    clearProperty(key);
  }

the getKeys() while loop clears out all of the sub-properties, and clearProperty(key) does
the right thing because it actually sets the value of the property to null. So even though
the node isn't actually removed because it has no parent, it has no value anymore. From what
I understand, this fulfills the contract of clear*(), since technically none of the clear*()
methods say the nodes are removed, just that they have no value.

Of course, this fires off EVENT_CLEAR_PROPERTY instead of EVENT_CLEAR_TREE, but that's just
because the above code calls the public methods.

But that doesn't really match up with how you described it (and as the documentation mentions).
Why is it that in a non-CombinedConfiguration, the node would have a parent, but in a CombinedConfiguration,
it doesn't?

> HierarchicalConfiguration.clearTree() does not remove named property
> --------------------------------------------------------------------
>
>                 Key: CONFIGURATION-293
>                 URL: https://issues.apache.org/jira/browse/CONFIGURATION-293
>             Project: Commons Configuration
>          Issue Type: Bug
>    Affects Versions: 1.4
>            Reporter: Wesley Miaw
>         Attachments: bug-config.xml, bug-override.xml, bug-test.properties
>
>
> HierarchicalConfiguration.clearTree(String) calls HierarchicalConfiguration.removeNode(ConfigurationNode)
which removes nothing if the passed in ConfigurationNode has no parent. Having no parent is
true of nodes that have the root for their parent (it seems to me) as well as for nodes that
have no properties defined "above" them. Here is an example:
> config.addProperty("a.b.c", "c");
> config.addProperty("a.b.c.d", "d");
> config.addProperty("a.b.c.d.e", "e");
> The following sequence of calls will fail:
> config.clearTree("a.b.c");
> assert config.containsKey("a.b.c") == false;
> The following sequence of calls will succeed:
> config.clearTree("a.b.c.d");
> assert config.containsKey("a.b.c.d") == false;
> assert config.containsKey("a.b.c.d.e") == false;

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message