| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| DelegationTypeFormatter |
|
| 5.0;5 |
| 1 | /* | |
| 2 | * Copyright 2004 Jonathan M. Lehr | |
| 3 | * | |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. | |
| 5 | * You may obtain a copy of the License at | |
| 6 | * | |
| 7 | * http://www.apache.org/licenses/LICENSE-2.0 | |
| 8 | * | |
| 9 | * Unless required by applicable law or agreed to in writing, software | |
| 10 | * distributed under the License is distributed on an "AS IS" BASIS, | |
| 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 12 | * See the License for the specific language governing permissions and | |
| 13 | * limitations under the License. | |
| 14 | * | |
| 15 | * MODIFIED BY THE KUALI FOUNDATION | |
| 16 | */ | |
| 17 | // begin Kuali Foundation modification | |
| 18 | package org.kuali.rice.kns.web.format; | |
| 19 | // end Kuali Foundation modification | |
| 20 | ||
| 21 | import java.util.Arrays; | |
| 22 | import java.util.List; | |
| 23 | ||
| 24 | import org.kuali.rice.core.util.RiceKeyConstants; | |
| 25 | import org.kuali.rice.core.web.format.Formatter; | |
| 26 | import org.kuali.rice.kew.util.KEWConstants; | |
| 27 | ||
| 28 | /** | |
| 29 | * begin Kuali Foundation modification | |
| 30 | * This class is used to format boolean values. | |
| 31 | * end Kuali Foundation modification | |
| 32 | * @author Kuali Rice Team (rice.collab@kuali.org) | |
| 33 | */ | |
| 34 | 0 | public class DelegationTypeFormatter extends Formatter { |
| 35 | private static final long serialVersionUID = -4109390572922205211L; | |
| 36 | /* | |
| 37 | protected Object convertToObject(String target) { | |
| 38 | if (Formatter.isEmptyValue(target)) | |
| 39 | return null; | |
| 40 | ||
| 41 | String stringValue = target.getClass().isArray() ? unwrapString(target) : (String) target; | |
| 42 | stringValue = stringValue.trim().toUpperCase(); | |
| 43 | ||
| 44 | return KEWConstants.DELEGATION_TYPES.get(stringValue); | |
| 45 | if (TRUE_VALUES.contains(stringValue)) | |
| 46 | return Boolean.TRUE; | |
| 47 | if (FALSE_VALUES.contains(stringValue)) | |
| 48 | return Boolean.FALSE; | |
| 49 | ||
| 50 | // begin Kuali Foundation modification | |
| 51 | // was: throw new FormatException(CONVERT_MSG + stringValue); | |
| 52 | throw new FormatException("converting", RiceKeyConstants.ERROR_BOOLEAN, stringValue); | |
| 53 | // end Kuali Foundation modification | |
| 54 | } | |
| 55 | */ | |
| 56 | public Object format(Object target) { | |
| 57 | 0 | if (target == null) |
| 58 | 0 | return null; |
| 59 | // begin Kuali Foundation modification | |
| 60 | 0 | if (target instanceof String) { |
| 61 | 0 | return KEWConstants.DELEGATION_TYPES.get(((String)target).trim().toUpperCase()); |
| 62 | } else { | |
| 63 | 0 | return ""; |
| 64 | } | |
| 65 | } | |
| 66 | } |