KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > db > sql > visualeditor > querymodel > HavingNode


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 package org.netbeans.modules.db.sql.visualeditor.querymodel;
20
21 /**
22  * Represents a HAVING clause in a SQL Table Expression
23  */

24
25 import java.util.ArrayList JavaDoc;
26 import java.util.List JavaDoc;
27 import java.util.Collection JavaDoc;
28
29 public class HavingNode implements Having {
30
31     // Fields
32

33     private Expression _condition; // simplified WHERE clause
34

35     // Constructors
36

37     public HavingNode () {
38     }
39
40     public HavingNode(Expression condition) {
41         _condition = condition;
42     }
43
44
45     // Methods
46

47     // Return the SQL string that corresponds to this From clause
48
// For now, assume no joins
49
public String JavaDoc genText() {
50         String JavaDoc res=""; // NOI18N
51
if (_condition != null) {
52             res = "\nHAVING " + _condition.genText(); // NOI18N
53
}
54
55         return res;
56     }
57
58
59     // Methods
60

61     // Accessors/Mutators
62

63     public Expression getExpression() {
64         return _condition;
65     }
66
67     void renameTableSpec(String JavaDoc oldTableSpec, String JavaDoc corrName) {
68
69         if (_condition instanceof Predicate)
70             ((Predicate) _condition).renameTableSpec(oldTableSpec, corrName);
71     }
72
73     // adds any column in the condition to the ArrayList of columns
74
public void getReferencedColumns (Collection JavaDoc columns) {
75         if (_condition != null)
76             _condition.getReferencedColumns(columns);
77     }
78
79     public void getQueryItems(Collection JavaDoc items) {
80         items.add(_condition);
81     }
82 }
83
84
85
Popular Tags