1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.ibatis.mapping;
17
18 import java.util.HashMap;
19 import java.util.List;
20 import java.util.Map;
21
22 import org.apache.ibatis.reflection.MetaObject;
23 import org.apache.ibatis.reflection.property.PropertyTokenizer;
24 import org.apache.ibatis.session.Configuration;
25
26
27
28
29
30
31
32
33
34
35 public class BoundSql {
36
37 private final String sql;
38 private final List<ParameterMapping> parameterMappings;
39 private final Object parameterObject;
40 private final Map<String, Object> additionalParameters;
41 private final MetaObject metaParameters;
42
43 public BoundSql(Configuration configuration, String sql, List<ParameterMapping> parameterMappings,
44 Object parameterObject) {
45 this.sql = sql;
46 this.parameterMappings = parameterMappings;
47 this.parameterObject = parameterObject;
48 this.additionalParameters = new HashMap<>();
49 this.metaParameters = configuration.newMetaObject(additionalParameters);
50 }
51
52 public String getSql() {
53 return sql;
54 }
55
56 public List<ParameterMapping> getParameterMappings() {
57 return parameterMappings;
58 }
59
60 public Object getParameterObject() {
61 return parameterObject;
62 }
63
64 public boolean hasAdditionalParameter(String name) {
65 String paramName = new PropertyTokenizer(name).getName();
66 return additionalParameters.containsKey(paramName);
67 }
68
69 public void setAdditionalParameter(String name, Object value) {
70 metaParameters.setValue(name, value);
71 }
72
73 public Object getAdditionalParameter(String name) {
74 return metaParameters.getValue(name);
75 }
76
77 public Map<String, Object> getAdditionalParameters() {
78 return additionalParameters;
79 }
80 }