Package org.apache.pivot.xml

Examples of org.apache.pivot.xml.XMLSerializer


                return false;
            }
        });

        GetQuery getQuery = new GetQuery("feeds.dzone.com", "/javalobby/frontpage");
        getQuery.setSerializer(new XMLSerializer());
        getQuery.getParameters().put("format", "xml");

        getQuery.execute(new TaskAdapter<Object>(new TaskListener<Object>() {
            @Override
            public void taskExecuted(Task<Object> task) {
View Full Code Here


import static org.junit.Assert.assertNull;

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 = XMLSerializer.getElement(root, "a");
        assertEquals(a.getName(), "a");
View Full Code Here

import org.junit.Test;

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");
View Full Code Here

        assertEquals(XML.getText(root, "d[0]/e[1]"), null);
    }

    @Test
    public void equalsTest() throws IOException, SerializationException {
        XMLSerializer xmlSerializer = new XMLSerializer();
        XMLSerializerListener xmlSerializerListener = new XMLSerializerListener() {
            @Override
            public void beginElement(XMLSerializer xmlSerializerArgument, Element element) {
                System.out.println("Begin element: " + element);
            }

            @Override
            public void endElement(XMLSerializer xmlSerializerArgument) {
                System.out.println("End element");
            }

            @Override
            public void readTextNode(XMLSerializer xmlSerializerArgument, TextNode textNode) {
                System.out.println("Read text node: " + textNode);
            }
        };

        xmlSerializer.getXMLSerializerListeners().add(xmlSerializerListener);
        Element root1 = xmlSerializer.readObject(getClass().getResourceAsStream("sample.xml"));
        assertNotNull(root1);

        xmlSerializer.getXMLSerializerListeners().remove(xmlSerializerListener);
        Element root2 = xmlSerializer.readObject(getClass().getResourceAsStream("sample.xml"));
        assertNotNull(root2);
    }
View Full Code Here

        window.setTitle(WINDOW_TITLE);
        window.open(display);
        window.requestFocus();

        if (System.in.available() > 0) {
            XMLSerializer xmlSerializer = new XMLSerializer();
            try {
                setDocument(xmlSerializer.readObject(System.in));
            } catch (Exception exception) {
                // No-op
            }
        }
    }
View Full Code Here

        Manifest clipboardContent = Clipboard.getContent();

        if (clipboardContent != null
            && clipboardContent.containsText()) {
            String xml = null;
            XMLSerializer xmlSerializer = new XMLSerializer();
            try {
                xml = clipboardContent.getText();
                setDocument(xmlSerializer.readObject(new StringReader(xml)));
            } catch (Exception exception) {
                Prompt.prompt(exception.getMessage(), window);
            }

            window.setTitle(WINDOW_TITLE);
View Full Code Here

        try {
            FileList fileList = dragContent.getFileList();
            if (fileList.getLength() == 1) {
                File file = fileList.get(0);

                XMLSerializer xmlSerializer = new XMLSerializer();
                FileInputStream fileInputStream = null;
                try {
                    try {
                        fileInputStream = new FileInputStream(file);
                        setDocument(xmlSerializer.readObject(fileInputStream));
                    } finally {
                        if (fileInputStream != null) {
                            fileInputStream.close();
                        }
                    }
View Full Code Here

import org.junit.Test;

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");
View Full Code Here

        assertEquals(XML.getText(root, "d[0]/e[1]"), null);
    }

    @Test
    public void equalsTest() throws IOException, SerializationException {
        XMLSerializer xmlSerializer = new XMLSerializer();
        XMLSerializerListener xmlSerializerListener = new XMLSerializerListener() {
            @Override
            public void beginElement(XMLSerializer xmlSerializer, Element element) {
                System.out.println("Begin element: " + element);
            }

            @Override
            public void endElement(XMLSerializer xmlSerializer) {
                System.out.println("End element");
            }

            @Override
            public void readTextNode(XMLSerializer xmlSerializer, TextNode textNode) {
                System.out.println("Read text node: " + textNode);
            }
        };

        xmlSerializer.getXMLSerializerListeners().add(xmlSerializerListener);
        Element root1 = xmlSerializer.readObject(getClass().getResourceAsStream("sample.xml"));
        assertNotNull(root1);

        xmlSerializer.getXMLSerializerListeners().remove(xmlSerializerListener);
        Element root2 = xmlSerializer.readObject(getClass().getResourceAsStream("sample.xml"));
        assertNotNull(root2);
    }
View Full Code Here

        window.setTitle(WINDOW_TITLE);
        window.open(display);
        window.requestFocus();

        if (System.in.available() > 0) {
            XMLSerializer xmlSerializer = new XMLSerializer();
            try {
                setDocument(xmlSerializer.readObject(System.in));
            } catch (Exception exception) {
                // No-op
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.pivot.xml.XMLSerializer

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.