Source Code Cross Referenced for SelectItemQualifier.java in  » GIS » GeoTools-2.4.1 » org » geotools » arcsde » data » view » 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 » GIS » GeoTools 2.4.1 » org.geotools.arcsde.data.view 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *    Geotools2 - OpenSource mapping toolkit
003:         *    http://geotools.org
004:         *    (C) 2002, Geotools Project Managment Committee (PMC)
005:         *
006:         *    This library is free software; you can redistribute it and/or
007:         *    modify it under the terms of the GNU Lesser General Public
008:         *    License as published by the Free Software Foundation;
009:         *    version 2.1 of the License.
010:         *
011:         *    This library 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 GNU
014:         *    Lesser General Public License for more details.
015:         *
016:         */
017:        package org.geotools.arcsde.data.view;
018:
019:        import java.util.ArrayList;
020:        import java.util.Collections;
021:        import java.util.List;
022:        import java.util.Map;
023:
024:        import net.sf.jsqlparser.expression.Expression;
025:        import net.sf.jsqlparser.schema.Column;
026:        import net.sf.jsqlparser.schema.Table;
027:        import net.sf.jsqlparser.statement.select.AllColumns;
028:        import net.sf.jsqlparser.statement.select.AllTableColumns;
029:        import net.sf.jsqlparser.statement.select.SelectExpressionItem;
030:        import net.sf.jsqlparser.statement.select.SelectItem;
031:
032:        import com.esri.sde.sdk.client.SeColumnDefinition;
033:        import com.esri.sde.sdk.client.SeConnection;
034:        import com.esri.sde.sdk.client.SeException;
035:        import com.esri.sde.sdk.client.SeTable;
036:
037:        /**
038:         * Qualifies instances of {@link net.sf.jsqlparser.statement.select.SelectExpressionItem},
039:         * and creates a list of qualified {@link net.sf.jsqlparser.statement.select.SelectExpressionItem}
040:         * for each {@link net.sf.jsqlparser.statement.select.AllColumns} and 
041:         * {@link net.sf.jsqlparser.statement.select.AllTableColumns} instances. So, this visitor
042:         * may produce more items than the visited.
043:         * 
044:         * @author Gabriel Roldan, Axios Engineering
045:         * @version $Id: SelectItemQualifier.java 29135 2008-02-07 19:49:09Z desruisseaux $
046:         * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/unsupported/arcsde/datastore/src/main/java/org/geotools/arcsde/data/view/SelectItemQualifier.java $
047:         * @since 2.3.x
048:         */
049:        class SelectItemQualifier implements 
050:                net.sf.jsqlparser.statement.select.SelectItemVisitor {
051:            /** DOCUMENT ME! */
052:            private List /*<SelectExpressionItem>*/qualifiedItems = Collections.EMPTY_LIST;
053:
054:            /** DOCUMENT ME! */
055:            private SeConnection conn;
056:
057:            private Map tableAliases;
058:
059:            /**
060:             * Creates a new SelectItemQualifier object.
061:             * 
062:             * @param conn
063:             *            DOCUMENT ME!
064:             */
065:            private SelectItemQualifier(SeConnection conn, Map tableAliases) {
066:                this .conn = conn;
067:                this .tableAliases = tableAliases;
068:            }
069:
070:            /**
071:             * DOCUMENT ME!
072:             * 
073:             * @param conn
074:             *            DOCUMENT ME!
075:             * @param item
076:             *            DOCUMENT ME!
077:             * 
078:             * @return DOCUMENT ME!
079:             */
080:            public static List qualify(SeConnection conn, Map tableAliases,
081:                    SelectItem item) {
082:                if (item == null) {
083:                    return null;
084:                }
085:
086:                SelectItemQualifier qualifier = new SelectItemQualifier(conn,
087:                        tableAliases);
088:                item.accept(qualifier);
089:
090:                return qualifier.qualifiedItems;
091:            }
092:
093:            /**
094:             * DOCUMENT ME!
095:             * 
096:             * @param allColumns
097:             *            DOCUMENT ME!
098:             */
099:            public void visit(AllColumns allColumns) {
100:                this .qualifiedItems = Collections.singletonList(allColumns);
101:            }
102:
103:            /**
104:             * DOCUMENT ME!
105:             * 
106:             * @param allTableColumns
107:             *            DOCUMENT ME!
108:             */
109:            public void visit(AllTableColumns allTableColumns) {
110:                AllTableColumns qualified = new AllTableColumns();
111:
112:                Table qt = allTableColumns.getTable();
113:                Table unaliasedTable = (Table) tableAliases.get(qt.getName());
114:
115:                if (unaliasedTable == null) {
116:                    //not an aliased table, qualify it
117:                    qt = TableQualifier.qualify(conn, allTableColumns
118:                            .getTable());
119:                } else {
120:                    //AllTableColumns is refering to an aliased table in the FROM clause,
121:                    //replace its table by the original one to get rid of the alias
122:                    qt = unaliasedTable;
123:                }
124:
125:                qualified.setTable(qt);
126:
127:                String tableName = qt.getSchemaName() + "." + qt.getName();
128:                SeTable table;
129:                SeColumnDefinition[] cols;
130:                try {
131:                    table = new SeTable(conn, tableName);
132:                    cols = table.describe();
133:                } catch (SeException e) {
134:                    throw new RuntimeException(e.getMessage());
135:                }
136:
137:                qualifiedItems = new ArrayList(cols.length);
138:
139:                for (int i = 0; i < cols.length; i++) {
140:                    String colName = cols[i].getName();
141:
142:                    Column column = new Column();
143:                    column.setTable(qt);
144:                    column.setColumnName(colName);
145:
146:                    SelectExpressionItem item = new SelectExpressionItem();
147:                    item.setExpression(column);
148:
149:                    qualifiedItems.add(item);
150:                }
151:            }
152:
153:            /**
154:             * DOCUMENT ME!
155:             * 
156:             * @param selectExpressionItem
157:             *            DOCUMENT ME!
158:             */
159:            public void visit(SelectExpressionItem selectExpressionItem) {
160:
161:                SelectExpressionItem qualifiedItem = new SelectExpressionItem();
162:
163:                qualifiedItem.setAlias(selectExpressionItem.getAlias());
164:
165:                Expression selectExpression = selectExpressionItem
166:                        .getExpression();
167:
168:                Expression qualifiedExpression = ExpressionQualifier.qualify(
169:                        conn, tableAliases, selectExpression);
170:
171:                qualifiedItem.setExpression(qualifiedExpression);
172:
173:                this.qualifiedItems = Collections.singletonList(qualifiedItem);
174:            }
175:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.