Coverage Report - org.kuali.rice.kns.web.format.DelegationTypeFormatter
 
Classes in this File Line Coverage Branch Coverage Complexity
DelegationTypeFormatter
0%
0/9
0%
0/6
7
 
 1  
 /**
 2  
  * Copyright 2005-2011 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  
 // begin Kuali Foundation modification
 17  
 package org.kuali.rice.kns.web.format;
 18  
 // end Kuali Foundation modification
 19  
 
 20  
 import org.kuali.rice.core.api.delegation.DelegationType;
 21  
 import org.kuali.rice.core.web.format.Formatter;
 22  
 import org.kuali.rice.kew.api.KewApiConstants;
 23  
 
 24  
 /**
 25  
  * begin Kuali Foundation modification
 26  
  * This class is used to format boolean values.
 27  
  * end Kuali Foundation modification
 28  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 29  
  */
 30  0
 public class DelegationTypeFormatter extends Formatter {
 31  
     private static final long serialVersionUID = -4109390572922205211L;
 32  
         /*
 33  
     protected Object convertToObject(String target) {
 34  
         if (Formatter.isEmptyValue(target))
 35  
             return null;
 36  
 
 37  
         String stringValue = target.getClass().isArray() ? unwrapString(target) : (String) target;
 38  
         stringValue = stringValue.trim().toUpperCase();
 39  
 
 40  
         return KewApiConstants.DELEGATION_TYPES.get(stringValue);
 41  
         if (TRUE_VALUES.contains(stringValue))
 42  
             return Boolean.TRUE;
 43  
         if (FALSE_VALUES.contains(stringValue))
 44  
             return Boolean.FALSE;
 45  
 
 46  
                 // begin Kuali Foundation modification
 47  
                 // was: throw new FormatException(CONVERT_MSG + stringValue);
 48  
         throw new FormatException("converting", RiceKeyConstants.ERROR_BOOLEAN, stringValue);
 49  
         // end Kuali Foundation modification
 50  
     }
 51  
 */
 52  
     public Object format(Object target) {
 53  0
         if (target == null) {
 54  0
             return null;
 55  
         }
 56  
         // begin Kuali Foundation modification
 57  0
         if (target instanceof String) {
 58  0
                 DelegationType delegationType = DelegationType.fromCode(((String) target).trim().toUpperCase());
 59  0
                 if (delegationType != null) {
 60  0
                         return delegationType.getLabel();
 61  
                 } else {
 62  0
                         return KewApiConstants.DELEGATION_BOTH_LABEL;
 63  
                 }
 64  
         } else {
 65  0
             return "";
 66  
         }
 67  
     }
 68  
 }