001: package org.apache.ojb.jdo.jdoql;
002:
003: /* Copyright 2003-2005 The Apache Software Foundation
004: *
005: * Licensed under the Apache License, Version 2.0 (the "License");
006: * you may not use this file except in compliance with the License.
007: * You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017:
018: import java.util.Iterator;
019: import java.util.List;
020:
021: /**
022: * Convenience base class for visitors that provides basic traversal capabilities.
023: *
024: * @author <a href="mailto:tomdz@apache.org">Thomas Dudziak</a>
025: */
026: public class VisitorBase implements Visitor {
027: /* (non-Javadoc)
028: * @see org.apache.ojb.jdo.jdoql.Visitor#visitFilter(org.apache.ojb.jdo.jdoql.Expression)
029: */
030: public void visitFilter(Expression filterExpr) {
031: filterExpr.accept(this );
032: }
033:
034: /* (non-Javadoc)
035: * @see org.apache.ojb.jdo.jdoql.Visitor#visitOrderings(java.util.List)
036: */
037: public void visitOrderings(List orderings) {
038: for (Iterator it = orderings.iterator(); it.hasNext();) {
039: ((Acceptor) it.next()).accept(this );
040: }
041: }
042:
043: /* (non-Javadoc)
044: * @see org.apache.ojb.jdo.jdoql.Visitor#visitParameters(java.util.List)
045: */
046: public void visitParameters(List params) {
047: for (Iterator it = params.iterator(); it.hasNext();) {
048: ((Acceptor) it.next()).accept(this );
049: }
050: }
051:
052: /* (non-Javadoc)
053: * @see org.apache.ojb.jdo.jdoql.Visitor#visitVariables(java.util.List)
054: */
055: public void visitVariables(List variables) {
056: for (Iterator it = variables.iterator(); it.hasNext();) {
057: ((Acceptor) it.next()).accept(this );
058: }
059: }
060:
061: /* (non-Javadoc)
062: * @see org.apache.ojb.jdo.jdoql.Visitor#visit(org.apache.ojb.jdo.jdoql.BinaryExpression)
063: */
064: public void visit(BinaryExpression binExpr) {
065: binExpr.getLeftSide().accept(this );
066: binExpr.getRightSide().accept(this );
067: }
068:
069: /* (non-Javadoc)
070: * @see org.apache.ojb.jdo.jdoql.Visitor#visit(org.apache.ojb.jdo.jdoql.FieldAccess)
071: */
072: public void visit(FieldAccess fieldAccess) {
073: if (fieldAccess.hasBaseExpression()) {
074: fieldAccess.getBaseExpression().accept(this );
075: }
076: }
077:
078: /* (non-Javadoc)
079: * @see org.apache.ojb.jdo.jdoql.Visitor#visit(org.apache.ojb.jdo.jdoql.Import)
080: */
081: public void visit(Import importSpec) {
082: }
083:
084: /* (non-Javadoc)
085: * @see org.apache.ojb.jdo.jdoql.Visitor#visit(org.apache.ojb.jdo.jdoql.Literal)
086: */
087: public void visit(Literal literal) {
088: }
089:
090: /* (non-Javadoc)
091: * @see org.apache.ojb.jdo.jdoql.Visitor#visit(org.apache.ojb.jdo.jdoql.LocalVariable)
092: */
093: public void visit(LocalVariable localVar) {
094: localVar.getType().accept(this );
095: }
096:
097: /* (non-Javadoc)
098: * @see org.apache.ojb.jdo.jdoql.Visitor#visit(org.apache.ojb.jdo.jdoql.LocalVariableAccess)
099: */
100: public void visit(LocalVariableAccess localVarAccess) {
101: }
102:
103: /* (non-Javadoc)
104: * @see org.apache.ojb.jdo.jdoql.Visitor#visit(org.apache.ojb.jdo.jdoql.MethodInvocation)
105: */
106: public void visit(MethodInvocation methodInvoc) {
107: if (methodInvoc.hasBaseExpression()) {
108: methodInvoc.getBaseExpression().accept(this );
109: }
110: for (Iterator it = methodInvoc.getArguments().iterator(); it
111: .hasNext();) {
112: ((Acceptor) it.next()).accept(this );
113: }
114: }
115:
116: /* (non-Javadoc)
117: * @see org.apache.ojb.jdo.jdoql.Visitor#visit(org.apache.ojb.jdo.jdoql.NullLiteral)
118: */
119: public void visit(NullLiteral nullLit) {
120: }
121:
122: /* (non-Javadoc)
123: * @see org.apache.ojb.jdo.jdoql.Visitor#visit(org.apache.ojb.jdo.jdoql.Ordering)
124: */
125: public void visit(Ordering ordering) {
126: ordering.getExpression().accept(this );
127: }
128:
129: /* (non-Javadoc)
130: * @see org.apache.ojb.jdo.jdoql.Visitor#visit(org.apache.ojb.jdo.jdoql.ThisExpression)
131: */
132: public void visit(ThisExpression this Expr) {
133: }
134:
135: /* (non-Javadoc)
136: * @see org.apache.ojb.jdo.jdoql.Visitor#visit(org.apache.ojb.jdo.jdoql.Type)
137: */
138: public void visit(Type type) {
139: }
140:
141: /* (non-Javadoc)
142: * @see org.apache.ojb.jdo.jdoql.Visitor#visit(org.apache.ojb.jdo.jdoql.TypeAccess)
143: */
144: public void visit(TypeAccess typeAccess) {
145: if (typeAccess.hasBaseExpression()) {
146: typeAccess.getBaseExpression().accept(this );
147: }
148: }
149:
150: /* (non-Javadoc)
151: * @see org.apache.ojb.jdo.jdoql.Visitor#visit(org.apache.ojb.jdo.jdoql.UnaryExpression)
152: */
153: public void visit(UnaryExpression unaryExpr) {
154: if (unaryExpr.getOperator() == UnaryExpression.OPERATOR_CAST) {
155: unaryExpr.getCastType().accept(this );
156: }
157: unaryExpr.getInnerExpression().accept(this );
158: }
159:
160: /* (non-Javadoc)
161: * @see org.apache.ojb.jdo.jdoql.Visitor#visit(org.apache.ojb.jdo.jdoql.NameExpression)
162: */
163: public void visit(NameExpression nameExpr) {
164: if (nameExpr.hasBaseExpression()) {
165: nameExpr.getBaseExpression().accept(this);
166: }
167: }
168:
169: }
|