Coverage Report - org.kuali.rice.core.jaxb.AttributeSetAdapter
 
Classes in this File Line Coverage Branch Coverage Complexity
AttributeSetAdapter
0%
0/14
0%
0/8
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.core.jaxb;
 17  
 
 18  
 import java.util.Map;
 19  
 
 20  
 import javax.xml.bind.annotation.adapters.XmlAdapter;
 21  
 
 22  
 import org.kuali.rice.core.xml.dto.AttributeSet;
 23  
 
 24  
 /**
 25  
  * This class allows for a {@link org.kuali.rice.core.xml.dto.AttributeSet} instance to be passed across the wire by jaxws enabled services
 26  
  * 
 27  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 28  
  *
 29  
  */
 30  0
 public class AttributeSetAdapter extends XmlAdapter<StringMapEntry[], AttributeSet> {
 31  
 
 32  
         /**
 33  
          * @see org.kuali.rice.core.jaxb.MapStringStringAdapter#marshal(java.lang.Object)
 34  
          */
 35  
         @Override
 36  
         public StringMapEntry[] marshal(AttributeSet attributeSet) throws Exception {
 37  0
                 if(null == attributeSet) return null;
 38  0
                 StringMapEntry[] entryArray = new StringMapEntry[attributeSet.size()];
 39  0
                 int i = 0;
 40  0
                 for (Map.Entry<String, String> e : attributeSet.entrySet()) {
 41  0
                         entryArray[i] = new StringMapEntry(e);
 42  0
                         i++;
 43  
                 }
 44  0
                 return entryArray;
 45  
         }
 46  
 
 47  
         /**
 48  
          * @see org.kuali.rice.core.jaxb.MapStringStringAdapter#unmarshal(java.util.ArrayList)
 49  
          */
 50  
         @Override
 51  
         public AttributeSet unmarshal(StringMapEntry[] entryArray) throws Exception {
 52  0
                 if (null == entryArray) return null;
 53  0
                 AttributeSet resultMap = new AttributeSet(entryArray.length);
 54  0
                 for (int i = 0; i < entryArray.length; i++) {
 55  0
                         StringMapEntry stringMapEntry = entryArray[i];
 56  0
                         resultMap.put(stringMapEntry.getKey(), stringMapEntry.getValue());
 57  
                 }
 58  0
                 return resultMap;
 59  
         }
 60  
 
 61  
 }