KickJava   Java API By Example, From Geeks To Geeks.

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


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.util.CharBuf;
16
17 import java.util.Map JavaDoc;
18
19 /**
20  * An unary operator expression.
21  */

22 public class UnaryFunctionExp extends UnaryExp {
23
24     public static final int FUNC_TO_LOWER_CASE = 1;
25
26     private int func;
27
28     public UnaryFunctionExp(SqlExp child, int func) {
29         super(child);
30         this.func = func;
31     }
32
33     public UnaryFunctionExp() {
34     }
35
36     public SqlExp createInstance() {
37         return new UnaryFunctionExp();
38     }
39
40     public SqlExp getClone(SqlExp clone, Map JavaDoc cloneMap) {
41         super.getClone(clone, cloneMap);
42
43         ((UnaryFunctionExp) clone).func = func;
44
45         return clone;
46     }
47
48     public String JavaDoc toString() {
49         String JavaDoc s = super.toString() + " ";
50         switch (func) {
51             case FUNC_TO_LOWER_CASE:
52                 return "toLowerCase(" + s + ")";
53         }
54         return s + "unknown(" + func + ")";
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         s.append(driver.getSqlUnaryFunctionName(func));
66         s.append('(');
67         childList.appendSQL(driver, s, null);
68         s.append(')');
69     }
70
71 }
72
Popular Tags