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: * A name expression which can mean an access to a variable/field or to a type.
20: *
21: * @author <a href="mailto:tomdz@apache.org">Thomas Dudziak</a>
22: */
23: public class NameExpression extends PostfixExpression {
24: /** The name */
25: private String _name;
26:
27: /**
28: * Creates a new name expression object.
29: *
30: * @param base The base expression (can be <code>null</code>)
31: * @param name The name
32: */
33: public NameExpression(Expression base, String name) {
34: super (base);
35: _name = name;
36: }
37:
38: /**
39: * Returns the name.
40: *
41: * @return The name
42: */
43: public String getName() {
44: return _name;
45: }
46:
47: /* (non-Javadoc)
48: * @see org.apache.ojb.jdo.jdoql.Acceptor#accept(org.apache.ojb.jdo.jdoql.Visitor)
49: */
50: public void accept(Visitor visitor) {
51: visitor.visit(this );
52: }
53:
54: /* (non-Javadoc)
55: * @see java.lang.Object#toString()
56: */
57: public String toString() {
58: StringBuffer result = new StringBuffer();
59:
60: if (_base != null) {
61: result.append(_base.toString());
62: result.append(".");
63: }
64: result.append(_name);
65: return result.toString();
66: }
67:
68: /* (non-Javadoc)
69: * @see org.apache.ojb.jdo.jdoql.Expression#getType()
70: */
71: public Class getType() {
72: // No need to return something because this expression is replaced
73: // in the resolving stage
74: return null;
75: }
76: }
|