01: /*
02: * Copyright 2004-2007 the original author or authors.
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: */
16: package org.springframework.binding.convert;
17:
18: /**
19: * A type converter converts objects from one type to another. They may support
20: * conversion of multiple source types to multiple target types.
21: * <p>
22: * Implementations of this interface are thread-safe.
23: *
24: * @author Keith Donald
25: */
26: public interface Converter {
27:
28: /**
29: * The source classes this converter can convert from.
30: * @return the supported source classes
31: */
32: public Class[] getSourceClasses();
33:
34: /**
35: * The target classes this converter can convert to.
36: * @return the supported target classes
37: */
38: public Class[] getTargetClasses();
39:
40: /**
41: * Convert the provided source object argument to an instance of the
42: * specified target class.
43: * @param source the source object to convert, its class must be one of the
44: * supported <code>sourceClasses</code>
45: * @param targetClass the target class to convert the source to, must be one
46: * of the supported <code>targetClasses</code>
47: * @param context an optional conversion context that may be used to
48: * influence the conversion process
49: * @return the converted object, an instance of the target type
50: * @throws ConversionException an exception occured during the conversion
51: */
52: public Object convert(Object source, Class targetClass,
53: ConversionContext context) throws ConversionException;
54:
55: }
|