001package org.kuali.ole.ingest;
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.ingest.pojo.OleAddressLine;
009
010/**
011 * OlePatronAddressLineConverter is a converter class used to convert object into data and data into object by using
012 * hierarchicalStreamWriter and hierarchicalStreamReader respectively
013 */
014public class OlePatronAddressLineConverter implements Converter {
015    /**
016     * This method convert the object into data by using hierarchicalStreamWriter.
017     * @param obj
018     * @param hierarchicalStreamWriter
019     * @param marshallingContext
020     */
021        @Override
022        public void marshal(Object obj, HierarchicalStreamWriter hierarchicalStreamWriter, MarshallingContext marshallingContext) {
023            OleAddressLine oleAddressLine = (OleAddressLine) obj;
024            hierarchicalStreamWriter.setValue(oleAddressLine.getAddressLine());
025        }
026
027    /**
028     *  This method convert the data into object by using hierarchicalStreamReader.
029     * @param hierarchicalStreamReader
030     * @param unmarshallingContext
031     * @return  oleAddressLine.
032     */
033        @Override
034        public Object unmarshal(HierarchicalStreamReader hierarchicalStreamReader, UnmarshallingContext unmarshallingContext) {
035            OleAddressLine oleAddressLine = new OleAddressLine();
036            oleAddressLine.setAddressLine(hierarchicalStreamReader.getValue());
037            return oleAddressLine;
038        }
039
040    /**
041     *  This method returns True/False.
042     *  This method check whether the class is OleAddressLine class or not.
043     * @param aClass
044     * @return  boolean
045     */
046        @Override
047        public boolean canConvert(Class aClass) {
048            return aClass.equals(OleAddressLine.class);
049        }
050}