Package org.apache.pivot.xml

Examples of org.apache.pivot.xml.Element$ElementDictionary


        boolean expanded, boolean selected, TreeView.NodeCheckState checkState,
        boolean highlighted, boolean disabled) {
        if (node != null) {
            String text;
            if (node instanceof Element) {
                Element element = (Element)node;
                text = "<" + element.getName() + ">";
            } else if (node instanceof TextNode) {
                TextNode textNode = (TextNode)node;
                text = textNode.getText();

                if (text.length() > MAXIMUM_TEXT_LENGTH) {
View Full Code Here


    }

    public String toString(Object node) {
        String string;
        if (node instanceof Element) {
            Element element = (Element)node;
            string = element.getName();
        } else if (node instanceof TextNode) {
            TextNode textNode = (TextNode)node;
            string = textNode.getText();
        } else {
            throw new IllegalArgumentException();
View Full Code Here

public class XMLSerializerTest {
    @Test
    public void basicTest() throws IOException, SerializationException {
        XMLSerializer xmlSerializer = new XMLSerializer();

        Element root = xmlSerializer.readObject(getClass().getResourceAsStream("sample.xml"));

        assertEquals(root.getName(), "root");

        Element a = XML.getElement(root, "a");
        assertEquals(a.getName(), "a");
        assertEquals(a.get("id"), "x");

        Element b = XML.getElement(root, "a/b");
        assertEquals(b.getName(), "b");
        assertEquals(b.get("id"), "y");

        b = XML.getElement(a, "b");
        assertEquals(b.getName(), "b");
        assertEquals(b.get("id"), "y");

        List<Element> cs = XML.getElements(root, "a/b", "c");
        assertEquals(cs.getLength(), 1);

        List<Element> fs = XML.getElements(root, "d/e", "f");
        assertEquals(fs.getLength(), 4);

        Element e = XML.getElement(root, "d/e");
        Element f = XML.getElement(e, "f");
        assertEquals(f.getName(), "f");

        Element g = XML.getElement(e, "g");
        assertEquals(g.getName(), "g");

        String ft = XML.getText(root, "d/e/f");
        assertEquals(ft, "1");

        String gt = XML.getText(root, "d/e/g");
View Full Code Here

    }

    @Test
    public void equalsTest() throws IOException, SerializationException {
        XMLSerializer xmlSerializer = new XMLSerializer();
        Element root1 = xmlSerializer.readObject(getClass().getResourceAsStream("sample.xml"));
        Element root2 = xmlSerializer.readObject(getClass().getResourceAsStream("sample.xml"));

        assertTrue(root1.equals(root2));

        Element a = XML.getElement(root2, "a");
        a.getAttributes().remove(0, 1);

        assertFalse(root1.equals(root2));
    }
View Full Code Here

TOP

Related Classes of org.apache.pivot.xml.Element$ElementDictionary

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.