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 service interface for retrieving type conversion executors. The returned
20: * command objects are thread-safe and may be safely cached for use by client
21: * code.
22: *
23: * @author Keith Donald
24: */
25: public interface ConversionService {
26:
27: /**
28: * Return a conversion executor command object capable of converting source
29: * objects of the specified <code>sourceClass</code> to instances of the
30: * <code>targetClass</code>.
31: * <p>
32: * The returned ConversionExecutor is thread-safe and may safely be cached
33: * for use in client code.
34: * @param sourceClass the source class to convert from
35: * @param targetClass the target class to convert to
36: * @return the executor that can execute instance conversion, never null
37: * @throws ConversionException an exception occured retrieving a converter
38: * for the source-to-target pair
39: */
40: public ConversionExecutor getConversionExecutor(Class sourceClass,
41: Class targetClass) throws ConversionException;
42:
43: /**
44: * Return a conversion executor command object capable of converting source
45: * objects of the specified <code>sourceClass</code> to target objects of
46: * the type associated with the specified alias.
47: * @param sourceClass the sourceClass
48: * @param targetAlias the target alias
49: * @return the conversion executor, or null if the alias cannot be found
50: * @throws ConversionException an exception occured retrieving a converter
51: * for the source-to-target pair
52: */
53: public ConversionExecutor getConversionExecutorByTargetAlias(
54: Class sourceClass, String targetAlias)
55: throws ConversionException;
56:
57: /**
58: * Return all conversion executors capable of converting source objects of
59: * the the specified <code>sourceClass</code>.
60: * @param sourceClass the source class to convert from
61: * @return the matching conversion executors
62: * @throws ConversionException an exception occured retrieving the converters
63: */
64: public ConversionExecutor[] getConversionExecutorsForSource(
65: Class sourceClass) throws ConversionException;
66:
67: /**
68: * Return the class with the specified alias.
69: * @param alias the class alias
70: * @return the class, or null if not aliased
71: * @throws ConversionException when an error occurs looking up the class by alias
72: */
73: public Class getClassByAlias(String alias)
74: throws ConversionException;
75:
76: }
|