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
24
25
26
27
28
29 public class JaxbStringMapAdapter extends XmlAdapter<StringMapEntryList, Map<String, String>> {
30
31
32
33
34
35
36 @Override
37 public StringMapEntryList marshal(Map<String, String> map) throws Exception {
38 if(null == map) return null;
39 StringMapEntryList entryList = new StringMapEntryList();
40 for (Map.Entry<String, String> e : map.entrySet()) {
41 entryList.getEntries().add(
42 new StringMapEntry(e.getKey(), e.getValue()));
43 }
44 return entryList;
45 }
46
47
48
49
50
51
52 @Override
53 public Map<String, String> unmarshal(StringMapEntryList entryList) throws Exception {
54 if (null == entryList) return null;
55 Map<String, String> resultMap = new HashMap<String, String>();
56 for (StringMapEntry entry : entryList.getEntries()) {
57 resultMap.put(entry.key, entry.value);
58 }
59 return resultMap;
60 }
61 }