1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.core.jaxb;
17
18 import java.util.HashMap;
19 import java.util.Map;
20
21 import javax.xml.bind.annotation.adapters.XmlAdapter;
22
23 import org.kuali.rice.kim.bo.entity.dto.KimEntityNameInfo;
24
25
26
27
28
29
30
31 public class StringToKimEntityNameInfoMapAdapter extends XmlAdapter<StringEntityNameInfoMapEntry[], Map<String, KimEntityNameInfo>> {
32
33
34
35
36
37
38 @Override
39 public StringEntityNameInfoMapEntry[] marshal(Map<String, KimEntityNameInfo> map) throws Exception {
40 if(null == map) return null;
41 StringEntityNameInfoMapEntry[] entryArray = new StringEntityNameInfoMapEntry[map.size()];
42 int i = 0;
43 for (Map.Entry<String, KimEntityNameInfo> e : map.entrySet()) {
44 entryArray[i] = new StringEntityNameInfoMapEntry(e.getKey(), e.getValue());
45 i++;
46 }
47 return entryArray;
48 }
49
50
51
52
53
54
55 @Override
56 public Map<String, KimEntityNameInfo> unmarshal(StringEntityNameInfoMapEntry[] entryArray) throws Exception {
57 if (null == entryArray) return null;
58 Map<String, KimEntityNameInfo> resultMap = new HashMap<String, KimEntityNameInfo>(entryArray.length);
59 for (int i = 0; i < entryArray.length; i++) {
60 StringEntityNameInfoMapEntry entry = entryArray[i];
61 resultMap.put(entry.key, entry.value);
62 }
63 return resultMap;
64 }
65 }