KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > ojb > jdo > jdoql > VisitorBase


1 package org.apache.ojb.jdo.jdoql;
2
3 /* Copyright 2003-2005 The Apache Software Foundation
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17
18 import java.util.Iterator JavaDoc;
19 import java.util.List JavaDoc;
20
21 /**
22  * Convenience base class for visitors that provides basic traversal capabilities.
23  *
24  * @author <a HREF="mailto:tomdz@apache.org">Thomas Dudziak</a>
25  */

26 public class VisitorBase implements Visitor
27 {
28     /* (non-Javadoc)
29      * @see org.apache.ojb.jdo.jdoql.Visitor#visitFilter(org.apache.ojb.jdo.jdoql.Expression)
30      */

31     public void visitFilter(Expression filterExpr)
32     {
33         filterExpr.accept(this);
34     }
35
36     /* (non-Javadoc)
37      * @see org.apache.ojb.jdo.jdoql.Visitor#visitOrderings(java.util.List)
38      */

39     public void visitOrderings(List JavaDoc orderings)
40     {
41         for (Iterator JavaDoc it = orderings.iterator(); it.hasNext();)
42         {
43             ((Acceptor)it.next()).accept(this);
44         }
45     }
46
47     /* (non-Javadoc)
48      * @see org.apache.ojb.jdo.jdoql.Visitor#visitParameters(java.util.List)
49      */

50     public void visitParameters(List JavaDoc params)
51     {
52         for (Iterator JavaDoc it = params.iterator(); it.hasNext();)
53         {
54             ((Acceptor)it.next()).accept(this);
55         }
56     }
57
58     /* (non-Javadoc)
59      * @see org.apache.ojb.jdo.jdoql.Visitor#visitVariables(java.util.List)
60      */

61     public void visitVariables(List JavaDoc variables)
62     {
63         for (Iterator JavaDoc it = variables.iterator(); it.hasNext();)
64         {
65             ((Acceptor)it.next()).accept(this);
66         }
67     }
68
69     /* (non-Javadoc)
70      * @see org.apache.ojb.jdo.jdoql.Visitor#visit(org.apache.ojb.jdo.jdoql.BinaryExpression)
71      */

72     public void visit(BinaryExpression binExpr)
73     {
74         binExpr.getLeftSide().accept(this);
75         binExpr.getRightSide().accept(this);
76     }
77
78     /* (non-Javadoc)
79      * @see org.apache.ojb.jdo.jdoql.Visitor#visit(org.apache.ojb.jdo.jdoql.FieldAccess)
80      */

81     public void visit(FieldAccess fieldAccess)
82     {
83         if (fieldAccess.hasBaseExpression())
84         {
85             fieldAccess.getBaseExpression().accept(this);
86         }
87     }
88
89     /* (non-Javadoc)
90      * @see org.apache.ojb.jdo.jdoql.Visitor#visit(org.apache.ojb.jdo.jdoql.Import)
91      */

92     public void visit(Import importSpec)
93     {
94     }
95
96     /* (non-Javadoc)
97      * @see org.apache.ojb.jdo.jdoql.Visitor#visit(org.apache.ojb.jdo.jdoql.Literal)
98      */

99     public void visit(Literal literal)
100     {
101     }
102
103     /* (non-Javadoc)
104      * @see org.apache.ojb.jdo.jdoql.Visitor#visit(org.apache.ojb.jdo.jdoql.LocalVariable)
105      */

106     public void visit(LocalVariable localVar)
107     {
108         localVar.getType().accept(this);
109     }
110
111     /* (non-Javadoc)
112      * @see org.apache.ojb.jdo.jdoql.Visitor#visit(org.apache.ojb.jdo.jdoql.LocalVariableAccess)
113      */

114     public void visit(LocalVariableAccess localVarAccess)
115     {
116     }
117
118     /* (non-Javadoc)
119      * @see org.apache.ojb.jdo.jdoql.Visitor#visit(org.apache.ojb.jdo.jdoql.MethodInvocation)
120      */

121     public void visit(MethodInvocation methodInvoc)
122     {
123         if (methodInvoc.hasBaseExpression())
124         {
125             methodInvoc.getBaseExpression().accept(this);
126         }
127         for (Iterator JavaDoc it = methodInvoc.getArguments().iterator(); it.hasNext();)
128         {
129             ((Acceptor)it.next()).accept(this);
130         }
131     }
132
133     /* (non-Javadoc)
134      * @see org.apache.ojb.jdo.jdoql.Visitor#visit(org.apache.ojb.jdo.jdoql.NullLiteral)
135      */

136     public void visit(NullLiteral nullLit)
137     {
138     }
139
140     /* (non-Javadoc)
141      * @see org.apache.ojb.jdo.jdoql.Visitor#visit(org.apache.ojb.jdo.jdoql.Ordering)
142      */

143     public void visit(Ordering ordering)
144     {
145         ordering.getExpression().accept(this);
146     }
147
148     /* (non-Javadoc)
149      * @see org.apache.ojb.jdo.jdoql.Visitor#visit(org.apache.ojb.jdo.jdoql.ThisExpression)
150      */

151     public void visit(ThisExpression thisExpr)
152     {
153     }
154
155     /* (non-Javadoc)
156      * @see org.apache.ojb.jdo.jdoql.Visitor#visit(org.apache.ojb.jdo.jdoql.Type)
157      */

158     public void visit(Type type)
159     {
160     }
161
162     /* (non-Javadoc)
163      * @see org.apache.ojb.jdo.jdoql.Visitor#visit(org.apache.ojb.jdo.jdoql.TypeAccess)
164      */

165     public void visit(TypeAccess typeAccess)
166     {
167         if (typeAccess.hasBaseExpression())
168         {
169             typeAccess.getBaseExpression().accept(this);
170         }
171     }
172
173     /* (non-Javadoc)
174      * @see org.apache.ojb.jdo.jdoql.Visitor#visit(org.apache.ojb.jdo.jdoql.UnaryExpression)
175      */

176     public void visit(UnaryExpression unaryExpr)
177     {
178         if (unaryExpr.getOperator() == UnaryExpression.OPERATOR_CAST)
179         {
180             unaryExpr.getCastType().accept(this);
181         }
182         unaryExpr.getInnerExpression().accept(this);
183     }
184
185     /* (non-Javadoc)
186      * @see org.apache.ojb.jdo.jdoql.Visitor#visit(org.apache.ojb.jdo.jdoql.NameExpression)
187      */

188     public void visit(NameExpression nameExpr)
189     {
190         if (nameExpr.hasBaseExpression())
191         {
192             nameExpr.getBaseExpression().accept(this);
193         }
194     }
195
196 }
197
Popular Tags