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: /**
17: * An expression with one child.
18: */
19: public class UnaryExp extends SqlExp {
20:
21: public UnaryExp(SqlExp child) {
22: super (child);
23: }
24:
25: public UnaryExp() {
26: }
27:
28: public SqlExp createInstance() {
29: return new UnaryExp();
30: }
31:
32: /**
33: * Create an aliases for any tables we may have.
34: */
35: public int createAlias(int index) {
36: return childList.createAlias(index);
37: }
38:
39: /**
40: * Append SQL for this node to s.
41: *
42: * @param driver The driver being used
43: * @param s Append the SQL here
44: * @param leftSibling
45: */
46: public void appendSQLImp(SqlDriver driver, CharBuf s,
47: SqlExp leftSibling) {
48: childList.appendSQL(driver, s, null);
49: }
50:
51: /**
52: * Normalize this node i.e. transform it into its simplist possible form.
53: * This will turn sub selects into joins and so on.
54: */
55: public SqlExp normalize(SqlDriver driver, SelectExp sel,
56: boolean convertExists) {
57: SqlExp r = childList.normalize(driver, sel, convertExists);
58: if (r != null)
59: childList = r;
60: return null;
61: }
62:
63: /**
64: * Replace any references to old with nw. This is used when redundant
65: * joins are removed.
66: */
67: public void replaceSelectExpRef(SelectExp old, SelectExp nw) {
68: childList.replaceSelectExpRef(old, nw);
69: }
70:
71: /**
72: * What is the JDBC type of this expression (0 if unknown)?
73: */
74: public int getJdbcType() {
75: return childList.getJdbcType();
76: }
77:
78: /**
79: * What is the java type code of this expression (0 if unknown)?
80: */
81: public int getJavaTypeCode() {
82: return childList.getJavaTypeCode();
83: }
84: }
|