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.OleSRUExplainConfigDefaultTagField;
9   import org.kuali.ole.bo.explain.OleSRUExplainConfigSettingTagField;
10  
11  /**
12   * Created with IntelliJ IDEA.
13   * User: ?
14   * Date: 7/19/12
15   * Time: 7:02 PM
16   * To change this template use File | Settings | File Templates.
17   */
18  public class OleSRUExplainConfigInfoSettingConverter implements Converter {
19  
20      @Override
21      public void marshal(Object o, HierarchicalStreamWriter hierarchicalStreamWriter,
22                          MarshallingContext marshallingContext) {
23          OleSRUExplainConfigSettingTagField oleSRUExplainConfigSettingTagField = (OleSRUExplainConfigSettingTagField) o;
24          hierarchicalStreamWriter.addAttribute("type", oleSRUExplainConfigSettingTagField.getType());
25          hierarchicalStreamWriter.setValue("" + oleSRUExplainConfigSettingTagField.getValue());
26      }
27  
28      @Override
29      public Object unmarshal(HierarchicalStreamReader hierarchicalStreamReader,
30                              UnmarshallingContext unmarshallingContext) {
31          OleSRUExplainConfigSettingTagField oleSRUExplainConfigSettingTagField = new OleSRUExplainConfigSettingTagField();
32          oleSRUExplainConfigSettingTagField.setType(hierarchicalStreamReader.getAttribute("type"));
33          oleSRUExplainConfigSettingTagField.setValue(Integer.parseInt(hierarchicalStreamReader.getValue()));
34          return oleSRUExplainConfigSettingTagField;
35      }
36  
37      @Override
38      public boolean canConvert(Class aClass) {
39          return aClass.equals(OleSRUExplainConfigSettingTagField.class);
40      }
41  }