Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
NoOpStringFormatter |
|
| 1.4285714285714286;1.429 |
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 | package org.kuali.rice.core.web.format; | |
17 | ||
18 | import java.util.Collection; | |
19 | ||
20 | ||
21 | /** | |
22 | * This class is used to prevent reformatting of String values. | |
23 | */ | |
24 | 0 | public class NoOpStringFormatter extends Formatter { |
25 | ||
26 | private static final long serialVersionUID = 7724214487192363066L; | |
27 | ||
28 | /** | |
29 | * Does absolutely nothing to the given String. Yes, this is actually a valuable way to prevent the POJO stuff from converting a | |
30 | * simple String into a 1-element String array. | |
31 | */ | |
32 | protected Object convertToObject(String target) { | |
33 | 0 | return target; |
34 | } | |
35 | ||
36 | /** | |
37 | * Does absolutely nothing to the given String. Yes, this is actually a valuable way to prevent the POJO stuff from converting a | |
38 | * simple String into a 1-element String array. | |
39 | */ | |
40 | public Object format(Object value) { | |
41 | 0 | if (value != null) { |
42 | 0 | if (!(value instanceof String)) { |
43 | 0 | throw new FormatException("the given " + value.getClass().getName() + " value is not a String"); |
44 | } | |
45 | } | |
46 | ||
47 | 0 | return value; |
48 | } | |
49 | ||
50 | public Object convertFromPresentationFormat(Object value) { | |
51 | 0 | return super.convertFromPresentationFormat(value); |
52 | } | |
53 | ||
54 | public Object formatArray(Object value) { | |
55 | 0 | return super.formatArray(value); |
56 | } | |
57 | ||
58 | public Object formatCollection(Collection value) { | |
59 | 0 | return super.formatCollection(value); |
60 | } | |
61 | ||
62 | public Object formatForPresentation(Object value) { | |
63 | 0 | return super.formatForPresentation(value); |
64 | } | |
65 | ||
66 | public Object formatObject(Object value) { | |
67 | 0 | return super.formatObject(value); |
68 | } | |
69 | } |