18 package com.mysql.clusterj.core.query;
20 import com.mysql.clusterj.ClusterJFatalInternalException;
21 import com.mysql.clusterj.ClusterJUserException;
22 import com.mysql.clusterj.core.spi.QueryExecutionContext;
23 import com.mysql.clusterj.core.spi.SessionSPI;
24 import com.mysql.clusterj.core.store.ResultData;
25 import com.mysql.clusterj.core.store.ScanFilter;
26 import com.mysql.clusterj.core.util.I18NHelper;
27 import com.mysql.clusterj.core.util.Logger;
28 import com.mysql.clusterj.core.util.LoggerFactoryService;
29 import com.mysql.clusterj.query.QueryDomainType;
31 import java.math.BigDecimal;
32 import java.math.BigInteger;
35 import java.sql.Timestamp;
36 import java.util.ArrayList;
37 import java.util.HashMap;
38 import java.util.List;
53 protected Map<String, Object> boundParameters =
54 new HashMap<String, Object>();
60 private List<ScanFilter> filters =
new ArrayList<ScanFilter>();
63 protected Map<String, Object>
explain = null;
69 if (session == null) {
71 local.
message(
"ERR_Session_Must_Not_Be_Null"));
81 this.
session = context.getSession();
82 boundParameters =
new HashMap<String, Object>(context.boundParameters);
91 this.boundParameters = parameterMap;
100 if (parameterName == null) {
102 local.
message(
"ERR_Parameter_Null"));
104 boundParameters.put(parameterName, value);
111 local.
message(
"ERR_Parameter_Not_Bound", parameterName));
113 return boundParameters.get(parameterName);
122 return boundParameters.containsKey(parameterName);
129 public ResultData getResultData(QueryDomainType<?> queryDomainType) {
130 return ((QueryDomainTypeImpl<?>)queryDomainType).getResultData(
this);
137 filters.add(scanFilter);
149 public void setExplain(Map<String, Object>
explain) {
153 public Map<String, Object> getExplain() {
158 Object result = boundParameters.get(index);
159 if (result == null) {
162 if (result instanceof Byte) {
165 throw new ClusterJUserException(local.
message(
"ERR_Parameter_Wrong_Type", index, result.getClass(),
"Byte"));
169 public BigDecimal getBigDecimal(
String index) {
170 Object result = boundParameters.get(index);
171 if (result == null) {
174 if (result instanceof BigDecimal) {
175 return (BigDecimal)result;
177 throw new ClusterJUserException(local.
message(
"ERR_Parameter_Wrong_Type", index, result.getClass(),
"BigDecimal"));
181 public BigInteger getBigInteger(
String index) {
182 Object result = boundParameters.get(index);
183 if (result == null) {
186 if (result instanceof BigInteger) {
187 return (BigInteger)result;
189 throw new ClusterJUserException(local.
message(
"ERR_Parameter_Wrong_Type", index, result.getClass(),
"BigInteger"));
193 public Boolean getBoolean(
String index) {
194 Object result = boundParameters.get(index);
195 if (result == null) {
198 if (result instanceof Boolean) {
199 return (Boolean)result;
201 throw new ClusterJUserException(local.
message(
"ERR_Parameter_Wrong_Type", index, result.getClass(),
"Boolean"));
205 public byte[] getBytes(
String index) {
206 Object result = boundParameters.get(index);
207 if (result == null) {
210 if (result instanceof byte[]) {
211 return (byte[])result;
213 throw new ClusterJUserException(local.
message(
"ERR_Parameter_Wrong_Type", index, result.getClass(),
"byte[]"));
217 public Double getDouble(
String index) {
218 Object result = boundParameters.get(index);
219 if (result == null) {
222 if (result instanceof Double) {
223 return (Double)result;
225 throw new ClusterJUserException(local.
message(
"ERR_Parameter_Wrong_Type", index, result.getClass(),
"Double"));
229 public Float getFloat(
String index) {
230 Object result = boundParameters.get(index);
231 if (result == null) {
234 if (result instanceof Float) {
235 return (Float)result;
237 throw new ClusterJUserException(local.
message(
"ERR_Parameter_Wrong_Type", index, result.getClass(),
"Float"));
241 public Integer getInt(
String index) {
242 Object result = boundParameters.get(index);
243 if (result == null) {
246 if (result instanceof Integer) {
247 return (Integer)result;
249 throw new ClusterJUserException(local.
message(
"ERR_Parameter_Wrong_Type", index, result.getClass(),
"Integer"));
253 public Date getJavaSqlDate(
String index) {
254 Object result = boundParameters.get(index);
255 if (result == null) {
258 if (result instanceof java.sql.Date) {
259 return (java.sql.Date)result;
261 throw new ClusterJUserException(local.
message(
"ERR_Parameter_Wrong_Type", index, result.getClass(),
"java.sql.Date"));
265 public Time getJavaSqlTime(
String index) {
266 Object result = boundParameters.get(index);
267 if (result == null) {
270 if (result instanceof java.sql.Time) {
271 return (java.sql.Time)result;
273 throw new ClusterJUserException(local.
message(
"ERR_Parameter_Wrong_Type", index, result.getClass(),
"java.sql.Time"));
277 public Timestamp getJavaSqlTimestamp(
String index) {
278 Object result = boundParameters.get(index);
279 if (result == null) {
282 if (result instanceof java.sql.Timestamp) {
283 return (java.sql.Timestamp)result;
285 throw new ClusterJUserException(local.
message(
"ERR_Parameter_Wrong_Type", index, result.getClass(),
"java.sql.Timestamp"));
289 public java.util.Date getJavaUtilDate(
String index) {
290 Object result = boundParameters.get(index);
291 if (result == null) {
294 if (result instanceof java.util.Date) {
295 return (java.util.Date)result;
297 throw new ClusterJUserException(local.
message(
"ERR_Parameter_Wrong_Type", index, result.getClass(),
"java.util.Date"));
301 public Long getLong(
String index) {
302 Object result = boundParameters.get(index);
303 if (result == null) {
306 if (result instanceof Long) {
309 throw new ClusterJUserException(local.
message(
"ERR_Parameter_Wrong_Type", index, result.getClass(),
"Long"));
313 public Short getShort(
String index) {
314 Object result = boundParameters.get(index);
315 if (result == null) {
318 if (result instanceof Short) {
319 return (Short)result;
321 throw new ClusterJUserException(local.
message(
"ERR_Parameter_Wrong_Type", index, result.getClass(),
"Short"));
326 Object result = boundParameters.get(index);
327 if (result == null) {
330 if (result instanceof
String) {
331 return (String)result;
333 throw new ClusterJUserException(local.
message(
"ERR_Parameter_Wrong_Type", index, result.getClass(),
"String"));
337 public Object getObject(String index) {
338 return boundParameters.get(index);