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

com.gitee.easyopen.serializer.XmlResultSerializer Maven / Gradle / Ivy

package com.gitee.easyopen.serializer;

import com.gitee.easyopen.ApiResult;
import com.gitee.easyopen.ResultSerializer;
import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.naming.NoNameCoder;
import com.thoughtworks.xstream.io.xml.StaxDriver;

public class XmlResultSerializer implements ResultSerializer {

    private static XStream xStream = new XStream(new StaxDriver(new NoNameCoder()));
    static {
        xStream.processAnnotations(ApiResult.class);
        xStream.aliasSystemAttribute(null, "class");
    }

    @Override
    public String serialize(Object obj) {
        return getXStream().toXML(obj);
    }

    public XStream getXStream() {
        return xStream;
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy