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