Re: svn commit: r1792011 - in /commons/proper/configuration/trunk/src: changes/changes.xml main/java/org/apache/commons/configuration2/tree/ImmutableNode.java test/java/org/apache/commons/configuratio
Fixed in SVN. Thank you for the good catch. Gary On Thu, Apr 20, 2017 at 5:59 AM, Gary Gregorywrote: > > > On Apr 20, 2017 2:40 AM, "Oliver Heger" > wrote: > > > > Am 20.04.2017 um 05:17 schrieb ggreg...@apache.org: > >> Author: ggregory >> Date: Thu Apr 20 03:17:59 2017 >> New Revision: 1792011 >> >> URL: http://svn.apache.org/viewvc?rev=1792011=rev >> Log: >> [CONFIGURATION-664] Add API org.apache.commons.configurati >> on2.tree.ImmutableNode.getChildren(String). >> >> Modified: >> commons/proper/configuration/trunk/src/changes/changes.xml >> commons/proper/configuration/trunk/src/main/java/org/apache/ >> commons/configuration2/tree/ImmutableNode.java >> commons/proper/configuration/trunk/src/test/java/org/apache/ >> commons/configuration2/tree/TestImmutableNode.java >> >> Modified: commons/proper/configuration/trunk/src/changes/changes.xml >> URL: http://svn.apache.org/viewvc/commons/proper/configuration/tr >> unk/src/changes/changes.xml?rev=1792011=1792010=1792011=diff >> >> == >> --- commons/proper/configuration/trunk/src/changes/changes.xml (original) >> +++ commons/proper/configuration/trunk/src/changes/changes.xml Thu Apr >> 20 03:17:59 2017 >> @@ -41,6 +41,9 @@ >> >> Add API org.apache.commons.configurati >> on2.DataConfiguration.getURI(String) methods. >> >> + >> +Add API org.apache.commons.configurati >> on2.tree.ImmutableNode.getChildren(String). >> + >> >> Update platform requirement from Java 6 to 7. >> >> >> Modified: commons/proper/configuration/trunk/src/main/java/org/apache/ >> commons/configuration2/tree/ImmutableNode.java >> URL: http://svn.apache.org/viewvc/commons/proper/configuration/tr >> unk/src/main/java/org/apache/commons/configuration2/tree/Imm >> utableNode.java?rev=1792011=1792010=1792011=diff >> >> == >> --- commons/proper/configuration/trunk/src/main/java/org/apache/ >> commons/configuration2/tree/ImmutableNode.java (original) >> +++ commons/proper/configuration/trunk/src/main/java/org/apache/ >> commons/configuration2/tree/ImmutableNode.java Thu Apr 20 03:17:59 2017 >> @@ -102,6 +102,29 @@ public final class ImmutableNode >> } >> >> /** >> + * Returns a list with the children of this node. This list cannot be >> + * modified. >> + * @param name the node name to find >> + * >> + * @return a list with the child nodes >> + */ >> +public List getChildren(final String name) >> +{ >> +final List list = new ArrayList<>(); >> +if (name == null) { >> +return list; >> +} >> +for (final ImmutableNode node : children) >> +{ >> +if (name.equals(node.getNodeName())) >> +{ >> +list.add(node); >> +} >> +} >> +return list; >> +} >> > > The list does not seem to be unmodifiable. Or do you mean that modifying > the list does not impact the child nodes? I think the implementation is not > aligned with the comment. > > > The comment is wrong. Will fix today, thank you! > > Gary > > > Oliver > > > + >> +/** >> * Returns a map with the attributes of this node. This map cannot be >> * modified. >> * >> >> Modified: commons/proper/configuration/trunk/src/test/java/org/apache/ >> commons/configuration2/tree/TestImmutableNode.java >> URL: http://svn.apache.org/viewvc/commons/proper/configuration/tr >> unk/src/test/java/org/apache/commons/configuration2/tree/Tes >> tImmutableNode.java?rev=1792011=1792010=1792011=diff >> >> == >> --- commons/proper/configuration/trunk/src/test/java/org/apache/ >> commons/configuration2/tree/TestImmutableNode.java (original) >> +++ commons/proper/configuration/trunk/src/test/java/org/apache/ >> commons/configuration2/tree/TestImmutableNode.java Thu Apr 20 03:17:59 >> 2017 >> @@ -30,6 +30,7 @@ import java.util.Iterator; >> import java.util.List; >> import java.util.Map; >> >> +import org.junit.Assert; >> import org.junit.Test; >> >> /** >> @@ -404,6 +405,49 @@ public class TestImmutableNode >> } >> >> /** >> + * Tests getting named children. >> + */ >> +@Test >> +public void testGetChildrenByName() >> +{ >> +ImmutableNode node = createDefaultNode(VALUE); >> +ImmutableNode child2 = >> +new ImmutableNode.Builder().name("child2").create(); >> +ImmutableNode node2 = node.addChild(child2); >> +checkUpdatedNode(node, node2); >> +assertEquals("child2", node2.getChildren("child2").ge >> t(0).getNodeName()); >> +assertEquals(child2, node2.getChildren("child2").get(0)); >> +} >> + >> +/** >> + * Tests getting named
Re: svn commit: r1792011 - in /commons/proper/configuration/trunk/src: changes/changes.xml main/java/org/apache/commons/configuration2/tree/ImmutableNode.java test/java/org/apache/commons/configuratio
On Apr 20, 2017 2:40 AM, "Oliver Heger"wrote: Am 20.04.2017 um 05:17 schrieb ggreg...@apache.org: > Author: ggregory > Date: Thu Apr 20 03:17:59 2017 > New Revision: 1792011 > > URL: http://svn.apache.org/viewvc?rev=1792011=rev > Log: > [CONFIGURATION-664] Add API org.apache.commons.configurati > on2.tree.ImmutableNode.getChildren(String). > > Modified: > commons/proper/configuration/trunk/src/changes/changes.xml > commons/proper/configuration/trunk/src/main/java/org/apache/ > commons/configuration2/tree/ImmutableNode.java > commons/proper/configuration/trunk/src/test/java/org/apache/ > commons/configuration2/tree/TestImmutableNode.java > > Modified: commons/proper/configuration/trunk/src/changes/changes.xml > URL: http://svn.apache.org/viewvc/commons/proper/configuration/tr > unk/src/changes/changes.xml?rev=1792011=1792010=1792011=diff > > == > --- commons/proper/configuration/trunk/src/changes/changes.xml (original) > +++ commons/proper/configuration/trunk/src/changes/changes.xml Thu Apr 20 > 03:17:59 2017 > @@ -41,6 +41,9 @@ > > Add API org.apache.commons.configurati > on2.DataConfiguration.getURI(String) methods. > > + > +Add API org.apache.commons.configuration2.tree.ImmutableNode. > getChildren(String). > + > > Update platform requirement from Java 6 to 7. > > > Modified: commons/proper/configuration/trunk/src/main/java/org/apache/ > commons/configuration2/tree/ImmutableNode.java > URL: http://svn.apache.org/viewvc/commons/proper/configuration/tr > unk/src/main/java/org/apache/commons/configuration2/tree/ > ImmutableNode.java?rev=1792011=1792010=1792011=diff > > == > --- commons/proper/configuration/trunk/src/main/java/org/apache/ > commons/configuration2/tree/ImmutableNode.java (original) > +++ commons/proper/configuration/trunk/src/main/java/org/apache/ > commons/configuration2/tree/ImmutableNode.java Thu Apr 20 03:17:59 2017 > @@ -102,6 +102,29 @@ public final class ImmutableNode > } > > /** > + * Returns a list with the children of this node. This list cannot be > + * modified. > + * @param name the node name to find > + * > + * @return a list with the child nodes > + */ > +public List getChildren(final String name) > +{ > +final List list = new ArrayList<>(); > +if (name == null) { > +return list; > +} > +for (final ImmutableNode node : children) > +{ > +if (name.equals(node.getNodeName())) > +{ > +list.add(node); > +} > +} > +return list; > +} > The list does not seem to be unmodifiable. Or do you mean that modifying the list does not impact the child nodes? I think the implementation is not aligned with the comment. The comment is wrong. Will fix today, thank you! Gary Oliver + > +/** > * Returns a map with the attributes of this node. This map cannot be > * modified. > * > > Modified: commons/proper/configuration/trunk/src/test/java/org/apache/ > commons/configuration2/tree/TestImmutableNode.java > URL: http://svn.apache.org/viewvc/commons/proper/configuration/tr > unk/src/test/java/org/apache/commons/configuration2/tree/ > TestImmutableNode.java?rev=1792011=1792010=1792011=diff > > == > --- commons/proper/configuration/trunk/src/test/java/org/apache/ > commons/configuration2/tree/TestImmutableNode.java (original) > +++ commons/proper/configuration/trunk/src/test/java/org/apache/ > commons/configuration2/tree/TestImmutableNode.java Thu Apr 20 03:17:59 > 2017 > @@ -30,6 +30,7 @@ import java.util.Iterator; > import java.util.List; > import java.util.Map; > > +import org.junit.Assert; > import org.junit.Test; > > /** > @@ -404,6 +405,49 @@ public class TestImmutableNode > } > > /** > + * Tests getting named children. > + */ > +@Test > +public void testGetChildrenByName() > +{ > +ImmutableNode node = createDefaultNode(VALUE); > +ImmutableNode child2 = > +new ImmutableNode.Builder().name("child2").create(); > +ImmutableNode node2 = node.addChild(child2); > +checkUpdatedNode(node, node2); > +assertEquals("child2", node2.getChildren("child2").ge > t(0).getNodeName()); > +assertEquals(child2, node2.getChildren("child2").get(0)); > +} > + > +/** > + * Tests getting named children. > + */ > +@Test > +public void testGetChildrenByNullName() > +{ > +ImmutableNode node = createDefaultNode(VALUE); > +ImmutableNode child2 = > +new ImmutableNode.Builder().name("child2").create(); > +ImmutableNode node2 =
Re: svn commit: r1792011 - in /commons/proper/configuration/trunk/src: changes/changes.xml main/java/org/apache/commons/configuration2/tree/ImmutableNode.java test/java/org/apache/commons/configuratio
Am 20.04.2017 um 05:17 schrieb ggreg...@apache.org: Author: ggregory Date: Thu Apr 20 03:17:59 2017 New Revision: 1792011 URL: http://svn.apache.org/viewvc?rev=1792011=rev Log: [CONFIGURATION-664] Add API org.apache.commons.configuration2.tree.ImmutableNode.getChildren(String). Modified: commons/proper/configuration/trunk/src/changes/changes.xml commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/tree/ImmutableNode.java commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration2/tree/TestImmutableNode.java Modified: commons/proper/configuration/trunk/src/changes/changes.xml URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/changes/changes.xml?rev=1792011=1792010=1792011=diff == --- commons/proper/configuration/trunk/src/changes/changes.xml (original) +++ commons/proper/configuration/trunk/src/changes/changes.xml Thu Apr 20 03:17:59 2017 @@ -41,6 +41,9 @@ Add API org.apache.commons.configuration2.DataConfiguration.getURI(String) methods. + +Add API org.apache.commons.configuration2.tree.ImmutableNode.getChildren(String). + Update platform requirement from Java 6 to 7. Modified: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/tree/ImmutableNode.java URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/tree/ImmutableNode.java?rev=1792011=1792010=1792011=diff == --- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/tree/ImmutableNode.java (original) +++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/tree/ImmutableNode.java Thu Apr 20 03:17:59 2017 @@ -102,6 +102,29 @@ public final class ImmutableNode } /** + * Returns a list with the children of this node. This list cannot be + * modified. + * @param name the node name to find + * + * @return a list with the child nodes + */ +public List getChildren(final String name) +{ +final List list = new ArrayList<>(); +if (name == null) { +return list; +} +for (final ImmutableNode node : children) +{ +if (name.equals(node.getNodeName())) +{ +list.add(node); +} +} +return list; +} The list does not seem to be unmodifiable. Or do you mean that modifying the list does not impact the child nodes? I think the implementation is not aligned with the comment. Oliver + +/** * Returns a map with the attributes of this node. This map cannot be * modified. * Modified: commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration2/tree/TestImmutableNode.java URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration2/tree/TestImmutableNode.java?rev=1792011=1792010=1792011=diff == --- commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration2/tree/TestImmutableNode.java (original) +++ commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration2/tree/TestImmutableNode.java Thu Apr 20 03:17:59 2017 @@ -30,6 +30,7 @@ import java.util.Iterator; import java.util.List; import java.util.Map; +import org.junit.Assert; import org.junit.Test; /** @@ -404,6 +405,49 @@ public class TestImmutableNode } /** + * Tests getting named children. + */ +@Test +public void testGetChildrenByName() +{ +ImmutableNode node = createDefaultNode(VALUE); +ImmutableNode child2 = +new ImmutableNode.Builder().name("child2").create(); +ImmutableNode node2 = node.addChild(child2); +checkUpdatedNode(node, node2); +assertEquals("child2", node2.getChildren("child2").get(0).getNodeName()); +assertEquals(child2, node2.getChildren("child2").get(0)); +} + +/** + * Tests getting named children. + */ +@Test +public void testGetChildrenByNullName() +{ +ImmutableNode node = createDefaultNode(VALUE); +ImmutableNode child2 = +new ImmutableNode.Builder().name("child2").create(); +ImmutableNode node2 = node.addChild(child2); +checkUpdatedNode(node, node2); +assertTrue(node2.getChildren(null).isEmpty()); +} + +/** + * Tests getting named children. + */ +@Test +public void testGetChildrenByMissingName() +{ +ImmutableNode node = createDefaultNode(VALUE); +ImmutableNode child2 = +new