1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.docstore.model.xstream.ingest;
17
18 import com.thoughtworks.xstream.converters.Converter;
19 import com.thoughtworks.xstream.converters.MarshallingContext;
20 import com.thoughtworks.xstream.converters.UnmarshallingContext;
21 import com.thoughtworks.xstream.io.HierarchicalStreamReader;
22 import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
23 import org.kuali.ole.docstore.model.xmlpojo.ingest.LinkInfo;
24
25
26
27
28
29
30
31
32
33 public class LinkInfoConverter implements Converter {
34 @Override
35 public void marshal(Object o, HierarchicalStreamWriter hierarchicalStreamWriter, MarshallingContext marshallingContext) {
36 LinkInfo linkInfo = (LinkInfo) o;
37 hierarchicalStreamWriter.addAttribute("from", linkInfo.getFrom());
38 hierarchicalStreamWriter.addAttribute("to", linkInfo.getTo());
39 }
40
41 @Override
42 public Object unmarshal(HierarchicalStreamReader hierarchicalStreamReader, UnmarshallingContext unmarshallingContext) {
43 LinkInfo linkInfo = new LinkInfo();
44 linkInfo.setFrom(hierarchicalStreamReader.getAttribute("from"));
45 linkInfo.setTo(hierarchicalStreamReader.getAttribute("to"));
46 return linkInfo;
47 }
48
49 @Override
50 public boolean canConvert(Class aClass) {
51 return aClass.equals(LinkInfo.class);
52 }
53 }