Package com.thoughtworks.xstream.io.xml

Examples of com.thoughtworks.xstream.io.xml.PrettyPrintWriter


    private String convertJson(String entityText) throws IOException {
        HierarchicalStreamDriver driver = new JettisonMappedXmlDriver();
        StringReader reader = new StringReader(entityText);
        HierarchicalStreamReader hsr = driver.createReader(reader);
        StringWriter writer = new StringWriter();
        new HierarchicalStreamCopier().copy(hsr, new PrettyPrintWriter(
                writer));
        writer.close();
        return writer.toString();
    }
View Full Code Here


    public XStreamDom4J() {
        super(new Dom4JDriver() {

            public HierarchicalStreamWriter createWriter(Writer out) {
                return new PrettyPrintWriter(out);
            }
           
        }, "XML with DOM4J parser");
    }
View Full Code Here

        final Software[] software = new Software[]{
            new Software("Microsoft", "Windows"),
            new OpenSourceSoftware("Codehaus", "XStream", "BSD")};
        final StringWriter writer = new StringWriter();
        final PrettyPrintWriter prettyPrintWriter = new PrettyPrintWriter(writer);
        new TreeMarshaller(prettyPrintWriter, converterLookup, mapper).start(software, null);
        prettyPrintWriter.flush();
        assertEquals(""
            + "<software-array>\n"
            + "  <software vendor=\"Microsoft\">Windows</software>\n"
            + "  <open-source vendor=\"Codehaus\" name=\"XStream\">BSD</open-source>\n"
            + "</software-array>", writer.toString());
View Full Code Here

    private double largestMetricForTarget;
    private List resultsForTarget;

    public HtmlReporter(File htmlFile, String title) throws IOException {
        this.title = title;
        out = new PrettyPrintWriter(new FileWriter(htmlFile));
    }
View Full Code Here

    public void testReadAndWriteMultipleObjectsInOneStream() {
        xstream.alias("person", Person.class);
        StringWriter buffer = new StringWriter();

        // serialize
        HierarchicalStreamWriter writer = new PrettyPrintWriter(buffer);
        writer.startNode("people");
        xstream.marshal(new Person("Postman", "Pat"), writer);
        xstream.marshal(new Person("Bob", "Builder"), writer);
        xstream.marshal(new Person("Tinky", "Winky"), writer);
        writer.endNode();

        assertEquals(""
            + "<people>\n"
            + "  <person>\n"
            + "    <firstName>Postman</firstName>\n"
View Full Code Here

        StringWriter writer = new StringWriter();
        DataHolder dataHolder = xstream.newDataHolder();

        // execute
        dataHolder.put("prefix", "additional stuff");
        xstream.marshal("something", new PrettyPrintWriter(writer), dataHolder);

        // verify
        String expected = "<string prefix=\"additional stuff\">something</string>";
        assertEquals(expected, writer.toString());
    }
View Full Code Here

     * @see #createObjectOutputStream(com.thoughtworks.xstream.io.HierarchicalStreamWriter, String)
     * @see #createObjectInputStream(com.thoughtworks.xstream.io.HierarchicalStreamReader)
     * @since 1.0.3
     */
    public ObjectOutputStream createObjectOutputStream(Writer writer) throws IOException {
        return createObjectOutputStream(new PrettyPrintWriter(writer), "object-stream");
    }
View Full Code Here

     * @see #createObjectInputStream(com.thoughtworks.xstream.io.HierarchicalStreamReader)
     * @since 1.0.3
     */
    public ObjectOutputStream createObjectOutputStream(Writer writer, String rootNodeName)
            throws IOException {
        return createObjectOutputStream(new PrettyPrintWriter(writer), rootNodeName);
    }
View Full Code Here

     * encoding
     */
    protected String marshall(Session session, ObjectMessage objectMessage) throws JMSException {
        Serializable object = objectMessage.getObject();
        StringWriter buffer = new StringWriter();
        HierarchicalStreamWriter out = new PrettyPrintWriter(buffer);
        getXStream().marshal(object, out);
        return buffer.toString();
    }
View Full Code Here

        StringWriter buffer = new StringWriter();
        HierarchicalStreamWriter out;
        if (transformation.toLowerCase(Locale.ENGLISH).endsWith("json")) {
            out = new JettisonMappedXmlDriver(new Configuration(), false).createWriter(buffer);
        } else {
            out = new PrettyPrintWriter(buffer);
        }
        getXStream().marshal(object, out);
        return buffer.toString();
    }
View Full Code Here

TOP

Related Classes of com.thoughtworks.xstream.io.xml.PrettyPrintWriter

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.