01: /*
02: * Copyright (c) 1998 - 2005 Versant Corporation
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * Versant Corporation - initial API and implementation
10: */
11: package com.versant.core.jdbc.sql.exp;
12:
13: import com.versant.core.jdbc.sql.SqlDriver;
14: import com.versant.core.util.CharBuf;
15:
16: import java.util.Map;
17:
18: /**
19: * An unary operator expression.
20: */
21: public class UnaryFunctionExp extends UnaryExp {
22:
23: public static final int FUNC_TO_LOWER_CASE = 1;
24:
25: private int func;
26:
27: public UnaryFunctionExp(SqlExp child, int func) {
28: super (child);
29: this .func = func;
30: }
31:
32: public UnaryFunctionExp() {
33: }
34:
35: public SqlExp createInstance() {
36: return new UnaryFunctionExp();
37: }
38:
39: public SqlExp getClone(SqlExp clone, Map cloneMap) {
40: super .getClone(clone, cloneMap);
41:
42: ((UnaryFunctionExp) clone).func = func;
43:
44: return clone;
45: }
46:
47: public String toString() {
48: String s = super .toString() + " ";
49: switch (func) {
50: case FUNC_TO_LOWER_CASE:
51: return "toLowerCase(" + s + ")";
52: }
53: return s + "unknown(" + func + ")";
54: }
55:
56: /**
57: * Append SQL for this node to s.
58: *
59: * @param driver The driver being used
60: * @param s Append the SQL here
61: * @param leftSibling
62: */
63: public void appendSQLImp(SqlDriver driver, CharBuf s,
64: SqlExp leftSibling) {
65: s.append(driver.getSqlUnaryFunctionName(func));
66: s.append('(');
67: childList.appendSQL(driver, s, null);
68: s.append(')');
69: }
70:
71: }
|