Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
StringToKimEntityNamePrincipalInfoMapAdapter |
|
| 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 java.util.HashMap; | |
19 | import java.util.Map; | |
20 | ||
21 | import javax.xml.bind.annotation.adapters.XmlAdapter; | |
22 | ||
23 | import org.kuali.rice.kim.bo.entity.dto.KimEntityNamePrincipalNameInfo; | |
24 | ||
25 | /** | |
26 | * Do jax-ws mapping of Map<String, String> for KIM service method parameters, etc. | |
27 | * | |
28 | * @author Kuali Rice Team (rice.collab@kuali.org) | |
29 | * | |
30 | */ | |
31 | 0 | public class StringToKimEntityNamePrincipalInfoMapAdapter extends XmlAdapter<StringEntNmPrncpInfoMapEntry[], Map<String, KimEntityNamePrincipalNameInfo>> { |
32 | ||
33 | /** | |
34 | * This overridden method ... | |
35 | * | |
36 | * @see javax.xml.bind.annotation.adapters.XmlAdapter#marshal(java.lang.Object) | |
37 | */ | |
38 | @Override | |
39 | public StringEntNmPrncpInfoMapEntry[] marshal(Map<String, KimEntityNamePrincipalNameInfo> map) throws Exception { | |
40 | 0 | if(null == map) return null; |
41 | 0 | StringEntNmPrncpInfoMapEntry[] entryArray = new StringEntNmPrncpInfoMapEntry[map.size()]; |
42 | 0 | int i = 0; |
43 | 0 | for (Map.Entry<String, KimEntityNamePrincipalNameInfo> e : map.entrySet()) { |
44 | 0 | entryArray[i] = new StringEntNmPrncpInfoMapEntry(e.getKey(), e.getValue()); |
45 | 0 | i++; |
46 | } | |
47 | 0 | return entryArray; |
48 | } | |
49 | ||
50 | /** | |
51 | * This overridden method ... | |
52 | * | |
53 | * @see javax.xml.bind.annotation.adapters.XmlAdapter#unmarshal(java.lang.Object) | |
54 | */ | |
55 | @Override | |
56 | public Map<String, KimEntityNamePrincipalNameInfo> unmarshal(StringEntNmPrncpInfoMapEntry[] entryArray) throws Exception { | |
57 | 0 | if (null == entryArray) return null; |
58 | 0 | Map<String, KimEntityNamePrincipalNameInfo> resultMap = new HashMap<String, KimEntityNamePrincipalNameInfo>(entryArray.length); |
59 | 0 | for (int i = 0; i < entryArray.length; i++) { |
60 | 0 | StringEntNmPrncpInfoMapEntry entry = entryArray[i]; |
61 | 0 | resultMap.put(entry.key, entry.value); |
62 | } | |
63 | 0 | return resultMap; |
64 | } | |
65 | } |