01: /*
02: * Copyright 2006 The Kuali Foundation.
03: *
04: * Licensed under the Educational Community License, Version 1.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.opensource.org/licenses/ecl1.php
09: *
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.core.web.format;
17:
18: import java.util.Collection;
19:
20: /**
21: * This class is used to prevent reformatting of String values.
22: */
23: public class NoOpStringFormatter extends Formatter {
24: /**
25: * Does absolutely nothing to the given String. Yes, this is actually a valuable way to prevent the POJO stuff from converting a
26: * simple String into a 1-element String array.
27: */
28: protected Object convertToObject(String target) {
29: return target;
30: }
31:
32: /**
33: * Does absolutely nothing to the given String. Yes, this is actually a valuable way to prevent the POJO stuff from converting a
34: * simple String into a 1-element String array.
35: */
36: public Object format(Object value) {
37: if (value != null) {
38: if (!(value instanceof String)) {
39: throw new FormatException("the given "
40: + value.getClass().getName()
41: + " value is not a String");
42: }
43: }
44:
45: return value;
46: }
47:
48: public Object convertFromPresentationFormat(Object value) {
49: return super .convertFromPresentationFormat(value);
50: }
51:
52: public Object formatArray(Object value) {
53: return super .formatArray(value);
54: }
55:
56: public Object formatCollection(Collection value) {
57: return super .formatCollection(value);
58: }
59:
60: public Object formatForPresentation(Object value) {
61: return super .formatForPresentation(value);
62: }
63:
64: public Object formatObject(Object value) {
65: return super.formatObject(value);
66: }
67: }
|