KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > xpath > XPathVisitor


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

16 /*
17  * $Id: XPathVisitor.java,v 1.4 2004/02/17 04:30:02 minchau Exp $
18  */

19 package org.apache.xpath;
20
21 import org.apache.xpath.axes.LocPathIterator;
22 import org.apache.xpath.axes.UnionPathIterator;
23 import org.apache.xpath.functions.Function;
24 import org.apache.xpath.objects.XNumber;
25 import org.apache.xpath.objects.XString;
26 import org.apache.xpath.operations.Operation;
27 import org.apache.xpath.operations.UnaryOperation;
28 import org.apache.xpath.operations.Variable;
29 import org.apache.xpath.patterns.NodeTest;
30 import org.apache.xpath.patterns.StepPattern;
31 import org.apache.xpath.patterns.UnionPattern;
32
33 /**
34  * A derivation from this class can be passed to a class that implements
35  * the XPathVisitable interface, to have the appropriate method called
36  * for each component of the XPath. Aside from possible other uses, the
37  * main intention is to provide a reasonable means to perform expression
38  * rewriting.
39  *
40  * <p>Each method has the form
41  * <code>boolean visitComponentType(ExpressionOwner owner, ComponentType compType)</code>.
42  * The ExpressionOwner argument is the owner of the component, and can
43  * be used to reset the expression for rewriting. If a method returns
44  * false, the sub hierarchy will not be traversed.</p>
45  *
46  * <p>This class is meant to be a base class that will be derived by concrete classes,
47  * and doesn't much except return true for each method.</p>
48  */

49 public class XPathVisitor
50 {
51     /**
52      * Visit a LocationPath.
53      * @param owner The owner of the expression, to which the expression can
54      * be reset if rewriting takes place.
55      * @param path The LocationPath object.
56      * @return true if the sub expressions should be traversed.
57      */

58     public boolean visitLocationPath(ExpressionOwner owner, LocPathIterator path)
59     {
60         return true;
61     }
62
63     /**
64      * Visit a UnionPath.
65      * @param owner The owner of the expression, to which the expression can
66      * be reset if rewriting takes place.
67      * @param path The UnionPath object.
68      * @return true if the sub expressions should be traversed.
69      */

70     public boolean visitUnionPath(ExpressionOwner owner, UnionPathIterator path)
71     {
72         return true;
73     }
74     
75     /**
76      * Visit a step within a location path.
77      * @param owner The owner of the expression, to which the expression can
78      * be reset if rewriting takes place.
79      * @param step The Step object.
80      * @return true if the sub expressions should be traversed.
81      */

82     public boolean visitStep(ExpressionOwner owner, NodeTest step)
83     {
84         return true;
85     }
86         
87     /**
88      * Visit a predicate within a location path. Note that there isn't a
89      * proper unique component for predicates, and that the expression will
90      * be called also for whatever type Expression is.
91      *
92      * @param owner The owner of the expression, to which the expression can
93      * be reset if rewriting takes place.
94      * @param pred The predicate object.
95      * @return true if the sub expressions should be traversed.
96      */

97     public boolean visitPredicate(ExpressionOwner owner, Expression pred)
98     {
99         return true;
100     }
101
102     /**
103      * Visit a binary operation.
104      * @param owner The owner of the expression, to which the expression can
105      * be reset if rewriting takes place.
106      * @param op The operation object.
107      * @return true if the sub expressions should be traversed.
108      */

109     public boolean visitBinaryOperation(ExpressionOwner owner, Operation op)
110     {
111         return true;
112     }
113
114     /**
115      * Visit a unary operation.
116      * @param owner The owner of the expression, to which the expression can
117      * be reset if rewriting takes place.
118      * @param op The operation object.
119      * @return true if the sub expressions should be traversed.
120      */

121     public boolean visitUnaryOperation(ExpressionOwner owner, UnaryOperation op)
122     {
123         return true;
124     }
125     
126     /**
127      * Visit a variable reference.
128      * @param owner The owner of the expression, to which the expression can
129      * be reset if rewriting takes place.
130      * @param var The variable reference object.
131      * @return true if the sub expressions should be traversed.
132      */

133     public boolean visitVariableRef(ExpressionOwner owner, Variable var)
134     {
135         return true;
136     }
137
138     /**
139      * Visit a function.
140      * @param owner The owner of the expression, to which the expression can
141      * be reset if rewriting takes place.
142      * @param func The function reference object.
143      * @return true if the sub expressions should be traversed.
144      */

145     public boolean visitFunction(ExpressionOwner owner, Function func)
146     {
147         return true;
148     }
149     
150     /**
151      * Visit a match pattern.
152      * @param owner The owner of the expression, to which the expression can
153      * be reset if rewriting takes place.
154      * @param pattern The match pattern object.
155      * @return true if the sub expressions should be traversed.
156      */

157     public boolean visitMatchPattern(ExpressionOwner owner, StepPattern pattern)
158     {
159         return true;
160     }
161     
162     /**
163      * Visit a union pattern.
164      * @param owner The owner of the expression, to which the expression can
165      * be reset if rewriting takes place.
166      * @param pattern The union pattern object.
167      * @return true if the sub expressions should be traversed.
168      */

169     public boolean visitUnionPattern(ExpressionOwner owner, UnionPattern pattern)
170     {
171         return true;
172     }
173     
174     /**
175      * Visit a string literal.
176      * @param owner The owner of the expression, to which the expression can
177      * be reset if rewriting takes place.
178      * @param str The string literal object.
179      * @return true if the sub expressions should be traversed.
180      */

181     public boolean visitStringLiteral(ExpressionOwner owner, XString str)
182     {
183         return true;
184     }
185
186
187     /**
188      * Visit a number literal.
189      * @param owner The owner of the expression, to which the expression can
190      * be reset if rewriting takes place.
191      * @param num The number literal object.
192      * @return true if the sub expressions should be traversed.
193      */

194     public boolean visitNumberLiteral(ExpressionOwner owner, XNumber num)
195     {
196         return true;
197     }
198
199
200 }
201
202
Popular Tags