Package org.apache.commons.configuration.tree

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


        // 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

     * @return the new node
     * @since 1.3
     */
    private ConfigurationNode processNodeAddData(NodeAddData data)
    {
        ConfigurationNode node = data.getParent();

        // Create missing nodes on the path
        for (Iterator it = data.getPathNodes().iterator(); it.hasNext();)
        {
            ConfigurationNode child = createNode((String) it.next());
            node.addChild(child);
            node = child;
        }

        // Add new target node
        ConfigurationNode child = createNode(data.getNewNodeName());
        if (data.isAttribute())
        {
            node.addAttribute(child);
        }
        else
View Full Code Here

        {
            this(src.getName(), src.getValue());
            setReference(src.getReference());
            for (Iterator it = src.getChildren().iterator(); it.hasNext();)
            {
                ConfigurationNode nd = (ConfigurationNode) it.next();
                // Don't change the parent node
                ConfigurationNode parent = nd.getParentNode();
                addChild(nd);
                nd.setParentNode(parent);
            }

            for (Iterator it = src.getAttributes().iterator(); it.hasNext();)
            {
                ConfigurationNode nd = (ConfigurationNode) it.next();
                // Don't change the parent node
                ConfigurationNode parent = nd.getParentNode();
                addAttribute(nd);
                nd.setParentNode(parent);
            }
        }
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

        }

        else
        {
            Iterator it = configurations.iterator();
            ConfigurationNode node = ((ConfigData) it.next())
                    .getTransformedRoot();
            while (it.hasNext())
            {
                node = getNodeCombiner().combine(node,
                        ((ConfigData) it.next()).getTransformedRoot());
View Full Code Here

     * @param node the node
     * @return the owning configuration
     */
    private Configuration findSourceConfiguration(ConfigurationNode node)
    {
        ConfigurationNode root = null;
        ConfigurationNode current = node;

        // find the root node in this hierarchy
        while (current != null)
        {
            root = current;
            current = current.getParentNode();
        }

        // Check with the root nodes of the child configurations
        for (Iterator it = configurations.iterator(); it.hasNext();)
        {
View Full Code Here

    public void load(Reader reader) throws ConfigurationException
    {
        try
        {
            BufferedReader bufferedReader = new BufferedReader(reader);
            ConfigurationNode sectionNode = getRootNode();

            String line = bufferedReader.readLine();
            while (line != null)
            {
                line = line.trim();
                if (!isCommentLine(line))
                {
                    if (isSectionLine(line))
                    {
                        String section = line.substring(1, line.length() - 1);
                        sectionNode = getSectionNode(section);
                    }

                    else
                    {
                        String key = "";
                        String value = "";
                        int index = line.indexOf("=");
                        if (index >= 0)
                        {
                            key = line.substring(0, index);
                            value = parseValue(line.substring(index + 1), bufferedReader);
                        }
                        else
                        {
                            index = line.indexOf(":");
                            if (index >= 0)
                            {
                                key = line.substring(0, index);
                                value = parseValue(line.substring(index + 1), bufferedReader);
                            }
                            else
                            {
                                key = line;
                            }
                        }
                        key = key.trim();
                        if (key.length() < 1)
                        {
                            // use space for properties with no key
                            key = " ";
                        }
                        ConfigurationNode node = createNode(key);
                        node.setValue(value);
                        sectionNode.addChild(node);
                    }
                }

                line = bufferedReader.readLine();
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.