001package org.kuali.ole.converters;
002
003import com.thoughtworks.xstream.converters.Converter;
004import com.thoughtworks.xstream.converters.MarshallingContext;
005import com.thoughtworks.xstream.converters.UnmarshallingContext;
006import com.thoughtworks.xstream.io.HierarchicalStreamReader;
007import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
008import org.kuali.ole.bo.explain.OleSRUExplainConfigDefaultTagField;
009import org.kuali.ole.bo.explain.OleSRUExplainConfigSupportTagField;
010
011/**
012 * Created with IntelliJ IDEA.
013 * User: ?
014 * Date: 7/19/12
015 * Time: 7:02 PM
016 * To change this template use File | Settings | File Templates.
017 */
018public class OleSRUExplainConfigInfoSupportConverter implements Converter {
019
020    @Override
021    public void marshal(Object o, HierarchicalStreamWriter hierarchicalStreamWriter,
022                        MarshallingContext marshallingContext) {
023        OleSRUExplainConfigSupportTagField oleSRUExplainConfigSupportTagField = (OleSRUExplainConfigSupportTagField) o;
024        hierarchicalStreamWriter.addAttribute("type", oleSRUExplainConfigSupportTagField.getType());
025        hierarchicalStreamWriter.setValue(oleSRUExplainConfigSupportTagField.getValue());
026    }
027
028    @Override
029    public Object unmarshal(HierarchicalStreamReader hierarchicalStreamReader,
030                            UnmarshallingContext unmarshallingContext) {
031        OleSRUExplainConfigSupportTagField oleSRUExplainConfigSupportTagField = new OleSRUExplainConfigSupportTagField();
032        oleSRUExplainConfigSupportTagField.setType(hierarchicalStreamReader.getAttribute("type"));
033        oleSRUExplainConfigSupportTagField.setValue(hierarchicalStreamReader.getValue());
034        return oleSRUExplainConfigSupportTagField;
035    }
036
037    @Override
038    public boolean canConvert(Class aClass) {
039        return aClass.equals(OleSRUExplainConfigSupportTagField.class);
040    }
041}