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 java.util.List;
040:
041: /**
042: * INTERNAL
043: * <p><b>Purpose</b>: This interface specifies methods to create parse trees
044: * and parse tree nodes.
045: * <p><b>Responsibilities</b>:<ul>
046: * <li> Used by the EJBQLParser to create an internal representation of an
047: * EJBQL query.
048: * <li> Abstract from concrete parse tree and parse tree node implementation
049: * classes.
050: * <li> The parse is created in a bottom-up fashion. All methods takes any
051: * child nodes for the parse tree node to be created as arguments. It is the
052: * responsibility of the new<XXX> method to set the parent-child relationship
053: * between the returned node any any of the child nodes passed as arguments.
054: * </ul>
055: */
056: public interface NodeFactory {
057:
058: /** Trim specification constants. */
059: public enum TrimSpecification {
060: LEADING, TRAILING, BOTH
061: }
062:
063: // ------------------------------------------
064: // Trees
065: // ------------------------------------------
066:
067: /** */
068: public Object newSelectStatement(int line, int column,
069: Object select, Object from, Object where, Object groupBy,
070: Object having, Object orderBy);
071:
072: /** */
073: public Object newUpdateStatement(int line, int column,
074: Object update, Object set, Object where);
075:
076: /** */
077: public Object newDeleteStatement(int line, int column,
078: Object delete, Object where);
079:
080: // ------------------------------------------
081: // Top level nodes
082: // ------------------------------------------
083:
084: /** */
085: public Object newSelectClause(int line, int column,
086: boolean distinct, List selectExprs);
087:
088: /** */
089: public Object newFromClause(int line, int column, List varDecls);
090:
091: /** */
092: public Object newWhereClause(int line, int column, Object condition);
093:
094: /** */
095: public Object newGroupByClause(int line, int column, List items);
096:
097: /** */
098: public Object newHavingClause(int line, int column, Object arg);
099:
100: /** */
101: public Object newOrderByClause(int line, int column, List items);
102:
103: /** */
104: public Object newUpdateClause(int line, int column, String schema,
105: String variable);
106:
107: /** */
108: public Object newDeleteClause(int line, int column, String schema,
109: String variable);
110:
111: // ------------------------------------------
112: // Variable declaration nodes
113: // ------------------------------------------
114:
115: /** */
116: public Object newRangeVariableDecl(int line, int column,
117: String schema, String variable);
118:
119: /** */
120: public Object newJoinVariableDecl(int line, int column,
121: boolean outer, Object path, String variable);
122:
123: /** */
124: public Object newFetchJoin(int line, int column, boolean outer,
125: Object path);
126:
127: /** */
128: public Object newCollectionMemberVariableDecl(int line, int column,
129: Object path, String variable);
130:
131: /** */
132: public Object newVariableDecl(int line, int column, Object path,
133: String variable);
134:
135: // ------------------------------------------
136: // Identifier and path expression nodes
137: // ------------------------------------------
138:
139: /** */
140: public Object newDot(int line, int column, Object left, Object right);
141:
142: /** */
143: public Object newVariableAccess(int line, int column,
144: String identifier);
145:
146: /** */
147: public Object newAttribute(int line, int column, String identifier);
148:
149: /** */
150: public Object newQualifiedAttribute(int line, int column,
151: String variable, String attribute);
152:
153: // ------------------------------------------
154: // Aggregate nodes
155: // ------------------------------------------
156:
157: /** */
158: public Object newAvg(int line, int column, boolean ditinct,
159: Object arg);
160:
161: /** */
162: public Object newMax(int line, int column, boolean ditinct,
163: Object arg);
164:
165: /** */
166: public Object newMin(int line, int column, boolean ditinct,
167: Object arg);
168:
169: /** */
170: public Object newSum(int line, int column, boolean ditinct,
171: Object arg);
172:
173: /** */
174: public Object newCount(int line, int column, boolean ditinct,
175: Object arg);
176:
177: // ------------------------------------------
178: // Binary expression nodes
179: // ------------------------------------------
180:
181: /** */
182: public Object newOr(int line, int column, Object left, Object right);
183:
184: /** */
185: public Object newAnd(int line, int column, Object left, Object right);
186:
187: /** */
188: public Object newEquals(int line, int column, Object left,
189: Object right);
190:
191: /** */
192: public Object newNotEquals(int line, int column, Object left,
193: Object right);
194:
195: /** */
196: public Object newGreaterThan(int line, int column, Object left,
197: Object right);
198:
199: /** */
200: public Object newGreaterThanEqual(int line, int column,
201: Object left, Object right);
202:
203: /** */
204: public Object newLessThan(int line, int column, Object left,
205: Object right);
206:
207: /** */
208: public Object newLessThanEqual(int line, int column, Object left,
209: Object right);
210:
211: /** */
212: public Object newPlus(int line, int column, Object left,
213: Object right);
214:
215: /** */
216: public Object newMinus(int line, int column, Object left,
217: Object right);
218:
219: /** */
220: public Object newMultiply(int line, int column, Object left,
221: Object right);
222:
223: /** */
224: public Object newDivide(int line, int column, Object left,
225: Object right);
226:
227: // ------------------------------------------
228: // Unary expression nodes
229: // ------------------------------------------
230:
231: /** */
232: public Object newUnaryPlus(int line, int column, Object arg);
233:
234: /** */
235: public Object newUnaryMinus(int line, int column, Object arg);
236:
237: /** */
238: public Object newNot(int line, int column, Object arg);
239:
240: // ------------------------------------------
241: // Conditional expression nodes
242: // ------------------------------------------
243:
244: /** */
245: public Object newBetween(int line, int column, boolean not,
246: Object arg, Object lower, Object upper);
247:
248: /** */
249: public Object newLike(int line, int column, boolean not,
250: Object string, Object pattern, Object escape);
251:
252: /** */
253: public Object newEscape(int line, int column, Object arg);
254:
255: /** */
256: public Object newIn(int line, int column, boolean not, Object expr,
257: List items);
258:
259: /** */
260: public Object newIsNull(int line, int column, boolean not,
261: Object expr);
262:
263: /** */
264: public Object newIsEmpty(int line, int column, boolean not,
265: Object expr);
266:
267: /** */
268: public Object newMemberOf(int line, int column, boolean not,
269: Object expr, Object collection);
270:
271: // ------------------------------------------
272: // Parameter nodes
273: // ------------------------------------------
274:
275: /** */
276: public Object newPositionalParameter(int line, int colimn,
277: String position);
278:
279: /** */
280: public Object newNamedParameter(int line, int colimn, String name);
281:
282: // ------------------------------------------
283: // Literal nodes
284: // ------------------------------------------
285:
286: /** */
287: public Object newBooleanLiteral(int line, int column, Object value);
288:
289: /** */
290: public Object newIntegerLiteral(int line, int column, Object value);
291:
292: /** */
293: public Object newLongLiteral(int line, int column, Object value);
294:
295: /** */
296: public Object newFloatLiteral(int line, int column, Object value);
297:
298: /** */
299: public Object newDoubleLiteral(int line, int column, Object value);
300:
301: /** */
302: public Object newStringLiteral(int line, int column, Object value);
303:
304: /** */
305: public Object newNullLiteral(int line, int column);
306:
307: // ------------------------------------------
308: // Objects for functions returning strings
309: // ------------------------------------------
310:
311: /** */
312: public Object newConcat(int line, int column, Object left,
313: Object right);
314:
315: /** */
316: public Object newSubstring(int line, int column, Object string,
317: Object start, Object length);
318:
319: /** */
320: public Object newTrim(int line, int column,
321: TrimSpecification trimSpec, Object trimChar, Object string);
322:
323: /** */
324: public Object newLower(int line, int column, Object arg);
325:
326: /** */
327: public Object newUpper(int line, int column, Object arg);
328:
329: // ------------------------------------------
330: // Objects for functions returning numerics
331: // ------------------------------------------
332:
333: /** */
334: public Object newLocate(int line, int column, Object pattern,
335: Object arg, Object startPos);
336:
337: /** */
338: public Object newLength(int line, int column, Object arg);
339:
340: /** */
341: public Object newAbs(int line, int column, Object arg);
342:
343: /** */
344: public Object newSqrt(int line, int column, Object arg);
345:
346: /** */
347: public Object newMod(int line, int column, Object left, Object right);
348:
349: /** */
350: public Object newSize(int line, int column, Object arg);
351:
352: // ------------------------------------------
353: // Objects for functions returning datetime
354: // ------------------------------------------
355:
356: /** */
357: public Object newCurrentDate(int line, int column);
358:
359: /** */
360: public Object newCurrentTime(int line, int column);
361:
362: /** */
363: public Object newCurrentTimestamp(int line, int column);
364:
365: // ------------------------------------------
366: // Subquery nodes
367: // ------------------------------------------
368:
369: /** */
370: public Object newSubquery(int line, int column, Object select,
371: Object from, Object where, Object groupBy, Object having);
372:
373: /** */
374: public Object newExists(int line, int column, boolean not,
375: Object subquery);
376:
377: /** */
378: public Object newIn(int line, int column, boolean not, Object expr,
379: Object subquery);
380:
381: /** */
382: public Object newAll(int line, int column, Object subquery);
383:
384: /** */
385: public Object newAny(int line, int column, Object subquery);
386:
387: /** */
388: public Object newSome(int line, int column, Object subquery);
389:
390: // ------------------------------------------
391: // Miscellaneous nodes
392: // ------------------------------------------
393:
394: /** */
395: public Object newAscOrdering(int line, int column, Object arg);
396:
397: /** */
398: public Object newDescOrdering(int line, int column, Object arg);
399:
400: /** */
401: public Object newConstructor(int line, int colimn,
402: String className, List args);
403:
404: /** */
405: public Object newSetClause(int line, int colimn, List assignments);
406:
407: /** */
408: public Object newSetAssignmentClause(int line, int column,
409: Object target, Object value);
410:
411: }
|