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.OleSRUExplainIndexSet;
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 OleSRUExplainIndexInfoConverter implements Converter {
18  
19  
20      @Override
21      public void marshal(Object o, HierarchicalStreamWriter hierarchicalStreamWriter,
22                          MarshallingContext marshallingContext) {
23          OleSRUExplainIndexSet oleSRUExplainIndexSet = (OleSRUExplainIndexSet) o;
24          hierarchicalStreamWriter.addAttribute("name", oleSRUExplainIndexSet.getName());
25          hierarchicalStreamWriter.addAttribute("identifier", oleSRUExplainIndexSet.getIdentifier());
26          hierarchicalStreamWriter.setValue(oleSRUExplainIndexSet.getValue());
27      }
28  
29      @Override
30      public Object unmarshal(HierarchicalStreamReader hierarchicalStreamReader,
31                              UnmarshallingContext unmarshallingContext) {
32          OleSRUExplainIndexSet oleSRUExplainIndexSet = new OleSRUExplainIndexSet();
33          oleSRUExplainIndexSet.setName(hierarchicalStreamReader.getAttribute("name"));
34          oleSRUExplainIndexSet.setIdentifier(hierarchicalStreamReader.getAttribute("identifier"));
35          oleSRUExplainIndexSet.setValue(hierarchicalStreamReader.getValue());
36          return oleSRUExplainIndexSet;
37      }
38  
39      @Override
40      public boolean canConvert(Class aClass) {
41          return aClass.equals(OleSRUExplainIndexSet.class);
42      }
43  }