01: package org.apache.ojb.jdo.jdoql;
02:
03: /* Copyright 2003-2005 The Apache Software Foundation
04: *
05: * Licensed under the Apache License, Version 2.0 (the "License");
06: * you may not use this file except in compliance with the License.
07: * You may obtain a copy of the License at
08: *
09: * 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: /** The base expression (can be <code>null</code>) */
26: protected Expression _base;
27:
28: /**
29: * Creates a new postfix expression. This constructor is intended to be called
30: * from subclass' constructors.
31: *
32: * @param base The base expression (can be <code>null</code>)
33: */
34: public PostfixExpression(Expression base) {
35: _base = base;
36: }
37:
38: /**
39: * Determines whether this postfix expression has a base expression.
40: *
41: * @return <code>true</code> if it has a base expression
42: */
43: public boolean hasBaseExpression() {
44: return _base != null;
45: }
46:
47: /**
48: * Returns the base expression.
49: *
50: * @return The base expression (can be <code>null</code>)
51: */
52: public Expression getBaseExpression() {
53: return _base;
54: }
55:
56: /**
57: * Sets the base expression.
58: *
59: * @param base The base expression (can be <code>null</code>)
60: */
61: public void setBaseExpression(Expression base) {
62: if (_base != null) {
63: _base.setParent(null);
64: }
65: _base = base;
66: if (_base != null) {
67: _base.setParent(this );
68: }
69: }
70:
71: /* (non-Javadoc)
72: * @see org.apache.ojb.jdo.jdoql.Expression#replaceChild(org.apache.ojb.jdo.jdoql.Expression, org.apache.ojb.jdo.jdoql.Expression)
73: */
74: public void replaceChild(Expression oldChild, Expression newChild) {
75: setBaseExpression(newChild);
76: }
77: }
|