KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > oracle > toplink > essentials > internal > expressions > ExpressionIterator


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the "License"). You may not use this file except
5  * in compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * glassfish/bootstrap/legal/CDDLv1.0.txt or
9  * https://glassfish.dev.java.net/public/CDDLv1.0.html.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * HEADER in each file and include the License file at
15  * glassfish/bootstrap/legal/CDDLv1.0.txt. If applicable,
16  * add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your
18  * own identifying information: Portions Copyright [yyyy]
19  * [name of copyright owner]
20  */

21 // Copyright (c) 1998, 2006, Oracle. All rights reserved.
22
package oracle.toplink.essentials.internal.expressions;
23
24 import java.util.*;
25 import oracle.toplink.essentials.expressions.*;
26
27 /**
28  * Used to itterate an expression tree, through inner subclasses.
29  */

30 public abstract class ExpressionIterator {
31
32     /** Allow the iteration to build a result. */
33     protected Object JavaDoc result;
34
35     /** Some iterations require a statement. */
36     protected SQLSelectStatement statement;
37
38     /** Some iterations require a more general parameter. */
39     protected Object JavaDoc parameter;
40
41     /**
42      * Block constructor comment.
43      */

44     public ExpressionIterator() {
45         super();
46     }
47
48     public Object JavaDoc getResult() {
49         return result;
50     }
51
52     public SQLSelectStatement getStatement() {
53         return statement;
54     }
55
56     /**
57      * Answers if this expression has already been visited.
58      * For a faster iteration override to insure expressions are only
59      * visited/processed once.
60      */

61     public boolean hasAlreadyVisited(Expression expression) {
62         return false;
63     }
64
65     /**
66      * INTERNAL:
67      * This method must be defined by subclasses to implement the logic of the iteratation.
68      */

69     public abstract void iterate(Expression expression);
70
71     /**
72      * INTERNAL:
73      */

74     public void iterateOn(Vector expressions) {
75         for (Enumeration expressionEnum = expressions.elements(); expressionEnum.hasMoreElements();) {
76             iterate((Expression)expressionEnum.nextElement());
77         }
78     }
79
80     /**
81      * INTERNAL:
82      * Return the call.
83      */

84     public void iterateOn(Expression expression) {
85         expression.iterateOn(this);
86     }
87
88     public void setResult(Object JavaDoc result) {
89         this.result = result;
90     }
91
92     public void setStatement(SQLSelectStatement statement) {
93         this.statement = statement;
94     }
95
96     /**
97      * Normally an Iterator will not go into the where clause of
98      * an SQLSubSelectExpression. I.e. when aliasing the parent statement
99      * is aliased before the subselects may even be normalized. An iterator to
100      * alias the SubSelect must be run later.
101      */

102     public boolean shouldIterateOverSubSelects() {
103         return false;
104     }
105 }
106
Popular Tags