KickJava   Java API By Example, From Geeks To Geeks.

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


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 /**
19  * Common base class for all JDOQL expressions.
20  *
21  * @author <a HREF="mailto:tomdz@apache.org">Thomas Dudziak</a>
22  */

23 public abstract class Expression extends QueryTreeNode
24 {
25     /** The parent expression if any */
26     private Expression _parent;
27
28     /**
29      * Determines whether this expression has a parent expression
30      * (i.e. an expression where this expression is an inner or base expression).
31      *
32      * @return <code>true</code> if this expression has a parent expression
33      */

34     public boolean hasParent()
35     {
36         return _parent != null;
37     }
38
39     /**
40      * Returns the parent expression of this expression if it exists.
41      *
42      * @return The parent expression or <code>null</code> if this expression
43      * has no parent
44      */

45     public Expression getParent()
46     {
47         return _parent;
48     }
49
50     /**
51      * Sets the parent expression of this expression. Note that this method
52      * does not remove this expression from the parent.
53      *
54      * @param parent The new parent expression
55      */

56     public void setParent(Expression parent)
57     {
58         _parent = parent;
59     }
60
61     /**
62      * Replaces the given old child expression with the new one. This also sets this
63      * expression as the parent of the new child and removes it from the old child.
64      *
65      * @param oldChild The old child to be replaced
66      * @param newChild The new child
67      */

68     public void replaceChild(Expression oldChild, Expression newChild)
69     {}
70
71     /**
72      * Returns the type of this expression. Note that in the case of primitives,
73      * the type only declares the general kind, not the actual data type. For instance,
74      * a literal of type {@link Long} can be a <code>byte</code>, <code>short</code>,
75      * <code>int</code>, <code>long</code>, or {@link java.math.BigInteger} value.
76      *
77      * @return The type
78      */

79     public abstract Class JavaDoc getType();
80 }
81
Popular Tags