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.OleSRUExplainConfigSupportTagField;
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 OleSRUExplainConfigInfoSupportConverter implements Converter {
19  
20      @Override
21      public void marshal(Object o, HierarchicalStreamWriter hierarchicalStreamWriter,
22                          MarshallingContext marshallingContext) {
23          OleSRUExplainConfigSupportTagField oleSRUExplainConfigSupportTagField = (OleSRUExplainConfigSupportTagField) o;
24          hierarchicalStreamWriter.addAttribute("type", oleSRUExplainConfigSupportTagField.getType());
25          hierarchicalStreamWriter.setValue(oleSRUExplainConfigSupportTagField.getValue());
26      }
27  
28      @Override
29      public Object unmarshal(HierarchicalStreamReader hierarchicalStreamReader,
30                              UnmarshallingContext unmarshallingContext) {
31          OleSRUExplainConfigSupportTagField oleSRUExplainConfigSupportTagField = new OleSRUExplainConfigSupportTagField();
32          oleSRUExplainConfigSupportTagField.setType(hierarchicalStreamReader.getAttribute("type"));
33          oleSRUExplainConfigSupportTagField.setValue(hierarchicalStreamReader.getValue());
34          return oleSRUExplainConfigSupportTagField;
35      }
36  
37      @Override
38      public boolean canConvert(Class aClass) {
39          return aClass.equals(OleSRUExplainConfigSupportTagField.class);
40      }
41  }