• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package org.apache.velocity.util.introspection;
2 
3 /*
4  * Licensed to the Apache Software Foundation (ASF) under one
5  * or more contributor license agreements.  See the NOTICE file
6  * distributed with this work for additional information
7  * regarding copyright ownership.  The ASF licenses this file
8  * to you under the Apache License, Version 2.0 (the
9  * "License"); you may not use this file except in compliance
10  * with the License.  You may obtain a copy of the License at
11  *
12  *   http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing,
15  * software distributed under the License is distributed on an
16  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17  * KIND, either express or implied.  See the License for the
18  * specific language governing permissions and limitations
19  * under the License.
20  */
21 
22 /**
23  * A conversion handler adds admissible conversions between Java types whenever Velocity introspection has to map
24  * VTL methods and property accessors to Java methods.
25  * Both methods must be consistent: <code>getNeededConverter</code> must not return <code>null</code> whenever
26  * <code>isExplicitlyConvertible</code> returned true with the same arguments.
27  *
28  * @author <a href="mailto:claude.brisson@gmail.com">Claude Brisson</a>
29  * @version $Id: ConversionHandler.java $
30  * @deprecated use {@link TypeConversionHandler}
31  * @see TypeConversionHandler
32  * @since 2.0
33  */
34 
35 @Deprecated
36 public interface ConversionHandler
37 {
38     /**
39      * Check to see if the conversion can be done using an explicit conversion
40      *
41      * @param formal expected formal type
42      * @param actual provided argument type
43      * @param possibleVarArg whether var arg is possible here
44      * @return null if no conversion is needed, or the appropriate Converter object
45      * @since 2.0
46      */
isExplicitlyConvertible(Class<?> formal, Class<?> actual, boolean possibleVarArg)47     boolean isExplicitlyConvertible(Class<?> formal, Class<?> actual, boolean possibleVarArg);
48 
49     /**
50      * Returns the appropriate Converter object needed for an explicit conversion
51      * Returns null if no conversion is needed.
52      *
53      * @param formal expected formal type
54      * @param actual provided argument type
55      * @return null if no conversion is needed, or the appropriate Converter object
56      * @since 2.0
57      */
getNeededConverter(final Class<?> formal, final Class<?> actual)58     Converter getNeededConverter(final Class<?> formal, final Class<?> actual);
59 
60     /**
61      * Add the given converter to the handler. Implementation should be thread-safe.
62      *
63      * @param formal    expected formal type
64      * @param actual    provided argument type
65      * @param converter converter
66      * @since 2.0
67      */
addConverter(Class<?> formal, Class<?> actual, Converter converter)68     void addConverter(Class<?> formal, Class<?> actual, Converter converter);
69 }
70 
71