View Javadoc
1   package org.kuali.ole.ingest;
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.ingest.pojo.OleAddressLine;
9   
10  /**
11   * OlePatronAddressLineConverter is a converter class used to convert object into data and data into object by using
12   * hierarchicalStreamWriter and hierarchicalStreamReader respectively
13   */
14  public class OlePatronAddressLineConverter implements Converter {
15      /**
16       * This method convert the object into data by using hierarchicalStreamWriter.
17       * @param obj
18       * @param hierarchicalStreamWriter
19       * @param marshallingContext
20       */
21          @Override
22          public void marshal(Object obj, HierarchicalStreamWriter hierarchicalStreamWriter, MarshallingContext marshallingContext) {
23              OleAddressLine oleAddressLine = (OleAddressLine) obj;
24              hierarchicalStreamWriter.setValue(oleAddressLine.getAddressLine());
25          }
26  
27      /**
28       *  This method convert the data into object by using hierarchicalStreamReader.
29       * @param hierarchicalStreamReader
30       * @param unmarshallingContext
31       * @return  oleAddressLine.
32       */
33          @Override
34          public Object unmarshal(HierarchicalStreamReader hierarchicalStreamReader, UnmarshallingContext unmarshallingContext) {
35              OleAddressLine oleAddressLine = new OleAddressLine();
36              oleAddressLine.setAddressLine(hierarchicalStreamReader.getValue());
37              return oleAddressLine;
38          }
39  
40      /**
41       *  This method returns True/False.
42       *  This method check whether the class is OleAddressLine class or not.
43       * @param aClass
44       * @return  boolean
45       */
46          @Override
47          public boolean canConvert(Class aClass) {
48              return aClass.equals(OleAddressLine.class);
49          }
50  }