Source Code Cross Referenced for TableSelectExpression.java in  » Database-DBMS » mckoi » com » mckoi » database » interpret » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Database DBMS » mckoi » com.mckoi.database.interpret 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * com.mckoi.database.interpret.TableSelectExpression  30 Oct 2001
003:         *
004:         * Mckoi SQL Database ( http://www.mckoi.com/database )
005:         * Copyright (C) 2000, 2001, 2002  Diehl and Associates, Inc.
006:         *
007:         * This program is free software; you can redistribute it and/or
008:         * modify it under the terms of the GNU General Public License
009:         * Version 2 as published by the Free Software Foundation.
010:         *
011:         * This program is distributed in the hope that it will be useful,
012:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
014:         * GNU General Public License Version 2 for more details.
015:         *
016:         * You should have received a copy of the GNU General Public License
017:         * Version 2 along with this program; if not, write to the Free Software
018:         * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
019:         *
020:         * Change Log:
021:         * 
022:         * 
023:         */package com.mckoi.database.interpret;
024:
025:        import com.mckoi.database.*;
026:        import java.util.*;
027:
028:        /**
029:         * A container object for the a table select expression, eg.
030:         * <p><pre>
031:         *               SELECT [columns]
032:         *                 FROM [tables]
033:         *                WHERE [search_clause]
034:         *             GROUP BY [column]
035:         *               HAVING [search_clause]
036:         * [composite_function] [table_select_expression]
037:         * </pre><p>
038:         * Note that a TableSelectExpression can be nested in the various clauses of
039:         * this object.
040:         *
041:         * @author Tobias Downer
042:         */
043:
044:        public final class TableSelectExpression implements 
045:                java.io.Serializable, StatementTreeObject, Cloneable {
046:
047:            static final long serialVersionUID = 6946017316981412561L;
048:
049:            /**
050:             * True if we only search for distinct elements.
051:             */
052:            public boolean distinct = false;
053:
054:            /**
055:             * The list of columns to select from.
056:             * (SelectColumn)
057:             */
058:            public ArrayList columns = new ArrayList();
059:
060:            /**
061:             * The from clause.
062:             */
063:            public FromClause from_clause = new FromClause();
064:
065:            /**
066:             * The where clause.
067:             */
068:            public SearchExpression where_clause = new SearchExpression();
069:
070:            /**
071:             * The list of columns to group by.
072:             * (ByColumn)
073:             */
074:            public ArrayList group_by = new ArrayList();
075:
076:            /**
077:             * The group max variable or null if no group max.
078:             */
079:            public Variable group_max = null;
080:
081:            /**
082:             * The having clause.
083:             */
084:            public SearchExpression having_clause = new SearchExpression();
085:
086:            /**
087:             * If there is a composite function this is set to the composite enumeration
088:             * from CompositeTable.
089:             */
090:            int composite_function = -1; // (None)
091:
092:            /**
093:             * If this is an ALL composite (no removal of duplicate rows) it is true.
094:             */
095:            boolean is_composite_all;
096:
097:            /**
098:             * The composite table itself.
099:             */
100:            TableSelectExpression next_composite;
101:
102:            /**
103:             * Constructor.
104:             */
105:            public TableSelectExpression() {
106:            }
107:
108:            /**
109:             * Chains a new composite function to this expression.  For example, if
110:             * this expression is a UNION ALL with another expression it would be
111:             * set through this method.
112:             */
113:            public void chainComposite(TableSelectExpression expression,
114:                    String composite, boolean is_all) {
115:                this .next_composite = expression;
116:                composite = composite.toLowerCase();
117:                if (composite.equals("union")) {
118:                    composite_function = CompositeTable.UNION;
119:                } else if (composite.equals("intersect")) {
120:                    composite_function = CompositeTable.INTERSECT;
121:                } else if (composite.equals("except")) {
122:                    composite_function = CompositeTable.EXCEPT;
123:                } else {
124:                    throw new Error("Don't understand composite function '"
125:                            + composite + "'");
126:                }
127:                is_composite_all = is_all;
128:            }
129:
130:            // ---------- Implemented from StatementTreeObject ----------
131:
132:            /**
133:             * Prepares all the expressions in the list.
134:             */
135:            private static void prepareAllInList(List list,
136:                    ExpressionPreparer preparer) throws DatabaseException {
137:                for (int n = 0; n < list.size(); ++n) {
138:                    StatementTreeObject ob = (StatementTreeObject) list.get(n);
139:                    ob.prepareExpressions(preparer);
140:                }
141:            }
142:
143:            public void prepareExpressions(ExpressionPreparer preparer)
144:                    throws DatabaseException {
145:                prepareAllInList(columns, preparer);
146:                from_clause.prepareExpressions(preparer);
147:                where_clause.prepareExpressions(preparer);
148:                prepareAllInList(group_by, preparer);
149:                having_clause.prepareExpressions(preparer);
150:
151:                // Go to the next chain
152:                if (next_composite != null) {
153:                    next_composite.prepareExpressions(preparer);
154:                }
155:            }
156:
157:            public Object clone() throws CloneNotSupportedException {
158:                TableSelectExpression v = (TableSelectExpression) super .clone();
159:                if (columns != null) {
160:                    v.columns = (ArrayList) StatementTree
161:                            .cloneSingleObject(columns);
162:                }
163:                if (from_clause != null) {
164:                    v.from_clause = (FromClause) from_clause.clone();
165:                }
166:                if (where_clause != null) {
167:                    v.where_clause = (SearchExpression) where_clause.clone();
168:                }
169:                if (group_by != null) {
170:                    v.group_by = (ArrayList) StatementTree
171:                            .cloneSingleObject(group_by);
172:                }
173:                if (group_max != null) {
174:                    v.group_max = (Variable) group_max.clone();
175:                }
176:                if (having_clause != null) {
177:                    v.having_clause = (SearchExpression) having_clause.clone();
178:                }
179:                if (next_composite != null) {
180:                    v.next_composite = (TableSelectExpression) next_composite
181:                            .clone();
182:                }
183:                return v;
184:            }
185:
186:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.