KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > jdo > spi > persistence > support > ejb > ejbqlc > JDOQLElements


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 in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
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 Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24
25
26 /*
27  * JDOQLElements.java
28  *
29  * Created on November 12, 2001
30  */

31
32 package com.sun.jdo.spi.persistence.support.ejb.ejbqlc;
33
34 import java.util.Properties JavaDoc;
35 import java.util.Map JavaDoc;
36 import java.util.HashMap JavaDoc;
37 import java.util.Iterator JavaDoc;
38 import java.io.File JavaDoc;
39 import java.io.FileInputStream JavaDoc;
40 import java.io.BufferedInputStream JavaDoc;
41 import java.io.IOException JavaDoc;
42 import java.io.FileOutputStream JavaDoc;
43 import java.io.BufferedOutputStream JavaDoc;
44
45 /**
46  * An JDOQLElements instance represents the result of the EJBQLC compile step.
47  *
48  * @author Michael Bouschen
49  * @author Shing Wai Chan
50  */

51 public class JDOQLElements
52 {
53     /** The name of the candidate class */
54     private String JavaDoc candidateClassName;
55
56     /** The parameter declarations string. */
57     private String JavaDoc parameters;
58
59     /** The variable declarations string. */
60     private String JavaDoc variables;
61
62     /** The filter expression string. */
63     private String JavaDoc filter;
64
65     /** The ordering expression string. */
66     private String JavaDoc ordering;
67
68     /** The result expression. */
69     private String JavaDoc result;
70
71     /** The result type. */
72     private String JavaDoc resultType;
73
74     /** Flag indicating whether the result element is of a pc class. */
75     private boolean isPCResult;
76
77     /**
78      * Flag indicating whether the result element is associated to an
79      * aggregate function.
80      */

81     private boolean isAggregate;
82
83     /** String array contains ejb names corresponding to parameters */
84     private String JavaDoc[] parameterEjbNames;
85
86     /**
87      * Constructor taking JDOQL elements.
88      */

89     public JDOQLElements(String JavaDoc candidateClassName,
90                          String JavaDoc parameters,
91                          String JavaDoc variables,
92                          String JavaDoc filter,
93                          String JavaDoc ordering,
94                          String JavaDoc result,
95                          String JavaDoc resultType,
96                          boolean isPCResult,
97                          boolean isAggregate,
98                          String JavaDoc[] parameterEjbNames)
99     {
100         setCandidateClassName(candidateClassName);
101         setParameters(parameters);
102         setVariables(variables);
103         setFilter(filter);
104         setOrdering(ordering);
105         setResult(result);
106         setResultType(resultType);
107         setPCResult(isPCResult);
108         setAggregate(isAggregate);
109         setParameterEjbNames(parameterEjbNames);
110     }
111
112     /** Returns the fully qulified name of the candidate class. */
113     public String JavaDoc getCandidateClassName()
114     {
115         return this.candidateClassName;
116     }
117
118     /** Sets the fully qulified name of the candidate class. */
119     public void setCandidateClassName(String JavaDoc candidateClassName)
120     {
121         // TBD: check non empty candidateClassName
122
this.candidateClassName = candidateClassName;
123     }
124
125     /** Returns the parameter declaration string. */
126     public String JavaDoc getParameters()
127     {
128         return parameters;
129     }
130
131     /** Sets the parameter declarations string. */
132     public void setParameters(String JavaDoc parameters)
133     {
134         this.parameters = (parameters == null) ? "" : parameters; //NOI18N
135
}
136
137     /** Returns the variable declarations string. */
138     public String JavaDoc getVariables()
139     {
140         return variables;
141     }
142
143     /** Sets the variable declarations string. */
144     public void setVariables(String JavaDoc variables)
145     {
146         this.variables = (variables == null) ? "" : variables; //NOI18N
147
}
148
149     /** Returns the filter expression. */
150     public String JavaDoc getFilter()
151     {
152         return filter;
153     }
154
155     /** Sets the filter expression. */
156     public void setFilter(String JavaDoc filter)
157     {
158         this.filter = (filter == null) ? "" : filter; //NOI18N
159
}
160
161     /** Returns the ordering expression. */
162     public String JavaDoc getOrdering()
163     {
164         return ordering;
165     }
166
167     /** Sets the ordering expression. */
168     public void setOrdering(String JavaDoc ordering)
169     {
170         this.ordering = (ordering == null) ? "" : ordering; //NOI18N
171
}
172
173     /** Returns the result expression. */
174     public String JavaDoc getResult()
175     {
176         return result;
177     }
178
179     /** Sets the result expression. */
180     public void setResult(String JavaDoc result)
181     {
182         this.result = (result == null) ? "" : result; //NOI18N
183
}
184
185     /**
186      * Returns the result type. The result type is the name of the element type
187      * of the JDO query result set.
188      */

189     public String JavaDoc getResultType()
190     {
191         return resultType;
192     }
193
194     /**
195      * Sets the result type. The result type is the name of the element type
196      * of the JDO query result set.
197      */

198     public void setResultType(String JavaDoc resultType)
199     {
200         this.resultType = resultType;
201     }
202
203     /**
204      * Returns whether the result of the JDOQL query is a collection of pc
205      * instances or not.
206      */

207     public boolean isPCResult()
208     {
209         return isPCResult;
210     }
211
212     /**
213      * Sets whether the result of the JDOQL query is a collection of pc
214      * instances or not.
215      */

216     public void setPCResult(boolean isPCResult)
217     {
218         this.isPCResult = isPCResult;
219     }
220
221     /**
222      * Returns whether the result of the JDOQL query is associated to
223      * an aggregate function.
224      */

225     public boolean isAggregate()
226     {
227         return isAggregate;
228     }
229
230     /**
231      * Sets whether the result of the JDOQL query is a associated to
232      * an aggregate function.
233      */

234     public void setAggregate(boolean isAggregate)
235     {
236         this.isAggregate = isAggregate;
237     }
238
239     /**
240      * Returns parameterEjbNames array
241      */

242     public String JavaDoc[] getParameterEjbNames()
243     {
244         return parameterEjbNames;
245     }
246
247     /**
248      * set parameterEjbNames array
249      */

250     public void setParameterEjbNames(String JavaDoc[] parameterEjbNames)
251     {
252         this.parameterEjbNames = parameterEjbNames;
253     }
254
255     /** Returns a string representation of this JDOQLElements instance. */
256     public String JavaDoc toString()
257     {
258         StringBuffer JavaDoc repr = new StringBuffer JavaDoc();
259         repr.append("JDOQLElements("); //NOI18N
260
repr.append("candidateClass: "); //NOI18N
261
repr.append(candidateClassName);
262         if (parameters != null && parameters.length() > 0) {
263             repr.append(", parameters: "); //NOI18N
264
repr.append(parameters);
265         }
266         if (variables != null && variables.length() > 0) {
267             repr.append(", variables: "); //NOI18N
268
repr.append(variables);
269         }
270         if (filter != null && filter.length() > 0) {
271             repr.append(", filter: "); //NOI18N
272
repr.append(filter);
273         }
274         if (ordering != null && ordering.length() > 0) {
275             repr.append(", ordering: "); //NOI18N
276
repr.append(ordering);
277         }
278         if (result != null && result.length() > 0) {
279             repr.append(", result: "); //NOI18N
280
repr.append(result);
281             repr.append(", resultType: "); //NOI18N
282
repr.append(resultType);
283             repr.append(", isPCResult: "); //NOI18N
284
repr.append(isPCResult);
285         }
286         repr.append(", isAggregate: ");
287         repr.append(isAggregate);
288         if (parameterEjbNames != null && parameterEjbNames.length > 0) {
289             repr.append(", parameterEjbNames: "); //NOI18N
290
for (int i = 0; i < parameterEjbNames.length; i++) {
291                 repr.append(i);
292                 repr.append(": ");
293                 repr.append(parameterEjbNames[i]);
294                 repr.append(", ");
295             }
296         }
297         repr.append(")"); //NOI18N
298
return repr.toString();
299     }
300 }
301
Popular Tags