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.Map;
19
20 import javax.xml.bind.annotation.adapters.XmlAdapter;
21
22 import org.kuali.rice.kim.bo.types.dto.AttributeSet;
23
24
25
26
27
28
29
30 public class AttributeSetAdapter extends XmlAdapter<StringMapEntry[], AttributeSet> {
31
32
33
34
35 @Override
36 public StringMapEntry[] marshal(AttributeSet attributeSet) throws Exception {
37 if(null == attributeSet) return null;
38 StringMapEntry[] entryArray = new StringMapEntry[attributeSet.size()];
39 int i = 0;
40 for (Map.Entry<String, String> e : attributeSet.entrySet()) {
41 entryArray[i] = new StringMapEntry(e);
42 i++;
43 }
44 return entryArray;
45 }
46
47
48
49
50 @Override
51 public AttributeSet unmarshal(StringMapEntry[] entryArray) throws Exception {
52 if (null == entryArray) return null;
53 AttributeSet resultMap = new AttributeSet(entryArray.length);
54 for (int i = 0; i < entryArray.length; i++) {
55 StringMapEntry stringMapEntry = entryArray[i];
56 resultMap.put(stringMapEntry.key, stringMapEntry.value);
57 }
58 return resultMap;
59 }
60
61 }