View Javadoc

1   package org.kuali.ole.converters;
2   
3   import com.thoughtworks.xstream.converters.Converter;
4   import com.thoughtworks.xstream.converters.MarshallingContext;
5   import com.thoughtworks.xstream.converters.UnmarshallingContext;
6   import com.thoughtworks.xstream.io.HierarchicalStreamReader;
7   import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
8   import org.kuali.ole.bo.explain.OleSRUExplainDatabaseTitle;
9   
10  /**
11   * Created with IntelliJ IDEA.
12   * User: ?
13   * Date: 7/19/12
14   * Time: 7:02 PM
15   * To change this template use File | Settings | File Templates.
16   */
17  public class OleSRUExplainDatabaseInfoConverter implements Converter {
18  
19  
20  
21  
22      @Override
23      public void marshal(Object o, HierarchicalStreamWriter hierarchicalStreamWriter,
24                          MarshallingContext marshallingContext) {
25          OleSRUExplainDatabaseTitle oleSRUExplainDatabaseTitle = (OleSRUExplainDatabaseTitle) o;
26          hierarchicalStreamWriter.addAttribute("lang", oleSRUExplainDatabaseTitle.getLang());
27          hierarchicalStreamWriter.addAttribute("primary", oleSRUExplainDatabaseTitle.getPrimary());
28          hierarchicalStreamWriter.setValue(oleSRUExplainDatabaseTitle.getValue());
29      }
30  
31      @Override
32      public Object unmarshal(HierarchicalStreamReader hierarchicalStreamReader,
33                              UnmarshallingContext unmarshallingContext) {
34          // System.out.println("datafield unmarshal");
35          OleSRUExplainDatabaseTitle oleSRUExplainDatabaseTitle = new OleSRUExplainDatabaseTitle();
36          oleSRUExplainDatabaseTitle.setLang(hierarchicalStreamReader.getAttribute("lang"));
37          oleSRUExplainDatabaseTitle.setPrimary(hierarchicalStreamReader.getAttribute("primary"));
38          oleSRUExplainDatabaseTitle.setValue(hierarchicalStreamReader.getValue());
39          return oleSRUExplainDatabaseTitle;
40      }
41  
42      @Override
43      public boolean canConvert(Class aClass) {
44          return aClass.equals(OleSRUExplainDatabaseTitle.class);
45      }
46  }