View Javadoc
1   /*
2    * Copyright 2004-2022 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    *    https://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 com.ibatis.sqlmap.engine.mapping.sql.stat;
17  
18  import com.ibatis.sqlmap.engine.mapping.parameter.ParameterMap;
19  import com.ibatis.sqlmap.engine.mapping.result.ResultMap;
20  import com.ibatis.sqlmap.engine.mapping.sql.Sql;
21  import com.ibatis.sqlmap.engine.scope.StatementScope;
22  
23  /**
24   * The Class StaticSql.
25   */
26  public class StaticSql implements Sql {
27  
28    /** The sql statement. */
29    private String sqlStatement;
30  
31    /**
32     * Instantiates a new static sql.
33     *
34     * @param sqlStatement
35     *          the sql statement
36     */
37    public StaticSql(String sqlStatement) {
38      this.sqlStatement = sqlStatement.replace('\r', ' ').replace('\n', ' ');
39    }
40  
41    public String getSql(StatementScope statementScope, Object parameterObject) {
42      return sqlStatement;
43    }
44  
45    public ParameterMap getParameterMap(StatementScope statementScope, Object parameterObject) {
46      return statementScope.getParameterMap();
47    }
48  
49    public ResultMap getResultMap(StatementScope statementScope, Object parameterObject) {
50      return statementScope.getResultMap();
51    }
52  
53    public void cleanup(StatementScope statementScope) {
54    }
55  
56  }