KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > versant > core > jdbc > sql > exp > ParamExp


1
2 /*
3  * Copyright (c) 1998 - 2005 Versant Corporation
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License v1.0
6  * which accompanies this distribution, and is available at
7  * http://www.eclipse.org/legal/epl-v10.html
8  *
9  * Contributors:
10  * Versant Corporation - initial API and implementation
11  */

12 package com.versant.core.jdbc.sql.exp;
13
14 import com.versant.core.jdbc.sql.SqlDriver;
15 import com.versant.core.jdbc.metadata.JdbcTypes;
16 import com.versant.core.util.CharBuf;
17 import com.versant.core.jdo.query.ParamNode;
18
19 import java.util.Map JavaDoc;
20
21 /**
22  * A replaceable parameter.
23  */

24 public class ParamExp extends LeafExp {
25
26     public int jdbcType;
27     public SqlParamUsage usage;
28     protected int firstCharIndex;
29
30     public ParamExp(int jdbcType, SqlParamUsage usage) {
31         this.jdbcType = jdbcType;
32         this.usage = usage;
33     }
34
35     public ParamExp() {
36     }
37
38     public SqlExp createInstance() {
39         return new ParamExp();
40     }
41
42     public SqlExp getClone(SqlExp clone, Map JavaDoc cloneMap) {
43         super.getClone(clone, cloneMap);
44         ParamExp cst = (ParamExp) clone;
45
46         cst.jdbcType = jdbcType;
47         if (usage != null) cst.usage = usage.getClone(cloneMap);
48         cst.firstCharIndex = firstCharIndex;
49
50         return clone;
51     }
52
53     public String JavaDoc 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, SqlExp leftSibling) {
65         firstCharIndex = s.size();
66         s.append(driver.getSqlParamString(jdbcType));
67     }
68
69     /**
70      * Get the index of first character of the 'is null' parameter
71      * replacement span for this expression.
72      */

73     public int getFirstCharIndex() {
74         return firstCharIndex;
75     }
76 }
77
Popular Tags