Examples of TreeWalker


Examples of org.w3c.dom.traversal.TreeWalker

        TreeWalker tw = new TreeWalkerImpl(dom, NodeFilter.SHOW_ALL, null, false);
        assertEquals("a", tw.getRoot().getLocalName());
    }

    public void testWhatToShow() throws Exception {
        TreeWalker tw = new TreeWalkerImpl(dom, NodeFilter.SHOW_COMMENT, null, false);
        assertEquals(NodeFilter.SHOW_COMMENT, tw.getWhatToShow());
        assertEquals(null, tw.nextNode());
    }
View Full Code Here

Examples of org.w3c.dom.traversal.TreeWalker

                }
                return NodeFilter.FILTER_SKIP;
            }
        };

        TreeWalker tw = new TreeWalkerImpl(dom, NodeFilter.SHOW_ALL, nf, false);
        assertEquals(nf, tw.getFilter());
        assertEquals("b", tw.nextNode().getNodeName());
        assertEquals("f", tw.nextNode().getNodeName());
        assertEquals(null, tw.nextNode());
    }
View Full Code Here

Examples of org.w3c.dom.traversal.TreeWalker

        assertEquals("f", tw.nextNode().getNodeName());
        assertEquals(null, tw.nextNode());
    }

    public void testNextNode() throws Exception {
        TreeWalker tw = new TreeWalkerImpl(dom, NodeFilter.SHOW_ALL, null, false);
        assertEquals("a", tw.getCurrentNode().getLocalName());

        assertEquals("b", tw.nextNode().getLocalName());
        assertEquals("c", tw.nextNode().getLocalName());
        assertEquals("d", tw.nextNode().getLocalName());
        assertEquals("e", tw.nextNode().getLocalName());
        assertEquals("f", tw.nextNode().getLocalName());
        assertEquals("g", tw.nextNode().getLocalName());
        assertEquals("h", tw.nextNode().getLocalName());
        assertEquals("i", tw.nextNode().getLocalName());
        assertEquals(null, tw.nextNode());
    }
View Full Code Here

Examples of org.w3c.dom.traversal.TreeWalker

        assertEquals("i", tw.nextNode().getLocalName());
        assertEquals(null, tw.nextNode());
    }

    public void testPreviousNode() throws Exception {
        TreeWalker tw = new TreeWalkerImpl(dom, NodeFilter.SHOW_ALL, null, false);
        tw.setCurrentNode(dom.getLastChild());
        assertEquals("i", tw.getCurrentNode().getLocalName());

        assertEquals("h", tw.previousNode().getLocalName());
        assertEquals("g", tw.previousNode().getLocalName());
        assertEquals("f", tw.previousNode().getLocalName());
        assertEquals("e", tw.previousNode().getLocalName());
        assertEquals("d", tw.previousNode().getLocalName());
        assertEquals("c", tw.previousNode().getLocalName());
        assertEquals("b", tw.previousNode().getLocalName());
        assertEquals("a", tw.previousNode().getLocalName());
        assertEquals(null, tw.previousNode());
    }
View Full Code Here

Examples of org.w3c.dom.traversal.TreeWalker

        assertEquals("a", tw.previousNode().getLocalName());
        assertEquals(null, tw.previousNode());
    }

    public void testCurrentNode() throws Exception {
        TreeWalker tw = new TreeWalkerImpl(dom, NodeFilter.SHOW_ALL, null, false);

        assertEquals("a", tw.getCurrentNode().getLocalName());
        assertEquals(null, tw.previousNode());
        assertEquals("a", tw.getCurrentNode().getLocalName());

        tw.setCurrentNode(dom.getLastChild());
        assertEquals("i", tw.getCurrentNode().getLocalName());
        assertEquals(null, tw.nextNode());
        assertEquals("i", tw.getCurrentNode().getLocalName());

        try {
            tw.setCurrentNode(null);
            fail("Exception expected");
        } catch (DOMException e) {
        }
        assertEquals("i", tw.getCurrentNode().getLocalName());
    }
View Full Code Here

Examples of org.w3c.dom.traversal.TreeWalker

        }
        assertEquals("i", tw.getCurrentNode().getLocalName());
    }

    public void testParentNode() throws Exception {
        TreeWalker tw = new TreeWalkerImpl(dom, NodeFilter.SHOW_ALL, null, false);
        // Go to F node
        tw.nextNode();
        tw.nextNode();
        tw.nextNode();
        tw.nextNode();
        tw.nextNode();
        assertEquals("f", tw.getCurrentNode().getLocalName());

        assertEquals("d", tw.parentNode().getLocalName());
        assertEquals("c", tw.parentNode().getLocalName());
        assertEquals("a", tw.parentNode().getLocalName());
        assertEquals(null, tw.parentNode());
    }
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.