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.OleSRUExplainIndexMapName;
009
010/**
011 * Created with IntelliJ IDEA.
012 * User: ?
013 * Date: 7/19/12
014 * Time: 7:02 PM
015 * To change this template use File | Settings | File Templates.
016 */
017public class OleSRUExplainIndexMapNameConverter implements Converter {
018
019    @Override
020    public void marshal(Object o, HierarchicalStreamWriter hierarchicalStreamWriter,
021                        MarshallingContext marshallingContext) {
022        OleSRUExplainIndexMapName oleSRUExplainIndexMapName = (OleSRUExplainIndexMapName) o;
023        hierarchicalStreamWriter.addAttribute("set", oleSRUExplainIndexMapName.getSet());
024        hierarchicalStreamWriter.setValue(oleSRUExplainIndexMapName.getValue());
025    }
026
027    @Override
028    public Object unmarshal(HierarchicalStreamReader hierarchicalStreamReader,
029                            UnmarshallingContext unmarshallingContext) {
030        OleSRUExplainIndexMapName oleSRUExplainIndexMapName = new OleSRUExplainIndexMapName();
031        oleSRUExplainIndexMapName.setSet(hierarchicalStreamReader.getAttribute("set"));
032        oleSRUExplainIndexMapName.setValue(hierarchicalStreamReader.getValue());
033        return oleSRUExplainIndexMapName;
034    }
035
036    @Override
037    public boolean canConvert(Class aClass) {
038        return aClass.equals(OleSRUExplainIndexMapName.class);
039    }
040}