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.Iterator;
021: import java.util.List;
022: import java.util.Map;
023:
024: import net.sf.jsqlparser.expression.Expression;
025: import net.sf.jsqlparser.expression.operators.relational.ExpressionList;
026: import net.sf.jsqlparser.expression.operators.relational.ItemsList;
027: import net.sf.jsqlparser.expression.operators.relational.ItemsListVisitor;
028: import net.sf.jsqlparser.statement.select.SubSelect;
029:
030: import com.esri.sde.sdk.client.SeConnection;
031:
032: /**
033: * DOCUMENT ME!
034: *
035: * @author Gabriel Roldan, Axios Engineering
036: * @version $Id: ItemsListQualifier.java 29135 2008-02-07 19:49:09Z desruisseaux $
037: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/unsupported/arcsde/datastore/src/main/java/org/geotools/arcsde/data/view/ItemsListQualifier.java $
038: * @since 2.3.x
039: */
040: class ItemsListQualifier implements ItemsListVisitor {
041: /** DOCUMENT ME! */
042: ItemsList qualifiedList;
043:
044: /** DOCUMENT ME! */
045: private SeConnection conn;
046:
047: private Map tableAliases;
048:
049: /**
050: * Creates a new ItemsListQualifier object.
051: *
052: * @param conn DOCUMENT ME!
053: */
054: public ItemsListQualifier(SeConnection conn, Map tableAliases) {
055: this .conn = conn;
056: this .tableAliases = tableAliases;
057: }
058:
059: /**
060: * DOCUMENT ME!
061: *
062: * @param conn DOCUMENT ME!
063: * @param items DOCUMENT ME!
064: *
065: * @return DOCUMENT ME!
066: */
067: public static ItemsList qualify(SeConnection conn,
068: Map tableAliases, ItemsList items) {
069: if (items == null) {
070: return null;
071: }
072:
073: ItemsListQualifier q = new ItemsListQualifier(conn,
074: tableAliases);
075: items.accept(q);
076:
077: return q.qualifiedList;
078: }
079:
080: /**
081: * DOCUMENT ME!
082: *
083: * @param subSelect DOCUMENT ME!
084: */
085: public void visit(SubSelect subSelect) {
086: SubSelect qualified = SubSelectQualifier.qualify(conn,
087: subSelect);
088: this .qualifiedList = qualified;
089: }
090:
091: /**
092: * DOCUMENT ME!
093: *
094: * @param expressionList DOCUMENT ME!
095: */
096: public void visit(ExpressionList expressionList) {
097: List expressions = expressionList.getExpressions();
098: List qualifiedList = new ArrayList(expressions.size());
099:
100: for (Iterator it = expressions.iterator(); it.hasNext();) {
101: Expression exp = (Expression) it.next();
102: Expression qExp = ExpressionQualifier.qualify(conn,
103: tableAliases, exp);
104:
105: qualifiedList.add(qExp);
106: }
107:
108: ExpressionList qExpList = new ExpressionList();
109: qExpList.setExpressions(qualifiedList);
110: this.qualifiedList = qExpList;
111: }
112: }
|