KickJava   Java API By Example, From Geeks To Geeks.

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


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  * This is an entry in an order by list.
21  */

22 public class OrderExp extends UnaryExp {
23
24     private boolean desc;
25
26     public OrderExp(SqlExp child, boolean desc) {
27         super(child);
28         this.desc = desc;
29     }
30
31     public OrderExp() {
32     }
33
34     public SqlExp createInstance() {
35         return new OrderExp();
36     }
37
38     public SqlExp getClone(SqlExp clone, Map JavaDoc cloneMap) {
39         super.getClone(clone, cloneMap);
40
41         ((OrderExp) clone).desc = desc;
42
43         return clone;
44     }
45
46     public String JavaDoc toString() {
47         return super.toString() + (desc ? " desc" : "");
48     }
49
50     /**
51      * Append SQL for this node to s.
52      *
53      * @param driver The driver being used
54      * @param s Append the SQL here
55      * @param leftSibling
56      */

57     public void appendSQLImp(SqlDriver driver, CharBuf s, SqlExp leftSibling) {
58         super.appendSQLImp(driver, s, leftSibling);
59         if (desc) s.append(" DESC");
60     }
61
62     public boolean isDesc() {
63         return desc;
64     }
65 }
66
67
Popular Tags