Examples of ImmutableNode


Examples of org.apache.commons.configuration2.tree.ImmutableNode

            // display the children
            Iterator<ImmutableNode> it = children.iterator();
            while (it.hasNext())
            {
                ImmutableNode child = it.next();

                printNode(out, indentLevel + 1, child, handler);

                // add a semi colon for elements that are not dictionaries
                Object value = child.getValue();
                if (value != null && !(value instanceof Map) && !(value instanceof Configuration))
                {
                    out.println(";");
                }
View Full Code Here

Examples of org.apache.commons.configuration2.tree.ImmutableNode

            Configuration config = (Configuration) value;
            Iterator<String> it = config.getKeys();
            while (it.hasNext())
            {
                String key = it.next();
                ImmutableNode node =
                        new ImmutableNode.Builder().name(key)
                                .value(config.getProperty(key)).create();
                InMemoryNodeModel tempModel = new InMemoryNodeModel(node);
                printNode(out, indentLevel + 1, node, tempModel.getNodeHandler());
                out.println(";");
View Full Code Here

Examples of org.apache.commons.configuration2.tree.ImmutableNode

    public void testSimpleXPath()
    {
        List<?> results = context.selectNodes(CHILD_NAME1);
        assertEquals("Incorrect number of results", 2, results.size());
        for (Object result : results) {
            ImmutableNode node = (ImmutableNode) result;
            assertEquals("Incorrect node name", CHILD_NAME1, node.getNodeName());
        }

        results = context.selectNodes("/" + CHILD_NAME1);
        assertEquals("Incorrect number of results", 2, results.size());
View Full Code Here

Examples of org.apache.commons.configuration2.tree.ImmutableNode

        List<?> nodes = context.selectNodes("/" + CHILD_NAME1 + "[1]/*");
        assertEquals("Wrong number of children", CHILD_COUNT, nodes.size());
        int index = 1;
        for (Iterator<?> it = nodes.iterator(); it.hasNext(); index++)
        {
            ImmutableNode node = (ImmutableNode) it.next();
            assertEquals("Wrong node value for child " + index, "2." + index,
                    node.getValue());
        }
    }
View Full Code Here

Examples of org.apache.commons.configuration2.tree.ImmutableNode

    public void testFollowingSiblingAxis()
    {
        List<?> nodes = context.selectNodes("/" + CHILD_NAME1
                + "[2]/following-sibling::*");
        assertEquals("Wrong number of following siblings", 1, nodes.size());
        ImmutableNode node = (ImmutableNode) nodes.get(0);
        assertEquals("Wrong node type", CHILD_NAME2, node.getNodeName());
        assertEquals("Wrong index", String.valueOf(CHILD_COUNT), node
                .getValue());
    }
View Full Code Here

Examples of org.apache.commons.configuration2.tree.ImmutableNode

    public void setUp() throws Exception
    {
        super.setUp();

        // Adds further attributes to the test node
        ImmutableNode orgNode = root.getChildren().get(1);
        ImmutableNode testNode =
                orgNode.setAttribute(TEST_ATTR, "yes").setAttribute(NS_ATTR,
                        "configuration");
        pointer =
                new ConfigurationNodePointer<ImmutableNode>(testNode,
                        Locale.getDefault(), handler);
View Full Code Here

Examples of org.apache.commons.configuration2.tree.ImmutableNode

     * the child nodes are unknown. (This should not happen in practice.)
     */
    @Test
    public void testCompareChildNodePointersAttributes()
    {
        ImmutableNode n1 = new ImmutableNode.Builder().name("n1").create();
        ImmutableNode n2 = new ImmutableNode.Builder().name("n2").create();
        NodePointer p1 =
                new ConfigurationNodePointer<ImmutableNode>(pointer, n1,
                        handler);
        NodePointer p2 =
                new ConfigurationNodePointer<ImmutableNode>(pointer, n2,
View Full Code Here

Examples of org.apache.commons.configuration2.tree.ImmutableNode

     * Tests the leaf flag for a real leaf node.
     */
    @Test
    public void testIsLeafTrue()
    {
        ImmutableNode leafNode =
                new ImmutableNode.Builder().name("leafNode").create();
        pointer =
                new ConfigurationNodePointer<ImmutableNode>(pointer, leafNode,
                        handler);
        assertTrue("Not a leaf node", pointer.isLeaf());
View Full Code Here

Examples of org.apache.commons.configuration2.tree.ImmutableNode

     *
     * @param p the node pointer to test
     */
    private void checkIterators(NodePointer p)
    {
        ImmutableNode node = (ImmutableNode) p.getNode();
        NodeIterator it = p.childIterator(null, false, null);
        assertEquals("Iterator count differs from children count", node
                .getChildren().size(), iteratorSize(it));

        for (int index = 1; it.setPosition(index); index++)
        {
            NodePointer pchild = it.getNodePointer();
            assertEquals("Wrong child", node.getChildren().get(index - 1),
                    pchild.getNode());
            checkIterators(pchild);
        }

        it = p.attributeIterator(new QName(null, "*"));
        assertEquals("Iterator count differs from attribute count", node
                .getAttributes().size(), iteratorSize(it));
        for (int index = 1; it.setPosition(index); index++)
        {
            NodePointer pattr = it.getNodePointer();
            assertTrue("Node pointer is no attribute", pattr.isAttribute());
            assertTrue("Wrong attribute name", node.getAttributes()
                    .containsKey(pattr.getName().getName()));
        }
    }
View Full Code Here

Examples of org.apache.commons.configuration2.tree.ImmutableNode

        builder.configure(new FileBasedBuilderParametersImpl()
                .setFileName(testProperties));
        conf = builder.getConfiguration();
        builder.getFileHandler().setFile(testSaveConf);
        builder.setAutoSave(true);
        ImmutableNode node = NodeStructureHelper.createNode(
                "addNodesTest", Boolean.TRUE);
        Collection<ImmutableNode> nodes = new ArrayList<ImmutableNode>(1);
        nodes.add(node);
        conf.addNodes("test.autosave", nodes);
        XMLConfiguration c2 = new XMLConfiguration();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.