KickJava   Java API By Example, From Geeks To Geeks.

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


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.util.CharBuf;
15 import com.versant.core.jdbc.sql.SqlDriver;
16
17 /**
18  * An 'in' expression.
19  */

20 public class InExp extends SqlExp {
21
22     public InExp(SqlExp children) {
23         super(children);
24     }
25
26     public InExp() {
27     }
28
29     public SqlExp createInstance() {
30         return new InExp();
31     }
32
33     /**
34      * If this expression is added to an AndExp should it be enclosed in
35      * parenthesis?
36      */

37     public boolean requiresParensInAnd() {
38         return false;
39     }
40
41     /**
42      * Append SQL for this node to s.
43      *
44      * @param driver The driver being used
45      * @param s Append the SQL here
46      * @param leftSibling
47      */

48     public void appendSQLImp(SqlDriver driver, CharBuf s, SqlExp leftSibling) {
49         childList.appendSQL(driver, s, null);
50         s.append(" IN (");
51         SqlExp e = childList.next;
52         e.appendSQL(driver, s, null);
53         for (e = e.next; e != null; e = e.next) {
54             s.append(',');
55             s.append(' ');
56             e.appendSQL(driver, s, null);
57         }
58         s.append(')');
59     }
60
61 }
62
63
Popular Tags