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.principal.EntityNamePrincipalName;
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 StringToKimEntityNamePrincipalInfoMapAdapter extends XmlAdapter<StringEntNmPrncpInfoMapEntry[], Map<String, EntityNamePrincipalName>> {
31
32
33
34
35
36
37 @Override
38 public StringEntNmPrncpInfoMapEntry[] marshal(Map<String, EntityNamePrincipalName> map) throws Exception {
39 if(null == map) return null;
40 StringEntNmPrncpInfoMapEntry[] entryArray = new StringEntNmPrncpInfoMapEntry[map.size()];
41 int i = 0;
42 for (Map.Entry<String, EntityNamePrincipalName> e : map.entrySet()) {
43 entryArray[i] = new StringEntNmPrncpInfoMapEntry(e.getKey(), e.getValue());
44 i++;
45 }
46 return entryArray;
47 }
48
49
50
51
52
53
54 @Override
55 public Map<String, EntityNamePrincipalName> unmarshal(StringEntNmPrncpInfoMapEntry[] entryArray) throws Exception {
56 if (null == entryArray) return null;
57 Map<String, EntityNamePrincipalName> resultMap = new HashMap<String, EntityNamePrincipalName>(entryArray.length);
58 for (int i = 0; i < entryArray.length; i++) {
59 StringEntNmPrncpInfoMapEntry entry = entryArray[i];
60 resultMap.put(entry.getKey(), entry.getValue());
61 }
62 return resultMap;
63 }
64 }