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