KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > speedo > query > lib > SpeedoQuery


1 /**
2  * Speedo: an implementation of JDO compliant personality on top of JORM generic
3  * I/O sub-system.
4  * Copyright (C) 2001-2004 France Telecom R&D
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  *
20  *
21  *
22  * Contact: speedo@objectweb.org
23  *
24  * Authors: S.Chassande-Barrioz.
25  *
26  */

27
28 package org.objectweb.speedo.query.lib;
29
30 import org.objectweb.speedo.query.api.CompiledQuery;
31 import org.objectweb.speedo.query.api.QueryDefinition;
32 import org.objectweb.speedo.query.api.QueryManager;
33 import org.objectweb.speedo.query.lib.QueryResultList;
34 import org.objectweb.speedo.pm.api.ProxyManager;
35 import org.objectweb.util.monolog.api.BasicLevel;
36 import org.objectweb.util.monolog.api.Logger;
37
38 import javax.jdo.Extent;
39 import javax.jdo.FetchPlan;
40 import javax.jdo.JDOFatalUserException;
41 import javax.jdo.JDOUserException;
42 import javax.jdo.PersistenceManager;
43 import javax.jdo.Query;
44 import javax.jdo.JDOException;
45 import java.util.Collection JavaDoc;
46 import java.util.HashMap JavaDoc;
47 import java.util.Map JavaDoc;
48 import java.util.StringTokenizer JavaDoc;
49 import java.util.Vector JavaDoc;
50 import java.util.List JavaDoc;
51 import java.util.ArrayList JavaDoc;
52
53 /**
54  * SpeedoQuery is the basic implementation of the javax.jdo.Query interface.
55  * This class is just a wrapper to a SpeedoCompiledQuery object which is a
56  * reused object.
57  *
58  * @author S. Chassande-Barrioz
59  */

60 public class SpeedoQuery extends QueryDefinitionImpl implements Query {
61
62
63     /**
64      * The queryManager object is used to create or return a CompiledQuery
65      * object.
66      */

67     private QueryManager queryManager = null;
68
69     /**
70      * Logger for monolog.
71      */

72     private Logger logger = null;
73
74     private boolean hasChanged = true;
75
76     /**
77      * PersistenceManager which manages this query.
78      */

79     private ProxyManager pm;
80
81     private List results;
82     
83     /**
84      * sQueryCompiler is the query, this object can compile and execute the
85      * query. This object is reused in the past, or future.
86      */

87     private CompiledQuery qc = null;
88     
89     /**
90      * The fetch plan.
91      * When a Query is retrieved from a PersistenceManager, its FetchPlan is initialized to the same settings
92      * as that of the PersistenceManager.
93      * Subsequent modifications of the Query's FetchPlan are not reflected
94      * in the FetchPlan of the PersistenceManager.
95      */

96     private FetchPlan fetchPlan;
97     
98     public SpeedoQuery() {
99         super();
100         results = new ArrayList JavaDoc(1);
101     }
102
103     public void setLogger(Logger logger) {
104         this.logger = logger;
105     }
106
107     public QueryManager getQueryManager() {
108         return queryManager;
109     }
110
111     public void setQueryManager(QueryManager _qm) {
112         queryManager = _qm;
113     }
114
115     public CompiledQuery getQueryCompiler() {
116         return qc;
117     }
118
119     public void setQueryCompiler(CompiledQuery _qc) {
120         qc = _qc;
121     }
122
123     public void setProxyManager(ProxyManager _pm) {
124         pm = _pm;
125     }
126
127     // IMPLEMENTATION OF THE Query INTERFACE //
128
//---------------------------------------//
129

130     public void defineWith(QueryDefinition qd) {
131         super.defineWith(qd);
132         hasChanged = true;
133     }
134     /**
135      * Set the class of the candidate instances of the query.
136      * <P>The class specifies the class
137      * of the candidates of the query. Elements of the candidate collection
138      * that are of the specified class are filtered before being
139      * put into the result Set.
140      * @param cls the Class of the candidate instances.
141      */

142     public void setClass(Class JavaDoc cls) {
143         assertPMIsOpen();
144         assertModifiable();
145         if (candidateClass != null) hasChanged = true;
146         candidateClass = cls;
147         assertCandidateClass();
148     }
149
150     /**
151      * Set the candidate Extent to query.
152      * @param pcs the Candidate Extent.
153      */

154     public void setCandidates(Extent pcs) {
155         assertPMIsOpen();
156         if (extentClass != null) hasChanged = true;
157         extentClass = pcs;
158         assertExtentClass();
159     }
160
161     /**
162      * Set the candidate Set to query.
163      * @param pcs the Candidate collection.
164      */

165     public void setCandidates(Collection JavaDoc pcs) {
166         assertPMIsOpen();
167         assertModifiable();
168         if (candidateInstances != null) hasChanged = true;
169         candidateInstances = pcs;
170         assertCandidateInstances();
171     }
172
173     /**
174      * Set the filter for the query.
175      * <P>The filter specification is a String containing a boolean
176      * expression that is to be evaluated for each of the instances
177      * in the candidate collection. If the filter is not specified,
178      * then it defaults to "true", which has the effect of filtering
179      * the input Set only for class type.
180      * <P>An element of the candidate collection is returned in the result if:
181      * <ul><li>it is assignment compatible to the candidate Class of the Query; and
182      * <li>for all variables there exists a value for which the filter
183      * expression evaluates to true.
184      * </ul>
185      * <P>The user may denote uniqueness in the filter expression by
186      * explicitly declaring an expression (for example, e1 != e2).
187      * <P>Rules for constructing valid expressions follow the Java
188      * language, except for these differences:
189      * <ul>
190      * <li>Equality and ordering comparisons between primitives and instances
191      * of wrapper classes are valid.
192      * <li>Equality and ordering comparisons of Date fields and Date
193      * parameters are valid.
194      * <li>White space (non-printing characters space, tab, carriage
195      * return, and line feed) is a separator and is otherwise ignored.
196      * <li>The assignment operators =, +=, etc. and pre- and post-increment
197      * and -decrement are not supported. Therefore, there are no side
198      * effects from evaluation of any expressions.
199      * <li>Methods, including object construction, are not supported, except
200      * for Set.contains(Object o), Set.isEmpty(),
201      * String.startsWith (String s), and String.endsWith (String e).
202      * Implementations might choose to support non-mutating method
203      * calls as non-standard extensions.
204      * <li>Navigation through a null-valued field, which would throw
205      * NullPointerException, is treated as if the filter expression
206      * returned false for the evaluation of the current set of variable
207      * values. Other values for variables might still qualify the candidate
208      * instance for inclusion in the result set.
209      * <li>Navigation through multi-valued fields (Set types) is
210      * specified using a variable declaration and the
211      * Set.contains(Object o) method.
212      * </ul>
213      * <P>Identifiers in the expression are considered to be in the name
214      * space of the specified class, with the addition of declared imports,
215      * parameters and variables. As in the Java language, this is a reserved
216      * word which means the element of the collection being evaluated.
217      * <P>Navigation through single-valued fields is specified by the Java
218      * language syntax of field_name.field_name....field_name.
219      * <P>A JDO implementation is allowed to reorder the filter expression
220      * for optimization purposes.
221      * @param f the query filter.
222      */

223     public void setFilter(String JavaDoc f) {
224         assertPMIsOpen();
225         assertModifiable();
226         if (f == null || f.length() == 0) {
227             filter = "true";
228         } else {
229             filter = "(" + f + ")";
230             hasChanged = true;
231         }
232     }
233
234     /**
235      * Set the import statements to be used to identify the fully qualified name of
236      * variables or parameters. Parameters and unbound variables might
237      * come from a different class from the candidate class, and the names
238      * need to be declared in an import statement to eliminate ambiguity.
239      * Import statements are specified as a String with semicolon-separated
240      * statements.
241      * <P>The String parameter to this method follows the syntax of the
242      * import statement of the Java language.
243      * @param imports import statements separated by semicolons.
244      */

245     public void declareImports(String JavaDoc imports) {
246         assertPMIsOpen();
247         assertModifiable();
248         if (importStatements != null) hasChanged = true;
249         StringTokenizer JavaDoc tok = new StringTokenizer JavaDoc(imports, ";");
250         importStatements = new Vector JavaDoc();
251         while (tok.hasMoreTokens())
252             importStatements.add(tok.nextToken().trim());
253     }
254
255     /**
256      * Declare the list of parameters query execution.
257      * The parameter declaration is a String containing one or more query
258      * parameter declarations separated with commas. Each parameter named
259      * in the parameter declaration must be bound to a value when
260      * the query is executed.
261      * <P>The String parameter to this method follows the syntax for formal
262      * parameters in the Java language.
263      * @param parameters the list of parameters separated by commas.
264      */

265     public void declareParameters(String JavaDoc parameters) {
266         assertPMIsOpen();
267         assertModifiable();
268         if (this.parameters != null) {
269             hasChanged = true;
270         }
271         this.parameters = parameters;
272         assertParameters();
273     }
274
275     /**
276      * Declare the unbound variables to be used in the query. Variables
277      * might be used in the filter, and these variables must be declared
278      * with their type. The unbound variable declaration is a String
279      * containing one or more unbound variable declarations separated
280      * with semicolons. It follows the syntax for local variables in
281      * the Java language.
282      * @param variables the variables separated by semicolons.
283      */

284     public void declareVariables(String JavaDoc variables) {
285         assertPMIsOpen();
286         assertModifiable();
287         if (this.variables != null) hasChanged = true;
288         this.variables = variables;
289         assertVariables();
290     }
291
292     /**
293      * Set the ordering specification for the result Set. The
294      * ordering specification is a String containing one or more ordering
295      * declarations separated by commas.
296      *
297      * <P>Each ordering declaration is the name of the field on which
298      * to order the results followed by one of the following words:
299      * "ascending" or "descending".
300      *
301      *<P>The field must be declared in the candidate class or must be
302      * a navigation expression starting with a field in the candidate class.
303      *
304      *<P>Valid field types are primitive types except boolean; wrapper types
305      * except Boolean; BigDecimal; BigInteger; String; and Date.
306      * @param ordering the ordering specification.
307      */

308     public void setOrdering(String JavaDoc ordering) {
309         assertPMIsOpen();
310         assertModifiable();
311         if (order != null) hasChanged = true;
312         StringTokenizer JavaDoc tok = new StringTokenizer JavaDoc(ordering, ",");
313         order = new ArrayList JavaDoc();
314         while (tok.hasMoreTokens())
315             order.add(tok.nextToken().trim());
316     }
317
318     /**
319      * Set the ignoreCache option. The default value for this option was
320      * set by the PersistenceManagerFactory or the PersistenceManager used
321      * to create this Query.
322      *
323      * The ignoreCache option setting specifies whether the query should execute
324      * entirely in the back end, instead of in the cache. If this flag is set
325      * to true, an implementation might be able to optimize the query
326      * execution by ignoring changed values in the cache. For optimistic
327      * transactions, this can dramatically improve query response times.
328      * @param ignoreCache the setting of the ignoreCache option.
329      */

330     public void setIgnoreCache(boolean ignoreCache) {
331         assertPMIsOpen();
332         assertModifiable();
333         this.ignoreCache = ignoreCache;
334     }
335
336     /**
337      * Get the ignoreCache option setting.
338      * @return the ignoreCache option setting.
339      * @see #setIgnoreCache
340      */

341     public boolean getIgnoreCache() {
342         assertPMIsOpen();
343         return ignoreCache;
344     }
345
346     public void setIncludeSubClasses(boolean val) {
347         assertModifiable();
348         includeSubClasses = val;
349     }
350     
351     /**
352      * Verify the elements of the query and provide a hint to
353      * the query to prepare and optimize an execution plan.
354      */

355     public void compile() {
356         // build a CompiledQuery object with the current object.
357
// if the object already exists, it is returned
358
qc = queryManager.getQueryCompiler(this);
359
360         // compile the CompiledQuery object
361
try {
362             qc.compile();
363         } catch (Exception JavaDoc e) {
364             throw new JDOException("Impossible to compile a query ", e);
365         }
366         hasChanged = false;
367     }
368
369     private void treatSpeedoHints(Map JavaDoc parameterValues) {
370         String JavaDoc speedoHints = (String JavaDoc) parameterValues.get("SPEEDO_HINTS");
371         if (speedoHints != null) {
372             treatSpeedoHints(speedoHints);
373         }
374     }
375     
376     private void treatSpeedoHints(Object JavaDoc[] parameterValues) {
377         StringTokenizer JavaDoc st = new StringTokenizer JavaDoc(parameters, ",", false);
378         int speedoHintsIndex = -1;
379         int tokenIndex = 0;
380         while(speedoHintsIndex < 0 && st.hasMoreTokens()) {
381             String JavaDoc token = st.nextToken();
382             if (parameters.indexOf("SPEEDO_HINTS") > -1) {
383                 speedoHintsIndex = tokenIndex;
384             }
385             tokenIndex++;
386         }
387         if (speedoHintsIndex >= 0) {
388             treatSpeedoHints((String JavaDoc) parameterValues[speedoHintsIndex]);
389         }
390     }
391     
392     private void treatSpeedoHints(String JavaDoc speedoHints) {
393         StringTokenizer JavaDoc st = new StringTokenizer JavaDoc(speedoHints, ",", false);
394         while(st.hasMoreTokens()) {
395             String JavaDoc token = st.nextToken();
396             if (token.equalsIgnoreCase("prefetch")) {
397                 if (!withPrefetch) {
398                     withPrefetch = true;
399                     hasChanged = true;
400                 }
401             } else if (token.equalsIgnoreCase("noprefetch")) {
402                 if (withPrefetch) {
403                     withPrefetch = false;
404                     hasChanged = true;
405                 }
406             //} else if (token.equalsIgnoreCase("list")) {
407

408             }
409         }
410         
411     }
412     
413     /**
414      * Execute the query and return the filtered Set.
415      * @return the filtered Set.
416      * @see #executeWithArray(java.lang.Object[] parameters)
417      */

418     public Object JavaDoc execute() {
419         Object JavaDoc[] params = new Object JavaDoc[0];
420         beforeExecute(params);
421         try {
422             Object JavaDoc res = qc.execute(params, pm, this);
423             if (!unique) {
424                 results.add(res);
425             }
426             return res;
427         } catch (JDOException e) {
428             throw e;
429         } catch (Exception JavaDoc e) {
430             logger.log(BasicLevel.ERROR, "execute failed", e);
431             throw new JDOException("Impossible to execute a query ", e);
432         }
433     }
434
435     /**
436      * Execute the query and return the filtered Set.
437      * @return the filtered Set.
438      * @see #executeWithArray(java.lang.Object[] parameters)
439      * @param p1 the value of the first parameter declared.
440      */

441     public Object JavaDoc execute(Object JavaDoc p1) {
442         Object JavaDoc[] params = new Object JavaDoc[]{p1};
443         beforeExecute(params);
444         try {
445             Object JavaDoc res = qc.execute(params, pm, this);
446             if (!unique) {
447                 results.add(res);
448             }
449             return res;
450         } catch (JDOException e) {
451             throw e;
452         } catch (Exception JavaDoc e) {
453             logger.log(BasicLevel.ERROR, "execute failed", e);
454             throw new JDOException("Impossible to execute a query ", e);
455         }
456     }
457
458     /**
459      * Execute the query and return the filtered Set.
460      * @return the filtered Set.
461      * @see #executeWithArray(java.lang.Object[] parameters)
462      * @param p1 the value of the first parameter declared.
463      * @param p2 the value of the second parameter declared.
464      */

465     public Object JavaDoc execute(Object JavaDoc p1, Object JavaDoc p2) {
466         Object JavaDoc[] params = new Object JavaDoc[]{p1, p2};
467         beforeExecute(params);
468         try {
469             Object JavaDoc res = qc.execute(params, pm, this);
470             if (!unique) {
471                 results.add(res);
472             }
473             return res;
474         } catch (JDOException e) {
475             throw e;
476         } catch (Exception JavaDoc e) {
477             logger.log(BasicLevel.ERROR, "execute failed", e);
478             throw new JDOException("Impossible to execute a query ", e);
479         }
480     }
481
482     /**
483      * Execute the query and return the filtered Set.
484      * @return the filtered Set.
485      * @see #executeWithArray(java.lang.Object[] parameters)
486      * @param p1 the value of the first parameter declared.
487      * @param p2 the value of the second parameter declared.
488      * @param p3 the value of the third parameter declared.
489      */

490     public Object JavaDoc execute(Object JavaDoc p1, Object JavaDoc p2, Object JavaDoc p3) {
491         Object JavaDoc[] params = new Object JavaDoc[]{p1, p2, p3};
492         beforeExecute(params);
493         try {
494             Object JavaDoc res = qc.execute(params, pm, this);
495             if (!unique) {
496                 results.add(res);
497             }
498             return res;
499         } catch (JDOException e) {
500             throw e;
501         } catch (Exception JavaDoc e) {
502             logger.log(BasicLevel.ERROR, "execute failed", e);
503             throw new JDOException("Impossible to execute a query ", e);
504         }
505     }
506
507     /**
508      * Execute the query and return the filtered Set.
509      * The query is executed with the parameters set by the Map values. Each
510      * Map entry consists of a key which is the name of the parameter in the
511      * declareParameters method, and a value which is the value used in
512      * the execute method. The keys in the Map and the declared parameters
513      * must exactly match or a JDOUserException is thrown.
514      * @return the filtered Set.
515      * @see #executeWithArray(java.lang.Object[] parameters)
516      * @param amap the Map containing all of the parameters.
517      */

518     public Object JavaDoc executeWithMap(Map JavaDoc amap) {
519         beforeExecute(amap);
520         try {
521             Object JavaDoc res = qc.execute(amap, pm, this);
522             if (!unique) {
523                 results.add(res);
524             }
525             return res;
526         } catch (JDOException e) {
527             throw e;
528         } catch (Exception JavaDoc e) {
529             logger.log(BasicLevel.ERROR, "execute failed", e);
530             throw new JDOException("Impossible to execute a query ", e);
531         }
532     }
533
534     /**
535      * Execute the query and return the filtered Set.
536      * <P>The execution of the query obtains the values of the parameters and
537      * matches them against the declared parameters in order. The names
538      * of the declared parameters are ignored. The type of
539      * the declared parameters must match the type of the passed parameters,
540      * except that the passed parameters might need to be unwrapped to get
541      * their primitive values.
542      *
543      * <P>The filter, import, declared parameters, declared variables, and
544      * ordering statements are verified for consistency.
545      *
546      * <P>Each element in the candidate Set is examined to see that it
547      * is assignment compatible to the Class of the query. It is then evaluated
548      * by the boolean expression of the filter. The element passes the filter
549      * if there exist unique values for all variables for which the filter
550      * expression evaluates to true.
551      * @return the filtered Set.
552      * @param anarray the Object array with all of the parameters.
553      */

554     public Object JavaDoc executeWithArray(Object JavaDoc[] anarray) {
555         beforeExecute(anarray);
556         try {
557             Object JavaDoc res = qc.execute(anarray, pm, this);
558             if (!unique) {
559                 results.add(res);
560             }
561             return res;
562         } catch (JDOException e) {
563             throw e;
564         } catch (Exception JavaDoc e) {
565             logger.log(BasicLevel.ERROR, "execute failed", e);
566             throw new JDOException("Impossible to execute a query ", e);
567         }
568     }
569
570     /**
571      * Get the PersistenceManager associated with this Query.
572      * <P>If this Query was restored from a serialized form, it has no
573      * PersistenceManager, and this method returns null.
574      * @return the PersistenceManager associated with this Query.
575      */

576     public PersistenceManager getPersistenceManager() {
577         return pm;
578     }
579
580     /**
581      * Close a query result and release any resources
582      * associated with it. The parameter is the return from execute(...) and
583      * might have iterators open on it. Iterators associated with the query
584      * result are invalidated: they return false to hasNext() and throw
585      * NoSuchElementException to next().
586      *
587      * This method makes nothing, all is done by the SpeedoCompiledQuery
588      * object. This object is never closed, and could be reused in the
589      * future.
590      *
591      * @param queryResult the result of execute(...) on this Query instance.
592      */

593     public void close(Object JavaDoc queryResult) {
594         if (queryResult instanceof QueryResultList) {
595             ((QueryResultList) queryResult).close();
596             int i=0;
597             while(i < results.size() && results.get(i) != queryResult) {
598                 i++;
599             }
600             if (i < results.size()) {
601                 results.remove(i);
602             }
603         }
604     }
605
606     /**
607      * Close all query results associated with this Query
608      * instance, and release all resources associated with them. The query
609      * results might have iterators open on them. Iterators associated with the
610      * query results are invalidated: they return false to hasNext() and throw
611      * NoSuchElementException to next().
612      */

613     public void closeAll() {
614         for(int i=0; i<results.size(); i++) {
615             Object JavaDoc queryResult = results.get(i);
616             if (queryResult instanceof QueryResultList) {
617                 ((QueryResultList) queryResult).close();
618             }
619         }
620         results.clear();
621     }
622
623     public FetchPlan getFetchPlan(){
624         return fetchPlan;
625     }
626     
627     public void setFetchPlan(FetchPlan fp){
628         assertModifiable();
629         fetchPlan = fp;
630     }
631     
632     public long deletePersistentAll() {
633         //TODO: implements deletePersistentAll
634
throw new JDOException("delete by query are not supported currently");
635     }
636
637     public long deletePersistentAll(Map JavaDoc arg0) {
638         //TODO: implements deletePersistentAll
639
throw new JDOException("delete by query are not supported currently");
640     }
641
642     public long deletePersistentAll(Object JavaDoc[] arg0) {
643         //TODO: implements deletePersistentAll
644
throw new JDOException("delete by query are not supported currently");
645     }
646
647     public void setGrouping(String JavaDoc arg0) {
648         assertModifiable();
649         this.grouping = arg0;
650     }
651
652     public void setRange(long first, long last) {
653         assertModifiable();
654         indexFirst = first;
655         indexLast = last;
656     }
657     
658     public void setUnique(boolean unique) {
659         assertModifiable();
660         this.unique = unique;
661     }
662
663     public void setResult(String JavaDoc result) {
664         assertModifiable();
665         this.result = result;
666     }
667
668     public void setResultClass(Class JavaDoc resultClass) {
669         assertModifiable();
670         this.resultClass = resultClass;
671     }
672
673     public Map JavaDoc extensions = null;
674
675     public void setExtensions(Map JavaDoc exts) {
676         assertModifiable();
677         this.extensions = exts;
678     }
679     public void addExtension(String JavaDoc key, Object JavaDoc value) {
680         assertModifiable();
681         if (extensions == null) {
682             if (value == null) {
683                 return;
684             }
685             extensions = new HashMap JavaDoc();
686         }
687         if (value == null) {
688             extensions.remove(key);
689         } else {
690             extensions.put(key, value);
691         }
692     }
693
694     boolean modifiable = true;
695     
696     public boolean isUnmodifiable() {
697         return modifiable;
698     }
699     public void setUnmodifiable() {
700         modifiable = false;
701     }
702
703     // PRIVATE METHODS //
704
//-----------------//
705

706     private void beforeExecute(Object JavaDoc[] parameterValues) {
707         if (parameters != null && parameterValues.length == 0 && parameters.length()>0)
708             throw new JDOUserException(
709                     "Parameters in not null, and you try to execute without parameters");
710         if (pm.isClosed())
711             throw new JDOFatalUserException(
712                     "Impossible to use the query: the persistent manager is closed.");
713         if (parameterValues != null && parameters != null) {
714             treatSpeedoHints(parameterValues);
715         }
716         if (hasChanged) {
717             compile();
718         }
719     }
720
721     private void beforeExecute(Map JavaDoc parameterValues) {
722         if (parameters != null && parameterValues.size() == 0 && parameters.length()>0)
723             throw new JDOUserException(
724                     "Parameters in not null, and you try to execute without parameters");
725         if (pm.isClosed())
726             throw new JDOFatalUserException(
727                     "Impossible to use the query: the persistent manager is closed.");
728         if (parameterValues != null) {
729             treatSpeedoHints(parameterValues);
730         }
731         if (hasChanged) {
732             compile();
733         }
734     }
735
736     private void assertPMIsOpen() {
737         if (pm.isClosed())
738             throw new JDOUserException("The persistence manager is closed.");
739     }
740
741     private void assertModifiable() {
742         if (!modifiable)
743             throw new JDOUserException("The query has been marked as not modifiable.");
744     }
745     
746     private void assertParameters() {
747         if (parameters == null)
748             throw new JDOUserException("Parameters string can not be null");
749     }
750
751     private void assertVariables() {
752         if (variables == null)
753             throw new JDOUserException("variables string can not be null");
754     }
755
756     private void assertCandidateClass() {
757         if (candidateClass == null)
758             throw new JDOUserException("candidate class can not be null");
759     }
760
761     private void assertExtentClass() {
762         if (extentClass == null)
763             throw new JDOUserException("Extent class can not be null");
764     }
765
766     private void assertCandidateInstances() {
767         if (candidateInstances == null)
768             throw new JDOUserException("candidate Collection can not be null");
769     }
770 }
771
Popular Tags