View Javadoc
1   package org.kuali.ole.handler;
2   
3   import com.thoughtworks.xstream.XStream;
4   import org.kuali.ole.bo.diagnostics.OleSRUDiagnostic;
5   
6   /**
7    * Created with IntelliJ IDEA.
8    * User: ?
9    * Date: 7/16/12
10   * Time: 7:06 PM
11   * To change this template use File | Settings | File Templates.
12   */
13  public class OleSRUDiagnosticsHandler {
14  
15      /**
16       * this method is used to convert OleSRUDiagnostic object to an XML
17       *
18       * @param oleSRUDiagnostic object
19       * @return xml as a string
20       */
21      public String toXML(OleSRUDiagnostic oleSRUDiagnostic) {
22          StringBuffer stringBuffer = new StringBuffer();
23          stringBuffer.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<diagnostics>");
24          stringBuffer.append("\n");
25          XStream xStream = new XStream();
26          xStream.alias("diagnostic", OleSRUDiagnostic.class);
27          String xml = xStream.toXML(oleSRUDiagnostic);
28          xml = xml.replaceAll("<diagnostic>", "<diagnostic xmlns=\"http://www.loc.gov/zing/srw/diagnostic/\">");
29          xml += "\n</diagnostics>";
30          stringBuffer.append(xml);
31          return stringBuffer.toString();
32      }
33  }