| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| SimpleBooleanFormatter |
|
| 2.0;2 |
| 1 | /* | |
| 2 | * Copyright 2006-2008 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.web.format; | |
| 17 | ||
| 18 | ||
| 19 | /** | |
| 20 | * This class is used to convert Boolean objects into and from 'true' and 'false' Strings, since that's what JSTL expects to use in | |
| 21 | * conditionals. | |
| 22 | */ | |
| 23 | 0 | public class SimpleBooleanFormatter extends Formatter { |
| 24 | ||
| 25 | private static final long serialVersionUID = 1733029018087594949L; | |
| 26 | ||
| 27 | /** | |
| 28 | * Converts the given true/false String into a Boolean. | |
| 29 | */ | |
| 30 | protected Object convertToObject(String target) { | |
| 31 | 0 | return Boolean.valueOf(target); |
| 32 | } | |
| 33 | ||
| 34 | /** | |
| 35 | * Converts the given Boolean into a boolean String. | |
| 36 | */ | |
| 37 | public Object format(Object value) { | |
| 38 | 0 | Object formatted = value; |
| 39 | ||
| 40 | 0 | if ((value != null) && (value instanceof Boolean)) { |
| 41 | 0 | formatted = value.toString(); |
| 42 | } | |
| 43 | ||
| 44 | 0 | return formatted; |
| 45 | } | |
| 46 | } |