KickJava   Java API By Example, From Geeks To Geeks.

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


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 exists sub select.
19  */

20 public class ExistsSelectExp extends SelectExp {
21
22     public ExistsSelectExp() {
23     }
24
25     public String JavaDoc toString() {
26         return super.toString();
27     }
28
29     public SqlExp createInstance() {
30         return new ExistsSelectExp();
31     }
32
33     /**
34      * Append SQL for this node to s.
35      *
36      * @param driver The driver being used
37      * @param s Append the SQL here
38      * @param leftSibling
39      */

40     public void appendSQLImp(SqlDriver driver, CharBuf s, SqlExp leftSibling) {
41         s.append("exists (");
42         super.appendSQLImp(driver, s, leftSibling);
43         s.append(')');
44     }
45
46     /**
47      * Check that the select list is valid.
48      */

49     protected void finishSelectList(CharBuf s, int start) {
50         int n = s.size() - start;
51         if (n <= 7) {
52             s.append('1');
53         } else {
54             s.setSize(n - 2); // remove the extra comma and space
55
}
56     }
57
58 }
59
60
Popular Tags