KickJava   Java API By Example, From Geeks To Geeks.

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


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  * Specifies an expression that can follow another expression (e.g. in a.b the
20  * field access to b follows the field access to a).
21  *
22  * @author <a HREF="mailto:tomdz@apache.org">Thomas Dudziak</a>
23  */

24 public abstract class PostfixExpression extends Expression
25 {
26     /** The base expression (can be <code>null</code>) */
27     protected Expression _base;
28
29     /**
30      * Creates a new postfix expression. This constructor is intended to be called
31      * from subclass' constructors.
32      *
33      * @param base The base expression (can be <code>null</code>)
34      */

35     public PostfixExpression(Expression base)
36     {
37         _base = base;
38     }
39     
40     /**
41      * Determines whether this postfix expression has a base expression.
42      *
43      * @return <code>true</code> if it has a base expression
44      */

45     public boolean hasBaseExpression()
46     {
47         return _base != null;
48     }
49
50     /**
51      * Returns the base expression.
52      *
53      * @return The base expression (can be <code>null</code>)
54      */

55     public Expression getBaseExpression()
56     {
57         return _base;
58     }
59
60     /**
61      * Sets the base expression.
62      *
63      * @param base The base expression (can be <code>null</code>)
64      */

65     public void setBaseExpression(Expression base)
66     {
67         if (_base != null)
68         {
69             _base.setParent(null);
70         }
71         _base = base;
72         if (_base != null)
73         {
74             _base.setParent(this);
75         }
76     }
77
78     /* (non-Javadoc)
79      * @see org.apache.ojb.jdo.jdoql.Expression#replaceChild(org.apache.ojb.jdo.jdoql.Expression, org.apache.ojb.jdo.jdoql.Expression)
80      */

81     public void replaceChild(Expression oldChild, Expression newChild)
82     {
83         setBaseExpression(newChild);
84     }
85 }
86
Popular Tags