All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.javalite.async.CDATAXppDriver Maven / Gradle / Ivy

There is a newer version: 3.5-j11
Show newest version
package org.javalite.async;

import com.thoughtworks.xstream.core.util.QuickWriter;
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
import com.thoughtworks.xstream.io.xml.PrettyPrintWriter;
import com.thoughtworks.xstream.io.xml.XppDriver;

import java.io.Writer;

/**
 * @author Igor Polevoy on 1/31/16.
 */
class CDATAXppDriver extends XppDriver {

    @Override
    public HierarchicalStreamWriter createWriter(Writer out) {
        return new PrettyPrintWriter(out) {
            boolean cdata;
            @Override
            public void startNode(String name, Class clazz) {
                super.startNode(name, clazz);
                cdata = CharSequence.class.isAssignableFrom(clazz);
            }
            @Override
            protected void writeText(QuickWriter writer, String text) {
                if(cdata) {
                    writer.write("");
                } else {
                    writer.write(text);
                }
            }
        };
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy