package com.library.util.currency;

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

import java.io.Writer;


public class XMLUtils {
	
	
	/**
	 * 
	 * @Title: addCDATAToXML
	 * @Description: 在参数值左右加上 “ <![CDATA[” “]]>”
	 * @param str
	 * @return
	 * @returnType: XStream
	 * @author: lin
	 * @date: May 12, 2017 8:38:52 PM
	 */
//	public static XStream addCDATAToXML(){
//		XStream xStream = new XStream(new XppDriver(new NoNameCoder()) {
//			@Override
//            public HierarchicalStreamWriter createWriter(Writer out) {
//                return new PrettyPrintWriter(out) {
//                    // 对所有xml节点的转换都增加CDATA标记
//                    boolean cdata = true;
//                    @Override
//                    @SuppressWarnings("rawtypes")
//                    public void startNode(String name, Class clazz) {
//                        super.startNode(name, clazz);
//                    }
//                    @Override
//                    public String encodeNode(String name) {
//                        return name;
//                    }
//                    @Override
//                    protected void writeText(QuickWriter writer, String text) {
//                        if (cdata) {
//                            writer.write("<![CDATA[");
//                            writer.write(text);
//                            writer.write("]]>");
//                        } else {
//                            writer.write(text);
//                        }
//                    }
//                };
//            }
//		});
//		return xStream;
//	}
	
}
