Subversion Repositories SmartDukaan

Rev

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 {

        @Override
        public 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;
        }

        @Override
        public String getContentType() {
                // TODO Auto-generated method stub
                return "text/xml";
        }

        @Override
        public String getExtension() {
                // TODO Auto-generated method stub
                return "xml";

        }

        @Override
        public void toObject(Reader in, Object target) throws IOException {
                // TODO Auto-generated method stub
                XStream x = new XStream();
                
              //x.processAnnotations(target.getClass());
              x.fromXML(in, target);

                
        }

}