001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * // Copyright (c) 1998, 2007, Oracle. All rights reserved.
005: *
006: *
007: * The contents of this file are subject to the terms of either the GNU
008: * General Public License Version 2 only ("GPL") or the Common Development
009: * and Distribution License("CDDL") (collectively, the "License"). You
010: * may not use this file except in compliance with the License. You can obtain
011: * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
012: * or glassfish/bootstrap/legal/LICENSE.txt. See the License for the specific
013: * language governing permissions and limitations under the License.
014: *
015: * When distributing the software, include this License Header Notice in each
016: * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
017: * Sun designates this particular file as subject to the "Classpath" exception
018: * as provided by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the License
020: * Header, with the fields enclosed by brackets [] replaced by your own
021: * identifying information: "Portions Copyrighted [year]
022: * [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * If you wish your version of this file to be governed by only the CDDL or
027: * only the GPL Version 2, indicate your decision by adding "[Contributor]
028: * elects to include this software in this distribution under the [CDDL or GPL
029: * Version 2] license." If you don't indicate a single choice of license, a
030: * recipient has the option to distribute your version of this file under
031: * either the CDDL, the GPL Version 2 or to extend the choice of license to
032: * its licensees as provided above. However, if you add GPL Version 2 code
033: * and therefore, elected the GPL Version 2 license, then the option applies
034: * only if the new code is made subject to such option by the copyright
035: * holder.
036: */
037: package oracle.toplink.essentials.internal.parsing;
038:
039: import oracle.toplink.essentials.queryframework.*;
040: import oracle.toplink.essentials.expressions.*;
041:
042: /**
043: * INTERNAL:
044: * This node contains the information about what kind of query is represented it's tree
045: * (e.g. Select, Update etc.)
046: * Subclasses of this node will contain query specific behavior.
047: */
048: public abstract class QueryNode extends MajorNode {
049: private ParseTree parseTree;
050:
051: public QueryNode() {
052: super ();
053: }
054:
055: /**
056: * INTERNAL
057: * Returns a DatabaseQuery instance according to the kind of the query the
058: * owning ParseTree represents: SELECT, UPDATE or DELETE.
059: */
060: public abstract DatabaseQuery createDatabaseQuery(
061: ParseTreeContext context);
062:
063: /**
064: * INTERNAL
065: * Apply this node to the passed query
066: */
067: public abstract void applyToQuery(DatabaseQuery theQuery,
068: GenerationContext context);
069:
070: /**
071: * INTERNAL
072: * Return a TopLink expression generated using the left node
073: */
074: public abstract Expression generateExpression(
075: GenerationContext context);
076:
077: /**
078: * Compute the Reference class for this query
079: * @param context
080: * @return the class this query is querying for
081: */
082: public Class getReferenceClass(GenerationContext genContext) {
083: return resolveClass(genContext);
084: }
085:
086: public boolean isSelectNode() {
087: return false;
088: }
089:
090: public boolean isUpdateNode() {
091: return false;
092: }
093:
094: public boolean isDeleteNode() {
095: return false;
096: }
097:
098: /**
099: * Return the class represented in this node.
100: */
101: public abstract Class resolveClass(GenerationContext context);
102:
103: /**
104: * Set the parseTree
105: */
106: public void setParseTree(ParseTree parseTree) {
107: this .parseTree = parseTree;
108: }
109:
110: /** */
111: public ParseTree getParseTree() {
112: return parseTree;
113: }
114:
115: }
|