01: /**
02: * Copyright 2006 Webmedia Group Ltd.
03: *
04: * Licensed under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0
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: **/package org.araneaframework.uilib.list.util.converter;
16:
17: import org.araneaframework.uilib.list.util.Converter;
18:
19: /**
20: * Converter that leaves <code>null</code> values unaltered and uses a another
21: * not-null <code>converter</code> for all other cases.
22: */
23: public class NullConverter implements Converter {
24:
25: protected Converter notNullConverter;
26:
27: public NullConverter(Converter notNullConverter) {
28: this .notNullConverter = notNullConverter;
29: }
30:
31: public Object convert(Object data) throws ConversionException {
32: if (data == null) {
33: return null;
34: }
35: return this .notNullConverter.convert(data);
36: }
37:
38: public Object reverseConvert(Object data)
39: throws ConversionException {
40: if (data == null) {
41: return null;
42: }
43: return this .notNullConverter.reverseConvert(data);
44: }
45:
46: public Class getSourceType() {
47: return this .notNullConverter.getSourceType();
48: }
49:
50: public Class getDestinationType() {
51: return this.notNullConverter.getDestinationType();
52: }
53:
54: }
|