Package org.apache.commons.configuration.tree

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


        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))
            {
                synchronized (node)
                {
                    parent.addChild(node);
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

        if (getSubnodeKey() != null)
        {
            // construct the correct subnode key
            // determine path to root node
            List lstPathToRoot = new ArrayList();
            ConfigurationNode top = super.getRootNode();
            ConfigurationNode nd = node;
            while (nd != top)
            {
                lstPathToRoot.add(nd);
                nd = nd.getParentNode();
            }

            // construct the keys for the nodes on this path
            Collections.reverse(lstPathToRoot);
            String key = getSubnodeKey();
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

        // Initialize the new root node
        Object value = null;
        int valueCount = 0;
        for (Iterator it = nodes.iterator(); it.hasNext();)
        {
            ConfigurationNode nd = (ConfigurationNode) it.next();
            if (nd.getValue() != null)
            {
                value = nd.getValue();
                valueCount++;
            }
            nd.visit(visitor);

            for (Iterator it2 = visitor.getClone().getChildren().iterator(); it2
                    .hasNext();)
            {
                result.getRootNode().addChild((ConfigurationNode) it2.next());
View Full Code Here

        List nodes = fetchNodeList(prefix);

        for (Iterator itNodes = nodes.iterator(); itNodes.hasNext();)
        {
            ConfigurationNode node = (ConfigurationNode) itNodes.next();
            for (Iterator it = node.getChildren().iterator(); it.hasNext();)
            {
                ((ConfigurationNode) it.next()).visit(visitor);
            }
            for (Iterator it = node.getAttributes().iterator(); it.hasNext();)
            {
                ((ConfigurationNode) it.next()).visit(visitor);
            }
        }
View Full Code Here

     *
     * @param node the node to be removed
     */
    protected void removeNode(ConfigurationNode node)
    {
        ConfigurationNode parent = node.getParentNode();
        if (parent != null)
        {
            parent.removeChild(node);
            if (!nodeDefined(parent))
            {
                removeNode(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.