Rev 490 | Blame | Compare with Previous | Last modification | View Log | RSS feed
package in.shop2020.support.controllers.handler;import java.io.Reader;import java.io.Writer;import org.apache.struts2.rest.handler.ContentTypeHandler;import com.thoughtworks.xstream.*;import java.io.*;public class SxstreamContentHandler implements ContentTypeHandler {@Overridepublic String fromObject(Object obj, String resultCode, Writer stream)throws IOException {if (obj != null) {XStream x = new XStream();//x.processAnnotations(obj.getClass());x.toXML(obj, stream);}return null;}@Overridepublic String getContentType() {// TODO Auto-generated method stubreturn "text/xml";}@Overridepublic String getExtension() {// TODO Auto-generated method stubreturn "xml";}@Overridepublic void toObject(Reader in, Object target) throws IOException {// TODO Auto-generated method stubXStream x = new XStream();//x.processAnnotations(target.getClass());x.fromXML(in, target);}}