| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| AdapterAttributeSetToHashMap | 
  | 
  | 1.6666666666666667;1.667 | 
| 1 |  /* | |
| 2 |   * Copyright 2007 Sun Microsystems, Inc. | |
| 3 |   * All rights reserved.  You may not modify, use, | |
| 4 |   * reproduce, or distribute this software except in | |
| 5 |   * compliance with  the terms of the License at: | |
| 6 |   * http://developer.sun.com/berkeley_license.html | |
| 7 |   */ | |
| 8 | ||
| 9 | ||
| 10 |  /* | |
| 11 |   * The contents of this file are subject to the terms | |
| 12 |   * of the Common Development and Distribution License | |
| 13 |   * (the "License").  You may not use this file except | |
| 14 |   * in compliance with the License. | |
| 15 |   * | |
| 16 |   * You can obtain a copy of the license at | |
| 17 |   * https://jwsdp.dev.java.net/CDDLv1.0.html | |
| 18 |   * See the License for the specific language governing | |
| 19 |   * permissions and limitations under the License. | |
| 20 |   * | |
| 21 |   * When distributing Covered Code, include this CDDL | |
| 22 |   * HEADER in each file and include the License file at | |
| 23 |   * https://jwsdp.dev.java.net/CDDLv1.0.html  If applicable, | |
| 24 |   * add the following below this CDDL HEADER, with the | |
| 25 |   * fields enclosed by brackets "[]" replaced with your | |
| 26 |   * own identifying information: Portions Copyright [yyyy] | |
| 27 |   * [name of copyright owner] | |
| 28 |   */ | |
| 29 |  package org.kuali.rice.core.jaxb; | |
| 30 | ||
| 31 |  import java.util.TreeMap; | |
| 32 |  import java.util.Iterator; | |
| 33 |  import javax.xml.bind.annotation.adapters.XmlAdapter; | |
| 34 | ||
| 35 |  import org.kuali.rice.core.xml.dto.AttributeEntry; | |
| 36 |  import org.kuali.rice.core.xml.dto.AttributeSet; | |
| 37 |  import org.kuali.rice.core.xml.dto.AttributeSetList; | |
| 38 | ||
| 39 | ||
| 40 |  /* | |
| 41 |   * | |
| 42 |   *  PurchaseList - ValueType | |
| 43 |   *  HashMap - BoundType | |
| 44 |   */ | |
| 45 | 0 |  public class AdapterAttributeSetToHashMap extends XmlAdapter<AttributeSetList, AttributeSet> { | 
| 46 | 0 |      public AdapterAttributeSetToHashMap() { | 
| 47 | 0 |      } | 
| 48 | ||
| 49 |      // Convert a value type to a bound type. | |
| 50 |      // read xml content and put into Java class. | |
| 51 |      public AttributeSet unmarshal(AttributeSetList v) { | |
| 52 | 0 |          int cnt = v.entry.size(); | 
| 53 | 0 |          AttributeSet aHashMap = new AttributeSet(cnt); | 
| 54 | ||
| 55 | 0 |          for (int i = 0; i < cnt; i++) { | 
| 56 | 0 |              AttributeEntry pe = v.entry.get(i); | 
| 57 | 0 |              aHashMap.put(pe.key, pe.value); | 
| 58 | }  | |
| 59 | ||
| 60 | 0 |          return aHashMap; | 
| 61 | }  | |
| 62 | ||
| 63 |      // Convert a bound type to a value type. | |
| 64 |      // write Java content into class that generates desired XML  | |
| 65 |      public AttributeSetList marshal(AttributeSet v) { | |
| 66 | 0 |          AttributeSetList pList = new AttributeSetList(); | 
| 67 | ||
| 68 |          // For QA consistency order the output.  | |
| 69 | 0 |          TreeMap<String, String> tMap = new TreeMap<String, String>(v); | 
| 70 | ||
| 71 | 0 |          Iterator it = tMap.keySet().iterator(); | 
| 72 | 0 |          while (it.hasNext()){ | 
| 73 | 0 |                  String key = (String) it.next(); | 
| 74 | 0 |              pList.entry.add( | 
| 75 |                      new AttributeEntry( | |
| 76 | key,  | |
| 77 | tMap.get(key)));  | |
| 78 | 0 |          } | 
| 79 | 0 |          return pList; | 
| 80 | }  | |
| 81 | }  |