View Javadoc

1   package org.kuali.ole.patron.merge.controller;
2   
3   import com.thoughtworks.xstream.XStream;
4   import org.kuali.ole.patron.merge.bo.OleConfigDocument;
5   import org.kuali.ole.patron.merge.bo.OlePatronConfig;
6   
7   import java.io.IOException;
8   import java.net.URISyntaxException;
9   
10  /**
11   * Created with IntelliJ IDEA.
12   * User: vivekb
13   * Date: 8/22/12
14   * Time: 3:04 PM
15   * To change this template use File | Settings | File Templates.
16   */
17  public class OlePatronConfigObjectGeneratorFromXML {
18      /**
19       *  This method returns PatronConfig object from fileContent.
20       *  The xStream will convert the fileContent into PatronConfig Object.
21       * @param fileContent
22       * @return PatronConfig object
23       * @throws java.net.URISyntaxException
24       * @throws java.io.IOException
25       */
26  
27      public OlePatronConfig buildKrmsFromFileContent(String fileContent) throws URISyntaxException, IOException {
28          XStream xStream = new XStream();
29          xStream.alias("patronConfig", OlePatronConfig.class);
30          xStream.alias("document", OleConfigDocument.class);
31          Object object = xStream.fromXML(fileContent);
32          return (OlePatronConfig) object;
33      }
34  }