KickJava   Java API By Example, From Geeks To Geeks.

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


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 /**
18  * Aggregate.
19  */

20 public class AggregateExp extends UnaryExp {
21     private String JavaDoc type;
22     private String JavaDoc asValue;
23
24     public AggregateExp(SqlExp child, String JavaDoc type) {
25         super(child);
26         this.type = type;
27     }
28
29     public AggregateExp(SqlExp child, String JavaDoc type, String JavaDoc asValue) {
30         super(child);
31         this.type = type;
32         this.asValue = asValue;
33     }
34
35     public String JavaDoc getAsValue() {
36         return asValue;
37     }
38
39     public void setAsValue(String JavaDoc asValue) {
40         this.asValue = asValue;
41     }
42
43     /**
44      * Append SQL for this node to s.
45      *
46      * @param driver The driver being used
47      * @param s Append the SQL here
48      * @param leftSibling
49      */

50     public void appendSQLImp(SqlDriver driver, CharBuf s, 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
62 }
63
Popular Tags