KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > oracle > toplink > essentials > internal > parsing > ParameterNode


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the "License"). You may not use this file except
5  * in compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * glassfish/bootstrap/legal/CDDLv1.0.txt or
9  * https://glassfish.dev.java.net/public/CDDLv1.0.html.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * HEADER in each file and include the License file at
15  * glassfish/bootstrap/legal/CDDLv1.0.txt. If applicable,
16  * add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your
18  * own identifying information: Portions Copyright [yyyy]
19  * [name of copyright owner]
20  */

21 // Copyright (c) 1998, 2006, Oracle. All rights reserved.
22
package oracle.toplink.essentials.internal.parsing;
23
24 import oracle.toplink.essentials.expressions.*;
25
26 /**
27  * INTERNAL
28  * <p><b>Purpose</b>: This node represnts a Parameter (?1) in an EJBQL
29  * <p><b>Responsibilities</b>:<ul>
30  * <li> Generate the correct expression for an AND in EJBQL
31  * <li> Maintain a
32  * <li>
33  * </ul>
34  * @author Jon Driscoll and Joel Lucuik
35  * @since TopLink 4.0
36  */

37 public class ParameterNode extends Node {
38
39     /** */
40     private String JavaDoc name;
41
42     /**
43      * Return a new ParameterNode.
44      */

45     public ParameterNode() {
46         super();
47     }
48
49     /**
50      * INTERNAL
51      * Create a new ParameterNode with the passed string.
52      * @param newVariableName java.lang.String
53      */

54     public ParameterNode(String JavaDoc newParameterName) {
55         setParameterName(newParameterName);
56     }
57
58     /**
59      * INTERNAL
60      */

61     public void validateParameter(ParseTreeContext context, Object JavaDoc contextType) {
62         context.defineParameterType(name, contextType);
63         setType(context.getParameterType(name));
64     }
65
66     /** */
67     public Expression generateExpression(GenerationContext context) {
68         //create builder, and add
69
Class JavaDoc baseClass = context.getBaseQueryClass();
70         ExpressionBuilder builder = new ExpressionBuilder(baseClass);
71         Expression whereClause = builder.getParameter(getParameterName(), getType());
72         return whereClause;
73     }
74
75     /**
76      * INTERNAL
77      * Return the parameterName
78      *
79      */

80     public String JavaDoc getAsString() {
81         return getParameterName();
82     }
83
84     /**
85      * INTERNAL
86      * Return the parameter name
87      */

88     public String JavaDoc getParameterName() {
89         return name;
90     }
91
92     /** */
93     public void setParameterName(String JavaDoc name) {
94         this.name = name;
95     }
96
97     /**
98      * INTERNAL
99      * Yes this is a Parameter node
100      */

101     public boolean isParameterNode() {
102         return true;
103     }
104
105 }
106
Popular Tags