KickJava   Java API By Example, From Geeks To Geeks.

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


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.metadata.JdbcField;
15 import com.versant.core.jdbc.metadata.JdbcColumn;
16 import com.versant.core.jdo.query.ParamNode;
17
18 import java.util.Map JavaDoc;
19
20 /**
21  * This tracks usage of this parameter in an SqlExp tree.
22  * A parameter may be used several times in the same tree if it is
23  * used more than once in the original filter expression. This will be
24  * null if the param is not used.<p>
25  *
26  * A parameter may also have to be split into more than one SqlExp
27  * if it is compared to a field with multiple columns. The first
28  * expression is expList. The expcount field specifies how far down
29  * the list to go as expList may be part of a larger list.
30  *
31  * @see com.versant.core.jdo.query.ParamNode#usageList
32  */

33 public class ParamNodeUsage {
34
35     /**
36      * Add us to the end of the usage list for n.
37      */

38     public void addToParamNode(ParamNode n) {
39         if (n.usageList == null) {
40             n.usageList = this;
41         } else {
42             ParamNodeUsage p = (ParamNodeUsage)n.usageList;
43             for (; p.next != null; p = p.next);
44             p.next = this;
45         }
46     }
47
48     /**
49      * The field for this parameter or null if it is not being compared
50      * to a field.
51      * @see #javaTypeCode
52      * @see #jdbcType
53      */

54     public JdbcField jdbcField;
55
56     public JdbcColumn col;
57     /**
58      * The java type code of this usage of the parameter. This is not
59      * set if jdbcField is not null.
60      * @see #jdbcField
61      */

62     public int javaTypeCode;
63     /**
64      * The JDBC type of this usage of the parameter. This is not
65      * set if jdbcField is not null.
66      * @see java.sql.Types
67      * @see #jdbcField
68      */

69     public int jdbcType;
70     /**
71      * The class index of the class for this parameter (-1 if unknown).
72      * This is used for OID parameters compared to columns that are
73      * not associated with a field e.g. in a link table.
74      */

75     public int classIndex;
76     /**
77      * The first expression for this usage of the parameter. This is
78      * the parent of the first ParamExp instance for this usage.
79      */

80     public SqlExp expList;
81     /**
82      * The number of expressions in expList for this usage of the
83      * parameter. If a param is used with a field split over multiple
84      * columns then this will be more than 1. This will be zero if
85      * the parameter never has to be converted into a 'is null' or
86      * 'is not null' expression.
87      */

88     public int expCount;
89     /**
90      * How must the parameter value be modified before being set? This is
91      * used for startsWith and endsWith for databases that do not allow
92      * expressions on the right hand side of a LIKE (e.g. Informix).
93      * @see com.versant.core.jdbc.query.SqlStruct.Param#MOD_APPEND_PERCENT
94      */

95     public int mod;
96     /**
97      * The next usage in the list.
98      */

99     public ParamNodeUsage next;
100
101     public ParamNodeUsage getClone(Map JavaDoc cloneMap) {
102         ParamNodeUsage sqlUsage = new ParamNodeUsage();
103         sqlUsage.jdbcField = jdbcField;
104         sqlUsage.javaTypeCode = javaTypeCode;
105         sqlUsage.jdbcType = jdbcType;
106         sqlUsage.classIndex = classIndex;
107         sqlUsage.expCount = expCount;
108         sqlUsage.mod = mod;
109         sqlUsage.expList = SqlExp.createClone(expList, cloneMap);
110         if (next != null) {
111             sqlUsage.next = next.getClone(cloneMap);
112         }
113         return sqlUsage;
114     }
115 }
116
117
Popular Tags