001    package org.kuali.ole.converters;
002    
003    import com.thoughtworks.xstream.converters.Converter;
004    import com.thoughtworks.xstream.converters.MarshallingContext;
005    import com.thoughtworks.xstream.converters.UnmarshallingContext;
006    import com.thoughtworks.xstream.io.HierarchicalStreamReader;
007    import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
008    import org.kuali.ole.bo.explain.OleSRUExplainConfigDefaultTagField;
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     */
017    public class OleSRUExplainConfigInfoDefaultConverter implements Converter {
018    
019        @Override
020        public void marshal(Object o, HierarchicalStreamWriter hierarchicalStreamWriter,
021                            MarshallingContext marshallingContext) {
022            OleSRUExplainConfigDefaultTagField oleSRUExplainConfigDefaultTagField = (OleSRUExplainConfigDefaultTagField) o;
023            hierarchicalStreamWriter.addAttribute("type", oleSRUExplainConfigDefaultTagField.getType());
024            hierarchicalStreamWriter.setValue(""+oleSRUExplainConfigDefaultTagField.getValue());
025        }
026    
027        @Override
028        public Object unmarshal(HierarchicalStreamReader hierarchicalStreamReader,
029                                UnmarshallingContext unmarshallingContext) {
030            OleSRUExplainConfigDefaultTagField oleSRUExplainConfigDefaultTagField = new OleSRUExplainConfigDefaultTagField();
031            oleSRUExplainConfigDefaultTagField.setType(hierarchicalStreamReader.getAttribute("type"));
032            oleSRUExplainConfigDefaultTagField.setValue(Integer.parseInt(hierarchicalStreamReader.getValue()));
033            return oleSRUExplainConfigDefaultTagField;
034        }
035    
036        @Override
037        public boolean canConvert(Class aClass) {
038            return aClass.equals(OleSRUExplainConfigDefaultTagField.class);
039        }
040    }