Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
ArrayFormatter |
|
| 1.0;1 |
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 | ||
19 | /** | |
20 | * Currently, in the {@link Formatter Formatter} class, array are formatted | |
21 | * by returning the first item in the array. This is not acceptable in some cases. | |
22 | * | |
23 | * <p> | |
24 | * One example is a struts multi-select dropdown. In order for struts to correctly handle | |
25 | * field highlighting struts expects an array. | |
26 | * </p> | |
27 | * | |
28 | * <p> | |
29 | * This formatter does not handle {@code null} arrays or arrays with {@code null} items. | |
30 | * This class may need to be modified to handle these conditions. | |
31 | * </p> | |
32 | */ | |
33 | 0 | public class ArrayFormatter extends Formatter { |
34 | ||
35 | private static final long serialVersionUID = -2207993820610088716L; | |
36 | ||
37 | /* | |
38 | public Object convertFromPresentationFormat(Object value) { | |
39 | if (isEmptyValue(value)) | |
40 | return getNullObjectValue(); | |
41 | ||
42 | Class type = value.getClass(); | |
43 | boolean isArray = true; | |
44 | boolean isCollection = propertyType != null && Collection.class.isAssignableFrom(propertyType); | |
45 | ||
46 | String[] strings = isArray ? (String[]) value : new String[] { (String) value }; | |
47 | ||
48 | return isArray ? convertToArray(strings) : convertToCollection(strings); | |
49 | } | |
50 | */ | |
51 | /** | |
52 | * Returns the value passed in. | |
53 | * | |
54 | * {@inheritDoc} | |
55 | */ | |
56 | @Override | |
57 | public Object formatObject(Object value) { | |
58 | 0 | return value; |
59 | } | |
60 | } |