01: /*
02: * Copyright (c) 1998 - 2005 Versant Corporation
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * Versant Corporation - initial API and implementation
10: */
11: package com.versant.core.jdbc.sql.exp;
12:
13: import com.versant.core.jdbc.sql.SqlDriver;
14: import com.versant.core.jdbc.metadata.JdbcTypes;
15: import com.versant.core.util.CharBuf;
16: import com.versant.core.jdo.query.ParamNode;
17:
18: import java.util.Map;
19:
20: /**
21: * A replaceable parameter.
22: */
23: public class ParamExp extends LeafExp {
24:
25: public int jdbcType;
26: public SqlParamUsage usage;
27: protected int firstCharIndex;
28:
29: public ParamExp(int jdbcType, SqlParamUsage usage) {
30: this .jdbcType = jdbcType;
31: this .usage = usage;
32: }
33:
34: public ParamExp() {
35: }
36:
37: public SqlExp createInstance() {
38: return new ParamExp();
39: }
40:
41: public SqlExp getClone(SqlExp clone, Map cloneMap) {
42: super .getClone(clone, cloneMap);
43: ParamExp cst = (ParamExp) clone;
44:
45: cst.jdbcType = jdbcType;
46: if (usage != null)
47: cst.usage = usage.getClone(cloneMap);
48: cst.firstCharIndex = firstCharIndex;
49:
50: return clone;
51: }
52:
53: public String toString() {
54: return super .toString() + " " + JdbcTypes.toString(jdbcType);
55: }
56:
57: /**
58: * Append SQL for this node to s.
59: *
60: * @param driver The driver being used
61: * @param s Append the SQL here
62: * @param leftSibling
63: */
64: public void appendSQLImp(SqlDriver driver, CharBuf s,
65: SqlExp leftSibling) {
66: firstCharIndex = s.size();
67: s.append(driver.getSqlParamString(jdbcType));
68: }
69:
70: /**
71: * Get the index of first character of the 'is null' parameter
72: * replacement span for this expression.
73: */
74: public int getFirstCharIndex() {
75: return firstCharIndex;
76: }
77: }
|