001    package org.kuali.ole.handler;
002    
003    import com.thoughtworks.xstream.XStream;
004    import org.kuali.ole.bo.diagnostics.OleSRUDiagnostic;
005    
006    /**
007     * Created with IntelliJ IDEA.
008     * User: ?
009     * Date: 7/16/12
010     * Time: 7:06 PM
011     * To change this template use File | Settings | File Templates.
012     */
013    public class OleSRUDiagnosticsHandler {
014    
015        /**
016         * this method is used to convert OleSRUDiagnostic object to an XML
017         * @param oleSRUDiagnostic object
018         * @return  xml as a string
019         */
020        public String toXML(OleSRUDiagnostic oleSRUDiagnostic) {
021            StringBuffer stringBuffer = new StringBuffer();
022            stringBuffer.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<diagnostics>" );
023            stringBuffer.append("\n");
024            XStream xStream = new XStream();
025            xStream.alias("diagnostic", OleSRUDiagnostic.class);
026            String xml = xStream.toXML(oleSRUDiagnostic);
027            xml = xml.replaceAll("<diagnostic>","<diagnostic xmlns=\"http://www.loc.gov/zing/srw/diagnostic/\">");
028            xml+="\n</diagnostics>";
029            stringBuffer.append(xml);
030            return stringBuffer.toString();
031        }
032    }