View Javadoc
1   /**
2    *    Copyright 2009-2015 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.apache.ibatis.scripting;
17  
18  import org.apache.ibatis.executor.parameter.ParameterHandler;
19  import org.apache.ibatis.mapping.BoundSql;
20  import org.apache.ibatis.mapping.MappedStatement;
21  import org.apache.ibatis.mapping.SqlSource;
22  import org.apache.ibatis.parsing.XNode;
23  import org.apache.ibatis.scripting.defaults.DefaultParameterHandler;
24  import org.apache.ibatis.session.Configuration;
25  
26  public interface LanguageDriver {
27  
28    /**
29     * Creates a {@link ParameterHandler} that passes the actual parameters to the the JDBC statement.
30     * 
31     * @author Frank D. Martinez [mnesarco]
32     * @see DefaultParameterHandler
33     * @param mappedStatement The mapped statement that is being executed
34     * @param parameterObject The input parameter object (can be null) 
35     * @param boundSql The resulting SQL once the dynamic language has been executed.
36     * @return
37     */
38    ParameterHandler createParameterHandler(MappedStatement mappedStatement, Object parameterObject, BoundSql boundSql);
39  
40    /**
41     * Creates an {@link SqlSource} that will hold the statement read from a mapper xml file. 
42     * It is called during startup, when the mapped statement is read from a class or an xml file.
43     * 
44     * @param configuration The MyBatis configuration
45     * @param script XNode parsed from a XML file
46     * @param parameterType input parameter type got from a mapper method or specified in the parameterType xml attribute. Can be null.
47     * @return
48     */
49    SqlSource createSqlSource(Configuration configuration, XNode script, Class<?> parameterType);
50  
51    /**
52     * Creates an {@link SqlSource} that will hold the statement read from an annotation.
53     * It is called during startup, when the mapped statement is read from a class or an xml file.
54     * 
55     * @param configuration The MyBatis configuration
56     * @param script The content of the annotation
57     * @param parameterType input parameter type got from a mapper method or specified in the parameterType xml attribute. Can be null.
58     * @return 
59     */
60    SqlSource createSqlSource(Configuration configuration, String script, Class<?> parameterType);
61  
62  }