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: * Aggregate.
18: */
19: public class AggregateExp extends UnaryExp {
20: private String type;
21: private String asValue;
22:
23: public AggregateExp(SqlExp child, String type) {
24: super (child);
25: this .type = type;
26: }
27:
28: public AggregateExp(SqlExp child, String type, String asValue) {
29: super (child);
30: this .type = type;
31: this .asValue = asValue;
32: }
33:
34: public String getAsValue() {
35: return asValue;
36: }
37:
38: public void setAsValue(String asValue) {
39: this .asValue = asValue;
40: }
41:
42: /**
43: * Append SQL for this node to s.
44: *
45: * @param driver The driver being used
46: * @param s Append the SQL here
47: * @param leftSibling
48: */
49: public void appendSQLImp(SqlDriver driver, CharBuf s,
50: SqlExp leftSibling) {
51: s.append(type);
52: s.append("(");
53: childList.appendSQL(driver, s, null);
54: s.append(')');
55:
56: if (asValue != null) {
57: s.append(" as " + asValue);
58: }
59: }
60:
61: }
|