1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kew.framework.actionlist;
17
18 import org.kuali.rice.core.api.mo.AbstractDataTransferObject;
19 import org.kuali.rice.kew.api.action.ActionItemCustomization;
20 import org.w3c.dom.Element;
21
22 import javax.xml.bind.annotation.XmlAnyElement;
23 import javax.xml.bind.annotation.XmlAttribute;
24 import javax.xml.bind.annotation.XmlElement;
25 import javax.xml.bind.annotation.adapters.XmlAdapter;
26 import java.util.Collection;
27 import java.util.HashMap;
28 import java.util.Map;
29
30
31
32
33
34
35
36 public class MapStringActionItemCustomizationAdapter extends XmlAdapter<MapStringActionItemCustomizationAdapter.StringActionItemCustomizationMapEntry[], Map<String, ActionItemCustomization>> {
37
38
39
40
41
42
43 @Override
44 public StringActionItemCustomizationMapEntry[] marshal(Map<String, ActionItemCustomization> map) throws Exception {
45 if(null == map) return null;
46 StringActionItemCustomizationMapEntry[] entryArray = new StringActionItemCustomizationMapEntry[map.size()];
47 int i = 0;
48 for (Map.Entry<String, ActionItemCustomization> e : map.entrySet()) {
49 entryArray[i] = new StringActionItemCustomizationMapEntry(e.getKey(), e.getValue());
50 i++;
51 }
52 return entryArray;
53 }
54
55
56
57
58
59
60 @Override
61 public Map<String, ActionItemCustomization> unmarshal(StringActionItemCustomizationMapEntry[] entryArray) throws Exception {
62 if (null == entryArray) return null;
63 Map<String, ActionItemCustomization> resultMap = new HashMap<String, ActionItemCustomization>(entryArray.length);
64 for (int i = 0; i < entryArray.length; i++) {
65 StringActionItemCustomizationMapEntry entry = entryArray[i];
66 resultMap.put(entry.getKey(), entry.getValue());
67 }
68 return resultMap;
69 }
70
71 public static class StringActionItemCustomizationMapEntry extends AbstractDataTransferObject {
72
73 private static final long serialVersionUID = 1L;
74
75 @XmlAttribute
76 private final String key;
77
78 @XmlElement(required=true)
79 private final ActionItemCustomization value;
80
81 @SuppressWarnings("unused")
82 @XmlAnyElement
83 private final Collection<Element> _futureElements = null;
84
85
86
87
88 public StringActionItemCustomizationMapEntry() {
89 key = null;
90 value = null;
91 }
92
93 public StringActionItemCustomizationMapEntry(String key, ActionItemCustomization value) {
94 super();
95
96 this.key = key;
97 this.value = value;
98 }
99
100 public String getKey() {
101 return key;
102 }
103
104 public ActionItemCustomization getValue() {
105 return value;
106 }
107 }
108 }