KickJava   Java API By Example, From Geeks To Geeks.

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


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  * 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 {
25     /** The name */
26     private String JavaDoc _name;
27
28     /**
29      * Creates a new name expression object.
30      *
31      * @param base The base expression (can be <code>null</code>)
32      * @param name The name
33      */

34     public NameExpression(Expression base, String JavaDoc name)
35     {
36         super(base);
37         _name = name;
38     }
39
40     /**
41      * Returns the name.
42      *
43      * @return The name
44      */

45     public String JavaDoc getName()
46     {
47         return _name;
48     }
49
50     /* (non-Javadoc)
51      * @see org.apache.ojb.jdo.jdoql.Acceptor#accept(org.apache.ojb.jdo.jdoql.Visitor)
52      */

53     public void accept(Visitor visitor)
54     {
55         visitor.visit(this);
56     }
57
58     /* (non-Javadoc)
59      * @see java.lang.Object#toString()
60      */

61     public String JavaDoc toString()
62     {
63         StringBuffer JavaDoc result = new StringBuffer JavaDoc();
64
65         if (_base != null)
66         {
67             result.append(_base.toString());
68             result.append(".");
69         }
70         result.append(_name);
71         return result.toString();
72     }
73
74     /* (non-Javadoc)
75      * @see org.apache.ojb.jdo.jdoql.Expression#getType()
76      */

77     public Class JavaDoc getType()
78     {
79         // No need to return something because this expression is replaced
80
// in the resolving stage
81
return null;
82     }
83 }
84
Popular Tags