Package org.apache.commons.configuration.tree

Examples of org.apache.commons.configuration.tree.ConfigurationNode


        Set sections = new ListOrderedSet();
        boolean globalSection = false;

        for (Iterator it = getRootNode().getChildren().iterator(); it.hasNext();)
        {
            ConfigurationNode node = (ConfigurationNode) it.next();
            if (isSectionNode(node))
            {
                if (globalSection)
                {
                    sections.add(null);
                    globalSection = false;
                }
                sections.add(node.getName());
            }
            else
            {
                globalSection = true;
            }
View Full Code Here


        if (!nodes.isEmpty())
        {
            return (ConfigurationNode) nodes.get(0);
        }

        ConfigurationNode node = createNode(sectionName);
        markSectionNode(node);
        getRootNode().addChild(node);
        return node;
    }
View Full Code Here

    {
        ViewNode parent = new ViewNode();

        for (Iterator it = getRootNode().getChildren().iterator(); it.hasNext();)
        {
            ConfigurationNode node = (ConfigurationNode) it.next();
            if (!isSectionNode(node))
            {
                parent.addChild(node);
            }
        }
View Full Code Here

     * Tests adding an attribute node with the addNodes() method.
     */
    public void testAddNodesAttributeNode()
    {
        Collection nodes = new ArrayList();
        ConfigurationNode nd = createNode("length", "10");
        nd.setAttribute(true);
        nodes.add(nd);
        config.addNodes("tables.table(0).fields.field(1)", nodes);
        assertEquals("Attribute was not added", "10", config
                .getString("tables.table(0).fields.field(1)[@length]"));
    }
View Full Code Here

        config.setRootNode(root);
        config.addProperty("child2", "test2");
        List nodes = config.getExpressionEngine().query(config.getRootNode(),
                "child2");
        assertEquals("Wrong number of result nodes", 1, nodes.size());
        ConfigurationNode child2 = (ConfigurationNode) nodes.get(0);
        assertEquals("Different parent nodes", child1.getParentNode(), child2
                .getParentNode());
    }
View Full Code Here

        DefaultConfigurationNode child1 = new DefaultConfigurationNode(
                "child1", "test1");
        root.addChild(child1);
        config.setRootNode(root);
        config.addProperty("child2", "test2");
        ConfigurationNode oldRoot = config.getRoot();
        assertEquals("Wrong number of children", 2, oldRoot.getChildrenCount());
    }
View Full Code Here

    public void testInitCopy() throws ConfigurationException
    {
      XMLConfiguration copy = new XMLConfiguration(conf);
        assertEquals("value", copy.getProperty("element"));
        assertNull("Document was copied, too", copy.getDocument());
        ConfigurationNode root = copy.getRootNode();
        for(Iterator it = root.getChildren().iterator(); it.hasNext();)
        {
          ConfigurationNode node = (ConfigurationNode) it.next();
          assertNull("Reference was not cleared", node.getReference());
        }

        removeTestFile();
        copy.setFile(testSaveConf);
        copy.save();
View Full Code Here

     * Tests saving a configuration after a node was added. Test for
     * CONFIGURATION-294.
     */
    public void testAddNodesAndSave() throws ConfigurationException
    {
        ConfigurationNode node = new HierarchicalConfiguration.Node("test");
        ConfigurationNode child = new HierarchicalConfiguration.Node("child");
        node.addChild(child);
        ConfigurationNode attr = new HierarchicalConfiguration.Node("attr");
        node.addAttribute(attr);
        ConfigurationNode node2 = conf.createNode("test2");
        Collection nodes = new ArrayList(2);
        nodes.add(node);
        nodes.add(node2);
        conf.addNodes("add.nodes", nodes);
        conf.setFile(testSaveConf);
View Full Code Here

        conf.addProperty("testAddNodes.property(1).value", "value2");
        Collection nodes = new ArrayList();
        nodes.add(new HierarchicalConfiguration.Node("property"));
        conf.addNodes("testAddNodes", nodes);
        nodes.clear();
        ConfigurationNode nd = new HierarchicalConfiguration.Node("name",
                "prop3");
        nd.setAttribute(true);
        nodes.add(nd);
        conf.addNodes("testAddNodes.property(2)", nodes);
        assertEquals("Attribute not added", "prop3", conf
                .getString("testAddNodes.property(2)[@name]"));
    }
View Full Code Here

                    // key is invalid, so detach this subnode configuration
                    setSubnodeKey(null);
                }
                else
                {
                    ConfigurationNode currentRoot = (ConfigurationNode) nodes
                            .get(0);
                    if (currentRoot != super.getRootNode())
                    {
                        // the root node was changed due to a change of the
                        // parent
View Full Code Here

TOP

Related Classes of org.apache.commons.configuration.tree.ConfigurationNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.