Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
StringToKimEntityNameInfoMapAdapter |
|
| 4.0;4 |
1 | /* | |
2 | * Copyright 2007-2010 The Kuali Foundation | |
3 | * | |
4 | * Licensed under the Educational Community License, Version 2.0 (the "License"); | |
5 | * you may not use this file except in compliance with the License. | |
6 | * You may obtain a copy of the License at | |
7 | * | |
8 | * http://www.opensource.org/licenses/ecl2.php | |
9 | * | |
10 | * Unless required by applicable law or agreed to in writing, software | |
11 | * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | * See the License for the specific language governing permissions and | |
14 | * limitations under the License. | |
15 | */ | |
16 | package org.kuali.rice.kim.api.jaxb; | |
17 | ||
18 | import org.kuali.rice.kim.api.identity.name.EntityName; | |
19 | ||
20 | import javax.xml.bind.annotation.adapters.XmlAdapter; | |
21 | import java.util.HashMap; | |
22 | import java.util.Map; | |
23 | ||
24 | /** | |
25 | * Do jax-ws mapping of Map<String, String> for KIM service method parameters, etc. | |
26 | * | |
27 | * @author Kuali Rice Team (rice.collab@kuali.org) | |
28 | * | |
29 | */ | |
30 | 0 | public class StringToKimEntityNameInfoMapAdapter extends XmlAdapter<StringEntityNameInfoMapEntry[], Map<String, EntityName>> { |
31 | ||
32 | /** | |
33 | * This overridden method ... | |
34 | * | |
35 | * @see javax.xml.bind.annotation.adapters.XmlAdapter#marshal(java.lang.Object) | |
36 | */ | |
37 | @Override | |
38 | public StringEntityNameInfoMapEntry[] marshal(Map<String, EntityName> map) throws Exception { | |
39 | 0 | if(null == map) return null; |
40 | 0 | StringEntityNameInfoMapEntry[] entryArray = new StringEntityNameInfoMapEntry[map.size()]; |
41 | 0 | int i = 0; |
42 | 0 | for (Map.Entry<String, EntityName> e : map.entrySet()) { |
43 | 0 | entryArray[i] = new StringEntityNameInfoMapEntry(e.getKey(), e.getValue()); |
44 | 0 | i++; |
45 | } | |
46 | 0 | return entryArray; |
47 | } | |
48 | ||
49 | /** | |
50 | * This overridden method ... | |
51 | * | |
52 | * @see javax.xml.bind.annotation.adapters.XmlAdapter#unmarshal(java.lang.Object) | |
53 | */ | |
54 | @Override | |
55 | public Map<String, EntityName> unmarshal(StringEntityNameInfoMapEntry[] entryArray) throws Exception { | |
56 | 0 | if (null == entryArray) return null; |
57 | 0 | Map<String, EntityName> resultMap = new HashMap<String, EntityName>(entryArray.length); |
58 | 0 | for (int i = 0; i < entryArray.length; i++) { |
59 | 0 | StringEntityNameInfoMapEntry entry = entryArray[i]; |
60 | 0 | resultMap.put(entry.key, entry.value); |
61 | } | |
62 | 0 | return resultMap; |
63 | } | |
64 | } |