Package org.apache.commons.configuration.tree

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


        ConfigurationNodeIteratorChildren it = new ConfigurationNodeIteratorChildren(
                rootPointer, null, true, childPointer);
        int value = 3;
        for (int index = 1; it.setPosition(index); index++, value--)
        {
            ConfigurationNode node = (ConfigurationNode) it.getNodePointer()
                    .getNode();
            assertEquals("Incorrect value at index " + index, String
                    .valueOf(value), node.getValue());
        }
        assertEquals("Iteration ended not at end node", 0, value);
    }
View Full Code Here


                new DefaultConfigurationNode("newNode"));
        ConfigurationNodeIteratorChildren it = new ConfigurationNodeIteratorChildren(
                rootPointer, null, false, childPointer);
        assertEquals("Wrong size of iteration", CHILD_COUNT, iteratorSize(it));
        it.setPosition(1);
        ConfigurationNode node = (ConfigurationNode) it.getNodePointer()
                .getNode();
        assertEquals("Wrong start node", "1", node.getValue());
    }
View Full Code Here

    private void checkValues(NodeIterator iterator, int[] expectedIndices)
    {
        List nodes = iterationElements(iterator);
        for (int i = 0; i < expectedIndices.length; i++)
        {
            ConfigurationNode child = (ConfigurationNode) nodes.get(i);
            assertTrue("Wrong index value for child " + i, child.getValue()
                    .toString().endsWith(String.valueOf(expectedIndices[i])));
        }
    }
View Full Code Here

         *
         * @param node the node
         */
        public void visitAfterChildren(ConfigurationNode node)
        {
            ConfigurationNode copy = (ConfigurationNode) copyStack.pop();
            if (copyStack.isEmpty())
            {
                result = copy;
            }
        }
View Full Code Here

         *
         * @param node the node
         */
        public void visitBeforeChildren(ConfigurationNode node)
        {
            ConfigurationNode copy = (ConfigurationNode) node.clone();
            copy.setParentNode(null);

            if (!copyStack.isEmpty())
            {
                if (node.isAttribute())
                {
View Full Code Here

    public Map getBeanProperties()
    {
        Map props = new HashMap();
        for (Iterator it = getNode().getAttributes().iterator(); it.hasNext();)
        {
            ConfigurationNode attr = (ConfigurationNode) it.next();
            if (!isReservedNode(attr))
            {
                props.put(attr.getName(), interpolate(attr .getValue()));
            }
        }

        return props;
    }
View Full Code Here

    public Map getNestedBeanDeclarations()
    {
        Map nested = new HashMap();
        for (Iterator it = getNode().getChildren().iterator(); it.hasNext();)
        {
            ConfigurationNode child = (ConfigurationNode) it.next();
            if (!isReservedNode(child))
            {
                nested.put(child.getName(), createBeanDeclaration(child));
            }
        }

        return nested;
    }
View Full Code Here

        else
        {
            List list = new ArrayList();
            for (Iterator it = nodes.iterator(); it.hasNext();)
            {
                ConfigurationNode node = (ConfigurationNode) it.next();
                if (node.getValue() != null)
                {
                    list.add(node.getValue());
                }
            }

            if (list.size() < 1)
            {
View Full Code Here

     * @param obj the value of the new property
     */
    protected void addPropertyDirect(String key, Object obj)
    {
        NodeAddData data = getExpressionEngine().prepareAdd(getRootNode(), key);
        ConfigurationNode node = processNodeAddData(data);
        node.setValue(obj);
    }
View Full Code Here

        {
            return;
        }

        fireEvent(EVENT_ADD_NODES, key, nodes, true);
        ConfigurationNode parent;
        List target = fetchNodeList(key);
        if (target.size() == 1)
        {
            // existing unique key
            parent = (ConfigurationNode) target.get(0);
        }
        else
        {
            // otherwise perform an add operation
            parent = processNodeAddData(getExpressionEngine().prepareAdd(
                    getRootNode(), key));
        }

        if (parent.isAttribute())
        {
            throw new IllegalArgumentException(
                    "Cannot add nodes to an attribute node!");
        }

        for (Iterator it = nodes.iterator(); it.hasNext();)
        {
            ConfigurationNode child = (ConfigurationNode) it.next();
            if (child.isAttribute())
            {
                parent.addAttribute(child);
            }
            else
            {
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.