Package org.apache.pivot.xml

Examples of org.apache.pivot.xml.XMLSerializer$XMLSerializerListenerList


        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 static org.junit.Assert.assertTrue;

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"));

        xmlSerializer.getXMLSerializerListeners().remove(xmlSerializerListener);
        Element root2 = xmlSerializer.readObject(getClass().getResourceAsStream("sample.xml"));

        assertTrue(root1.equals(root2));

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

                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

                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

        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 static org.junit.Assert.assertTrue;

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

TOP

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

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.