Coverage Report - org.kuali.rice.kew.api.doctype.DocumentTypePolicyMapAdapter
 
Classes in this File Line Coverage Branch Coverage Complexity
DocumentTypePolicyMapAdapter
0%
0/14
0%
0/10
3.5
 
 1  
 /*
 2  
  * Copyright 2007-2009 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.kew.api.doctype;
 17  
 
 18  
 import java.util.ArrayList;
 19  
 import java.util.HashMap;
 20  
 import java.util.List;
 21  
 import java.util.Map;
 22  
 
 23  
 import javax.xml.bind.annotation.adapters.XmlAdapter;
 24  
 
 25  
 import org.kuali.rice.core.util.jaxb.StringMapEntry;
 26  
 import org.kuali.rice.core.util.jaxb.StringMapEntryList;
 27  
 
 28  
 /**
 29  
  * TODO...
 30  
  * 
 31  
  * @author Kuali Rice Team (kuali-rice@googlegroups.com)
 32  
  *
 33  
  */
 34  0
 class DocumentTypePolicyMapAdapter extends XmlAdapter<StringMapEntryList, Map<DocumentTypePolicy, String>> {
 35  
 
 36  
         @Override
 37  
         public StringMapEntryList marshal(Map<DocumentTypePolicy, String> map) {
 38  0
             List<StringMapEntry> entries = new ArrayList<StringMapEntry>();
 39  0
             if (map != null) {
 40  0
                 for (DocumentTypePolicy policy : map.keySet()) {
 41  0
                     entries.add(new StringMapEntry(policy.getCode(), map.get(policy)));
 42  
                 }
 43  
             }
 44  0
             return new StringMapEntryList(entries);
 45  
         }
 46  
 
 47  
         @Override
 48  
         public Map<DocumentTypePolicy, String> unmarshal(StringMapEntryList entryList) {
 49  0
             Map<DocumentTypePolicy, String> policies = new HashMap<DocumentTypePolicy, String>();
 50  0
             if (entryList != null) {
 51  0
                 for (StringMapEntry entry : entryList.getEntries()) {
 52  0
                     DocumentTypePolicy policy = DocumentTypePolicy.fromCode(entry.getKey());
 53  
                     // if the policy value comes back as null, that means we recieved a policy that we
 54  
                     // don't understand...ignore it
 55  0
                     if (policy != null) {
 56  0
                         policies.put(policy, entry.getValue());
 57  
                     }
 58  0
                 }
 59  
             }
 60  0
             return policies;
 61  
         }
 62  
         
 63  
 }