KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > binding > convert > ConversionService


1 /*
2  * Copyright 2002-2006 the original author or authors.
3  *
4  * Licensed under the Apache 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.apache.org/licenses/LICENSE-2.0
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.springframework.binding.convert;
17
18 /**
19  * A service interface for retrieving type conversion executors. The returned
20  * command object is 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      *
35      * @param sourceClass The source class to convert from
36      * @param targetClass The target class to convert to
37      * @return The executor that can execute instance conversion
38      * @throws ConversionException An exception occured retrieving a converter
39      * for the source-to-target pair.
40      */

41     public ConversionExecutor getConversionExecutor(Class JavaDoc sourceClass, Class JavaDoc 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      *
48      * @param sourceClass the sourceClass
49      * @param targetAlias the target alias, may also be the fully qualified
50      * target class name
51      * @return the conversion executor
52      */

53     public ConversionExecutor getConversionExecutorByTargetAlias(Class JavaDoc sourceClass, String JavaDoc targetAlias)
54             throws ConversionException;
55
56     /**
57      * Return all conversion executors capable of converting source objects of
58      * the the specified <code>sourceClass</code>.
59      * @param sourceClass the source class to convert from
60      * @return the matching conversion executors
61      */

62     public ConversionExecutor[] getConversionExecutorsForSource(Class JavaDoc sourceClass) throws ConversionException;
63
64     /**
65      * Return the class with the specified alias.
66      * @param alias the class alias
67      * @return the class
68      */

69     public Class JavaDoc getClassByAlias(String JavaDoc alias) throws ConversionException;
70
71 }
Popular Tags