Hi,
attached you find the patch file (rio.path) containing the changes described below. Please execute "patch -E -p0 < rio.patch" to apply the patch to your workspace. Parameter "-E" will remove empty files.
If you decide to checkin the patch, please make sure that you add/remove the files of the patch in subversion:
- "svn add src/java/org/apache/jdo/query"
- "svn remove src/java/org/apache/jdo/jdoql/Bundle.properties src/java/org/apache/jdo/jdoql/QueryResultHelper.java src/java/org/apache/jdo/jdoql/QueryResult.java src/java/org/apache/jdo/jdoql/BasicQueryResult.java src/java/org/apache/jdo/jdoql/QueryResultIterator.java"
Regards, Michael
Hi,
I encountered an additional dependency (which I have missed before) from r11 runtime to r11 query: org.apache.jdo.store.StoreManager and org.apache.jdo.store.StoreManagerImpl use QueryResult, and QueryResultHelper, BasicQueryResult.
Breaking out r11 into core20, enhancer20, runtime20, query20, and fostore20 as decided means that we would have circular dependencies between query20 and runtime20.
Preventing these circular dependencies in XXX20 projects I have the following proposal:
1) Repackaging of the following classes, interfaces, and resources in r11:
org.apache.jdo.jdoql.QueryResult -> org.apache.jdo.query.QueryResult org.apache.jdo.jdoql.QueryResultHelper -> org.apache.jdo.query.QueryResultHelper org.apache.jdo.jdoql.QueryResultIterator -> org.apache.jdo.query.QueryResultIterator org.apache.jdo.jdoql.BasicQueryResult -> org.apache.jdo.query.BasicQueryResult org/apache/jdo/jdoql/Bundle.properties -> org/apache/jdo/query/Bundle.properties
2) At the time we break out r11 into XXX20 projects we assign package org.apache.jdo.query (and all of its classes/interfaces/resources) to runtime20.
If you do not have any objections, I'll send the "svn diff" on Monday.
Thanks, Michael
-- ------------------------------------------------------------------- Michael Watzek [EMAIL PROTECTED] Engineering GmbH mailto:[EMAIL PROTECTED] Buelowstr. 66 Tel.: ++49/30/235 520 36 10783 Berlin - Germany Fax.: ++49/30/217 520 12 http://www.spree.de/ -------------------------------------------------------------------
Index: src/java/org/apache/jdo/impl/fostore/FOStoreStoreManager.java =================================================================== --- src/java/org/apache/jdo/impl/fostore/FOStoreStoreManager.java (revision 170604) +++ src/java/org/apache/jdo/impl/fostore/FOStoreStoreManager.java (working copy) @@ -40,12 +40,12 @@ import org.apache.commons.logging.LogFactory; import org.apache.jdo.impl.model.java.runtime.RuntimeJavaModelFactory; -import org.apache.jdo.jdoql.BasicQueryResult; -import org.apache.jdo.jdoql.QueryResult; -import org.apache.jdo.jdoql.QueryResultHelper; import org.apache.jdo.model.jdo.JDOClass; import org.apache.jdo.model.jdo.JDOIdentityType; import org.apache.jdo.pm.PersistenceManagerInternal; +import org.apache.jdo.query.BasicQueryResult; +import org.apache.jdo.query.QueryResult; +import org.apache.jdo.query.QueryResultHelper; import org.apache.jdo.state.StateManagerInternal; import org.apache.jdo.store.Connector; import org.apache.jdo.store.StoreManagerImpl; Index: src/java/org/apache/jdo/impl/jdoql/QueryResultHelperImpl.java =================================================================== --- src/java/org/apache/jdo/impl/jdoql/QueryResultHelperImpl.java (revision 170604) +++ src/java/org/apache/jdo/impl/jdoql/QueryResultHelperImpl.java (working copy) @@ -35,12 +35,12 @@ import org.apache.jdo.impl.jdoql.jdoqlc.JDOQLAST; import org.apache.jdo.impl.jdoql.scope.ParameterTable; import org.apache.jdo.impl.jdoql.scope.VariableTable; -import org.apache.jdo.jdoql.QueryResultHelper; import org.apache.jdo.jdoql.tree.Expression; import org.apache.jdo.jdoql.tree.QueryTree; import org.apache.jdo.jdoql.tree.TreeWalker; import org.apache.jdo.jdoql.tree.ValueTable; import org.apache.jdo.pm.PersistenceManagerInternal; +import org.apache.jdo.query.QueryResultHelper; import org.apache.jdo.util.I18NHelper; /** Index: src/java/org/apache/jdo/impl/jdoql/QueryImpl.java =================================================================== --- src/java/org/apache/jdo/impl/jdoql/QueryImpl.java (revision 170604) +++ src/java/org/apache/jdo/impl/jdoql/QueryImpl.java (working copy) @@ -36,8 +36,8 @@ import org.apache.jdo.impl.jdoql.scope.VariableTable; import org.apache.jdo.impl.jdoql.tree.Tree; import org.apache.jdo.jdoql.JDOQueryException; -import org.apache.jdo.jdoql.QueryResult; import org.apache.jdo.pm.PersistenceManagerInternal; +import org.apache.jdo.query.QueryResult; import org.apache.jdo.store.StoreManager; import org.apache.jdo.util.I18NHelper; Index: src/java/org/apache/jdo/query/Bundle.properties =================================================================== --- src/java/org/apache/jdo/query/Bundle.properties (revision 0) +++ src/java/org/apache/jdo/query/Bundle.properties (revision 0) @@ -0,0 +1,28 @@ +# +# Copyright 2005 The Apache Software Foundation. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# This file should conform to netbeans standards +# (http://www.netbeans.org/i18n) + +# resource bundle for the messages +# key consists of: <PREFIX_><description> +# <PREFIX_> - any valid prefix like MSG_, EXC_, etc. +# <description> - short description started with the upper case letter and used +# upper case to represent each next word. + +# +# BasicQueryResult +# +EXC_ReadOnly=Read only
Property changes on: src/java/org/apache/jdo/query/Bundle.properties ___________________________________________________________________ Name: svn:executable + * Index: src/java/org/apache/jdo/query/QueryResult.java =================================================================== --- src/java/org/apache/jdo/query/QueryResult.java (revision 0) +++ src/java/org/apache/jdo/query/QueryResult.java (revision 0) @@ -0,0 +1,42 @@ +/* + * Copyright 2005 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * QueryResult.java + * + * Created on March 18, 2001, 12:33 PM + */ + +package org.apache.jdo.query; + +/** An instance of this interface is returned as the result of + * Query.execute(...). + * @author Craig Russell + * @version 0.9 + */ +public interface QueryResult extends java.util.Collection { + + /** Close this query result and invalidate all iterators + * that have been opened on it. After this method completes, + * no more iterators can be opened; and + * all iterators currently open on it will return false to + * hasNext(), and will throw NoSuchElementException to next(). + * + */ + void close(); + +} + Property changes on: src/java/org/apache/jdo/query/QueryResult.java ___________________________________________________________________ Name: svn:executable + * Index: src/java/org/apache/jdo/query/QueryResultHelper.java =================================================================== --- src/java/org/apache/jdo/query/QueryResultHelper.java (revision 0) +++ src/java/org/apache/jdo/query/QueryResultHelper.java (revision 0) @@ -0,0 +1,83 @@ +/* + * Copyright 2005 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * QueryResultHelper.java + * + * Created on March 18, 2001, 12:35 PM + */ + +package org.apache.jdo.query; + +import java.util.Collection; +import java.util.List; +import javax.jdo.Extent; + +import org.apache.jdo.jdoql.tree.QueryTree; +import org.apache.jdo.jdoql.tree.ValueTable; + + +/** This interface is a helper for the query execution strategy + * of the StoreManager. When a query is executed, the filter + * is parsed. The parsed query, candidate collection or extent, + * and actual parameters of the execute are stored in the + * QueryResultHelper. + * This interface also provides methods useful for ordering + * the candidate objects and for filtering objects. + * @author Craig Russell + * @version 1.0 + */ +public interface QueryResultHelper { + + /** Return the candidate Collection or Extent specified by + * the user. + * @return the candidate Collection or Extent. + */ + Object getCandidates(); + + /** This method filters the specified collection, removing all elements that + * are not assignment compatible to the candidate Class specified by the + * user, and then orders the results according to the ordering expression + * specified by the user. A new List is returned. + * @param candidates the collection of instances to be filtered and ordered + * @return the filtered parameter collection ordered by the ordering + * expression. + */ + List orderCandidates(Collection candidates); + + /** This method determines whether the specified object is assignment + * compatible to the candidate Class specified by the user and satisfies + * the query filter. + * @return <CODE>true</CODE> if the specified object is of the candidate + * class and satisfies the query filter; <CODE>false otherwise</CODE> + * @param obj the candidate object. + */ + boolean applyFilter(Object obj); + + /** Return the query tree which is either specified by the user or compiled + * from a JDOQL query. + * @return the query tree + * + */ + QueryTree getQueryTree(); + + /** This method returns the parameter values passed by the user + * in the execute(...) method. + * @return a ValueTable representing the parameter values + */ + ValueTable getParameterValues(); +} + Property changes on: src/java/org/apache/jdo/query/QueryResultHelper.java ___________________________________________________________________ Name: svn:executable + * Index: src/java/org/apache/jdo/query/BasicQueryResult.java =================================================================== --- src/java/org/apache/jdo/query/BasicQueryResult.java (revision 0) +++ src/java/org/apache/jdo/query/BasicQueryResult.java (revision 0) @@ -0,0 +1,310 @@ +/* + * Copyright 2005 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * BasicQueryResult.java + * + * Created on March 18, 2001, 12:48 PM + */ + +package org.apache.jdo.query; + +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.NoSuchElementException; + + +import javax.jdo.Extent; +import javax.jdo.spi.I18NHelper; + + +/** This class implements the basic query execution + * strategy. It first orders the candidate set + * using the query helper orderCandidates method. + * It then iterates over the ordered candidate + * collection, filtering each one, + * using the query helper applyFilter method and removing the + * objects that fail the filter. + * All of the methods of Collection are then delegated + * to the result collection. + * + * @author Craig Russell + * @version 1.0 + */ +public class BasicQueryResult extends Object implements QueryResult { + + /** The result after filtering the candidates for the + * proper class, ordering the results, and filtering + * candidates for the user-defined filter. + */ + final List result; + + /** The open iterators against the query results. + */ + HashSet iterators; + + /** The flag indicating whether the query result is + * closed. If the query result is closed, no further + * operations can be done on it. + */ + boolean closed; + + /** I18N support */ + private final static I18NHelper msg = + I18NHelper.getInstance(BasicQueryResult.class); + + /** Creates new BasicQueryResult + * @param qrh the query result helper provided + * by the query parser. + */ + public BasicQueryResult(QueryResultHelper qrh) { + iterators = new HashSet(); + Collection candidates; + // getCandidates returns either a Collection or an Extent + Object possibles = qrh.getCandidates(); + if (possibles instanceof Collection) { + candidates = (Collection) possibles; + } + else { + // iterate the Extent to create the candidate Collection + candidates = new ArrayList(); + Iterator it = ((Extent) possibles).iterator(); + while (it.hasNext()) { + candidates.add (it.next()); + } + } + // order the candidates according to the user's request + result = qrh.orderCandidates(candidates); + Iterator it = result.iterator(); + while (it.hasNext()) { + if (! qrh.applyFilter (it.next())) { + // remove non-qualifying elements and we are done. + it.remove(); + } + } + } + + /** This method closes the result set, closes all open iterators, and releases + * all resources that might be held by the result. + */ + public void close() { + closed = true; + for (Iterator qrii = iterators.iterator(); qrii.hasNext(); ) { + ((QueryResultIterator) qrii.next()).close(); + } + iterators = null; + result.clear(); + } + + /** This method throws UnsupportedOperationException because + * the collection is read-only. + * @param collection ignored. + * @return never. + */ + public boolean retainAll(java.util.Collection collection) { + throw new UnsupportedOperationException (msg.msg("EXC_ReadOnly")); //NOI18N + } + + /** This method delegates to the result collection method. + * @param obj the object to be tested. + * @return <CODE>true</CODE> if the result collection contains + * the parameter object. + */ + public boolean contains(java.lang.Object obj) { + return result.contains (obj); + } + + /** This method delegates to the result collection method. + * @return an array of all objects in the result + * collection that are of the runtime + * type of the parameter array. + * @param obj an array into which to place the + * objects from the result collection. + */ + public java.lang.Object[] toArray(java.lang.Object[] obj) { + return result.toArray (obj); + } + + /** This method delegates to the result collection method. + * @return an iterator over the result collection. + */ + public java.util.Iterator iterator() { + QueryResultIterator i = new BasicQueryResultIterator (result.iterator()); + if (closed) + i.close(); + else + iterators.add(i); + return i; + } + + /** This method delegates to the result collection method. + * @return the result collection as an array. + */ + public java.lang.Object[] toArray() { + return result.toArray(); + } + + /** This method throws UnsupportedOperationException because + * the collection is read-only. + * @param collection ignored. + * @return never. + */ + public boolean removeAll(java.util.Collection collection) { + throw new UnsupportedOperationException (msg.msg("EXC_ReadOnly")); //NOI18N + } + + /** This method throws UnsupportedOperationException because + * the collection is read-only. + * @param obj ignored. + * @return never. + */ + public boolean remove(java.lang.Object obj) { + throw new UnsupportedOperationException (msg.msg("EXC_ReadOnly")); //NOI18N + } + + /** This method throws UnsupportedOperationException because + * the collection is read-only. + */ + public void clear() { + throw new UnsupportedOperationException (msg.msg("EXC_ReadOnly")); //NOI18N + } + + /** This method throws UnsupportedOperationException because + * the collection is read-only. + * @param collection ignored. + * @return never. + */ + public boolean addAll(java.util.Collection collection) { + throw new UnsupportedOperationException (msg.msg("EXC_ReadOnly")); //NOI18N + } + + /** This method delegates to the result collection method. + * @return the size of the results. + */ + public int size() { + return result.size(); + } + + /** This method delegates to the result collection method. + * @return <CODE>true</CODE> if the result collection contains all of the + * elements in the parameter collection. + * @param collection a collection of elements to be tested. + */ + public boolean containsAll(java.util.Collection collection) { + return result.containsAll (collection); + } + + /** This method throws UnsupportedOperationException because + * the collection is read-only. + * @param obj ignored. + * @return never. + */ + public boolean add(java.lang.Object obj) { + throw new UnsupportedOperationException (msg.msg("EXC_ReadOnly")); //NOI18N + } + + /** This method delegates to the result collection method. + * @return <CODE>true</CODE> if the result collection is empty. + */ + public boolean isEmpty() { + return result.isEmpty(); + } + + /** This method delegates to the result collection method. + * @return <CODE>true</CODE> if the result collection is equal to the parameter + * collection. + * @param obj the object to which to compare this object. + */ + public boolean equals (Object obj) { + return result.equals (obj); + } + + /** This method delegates to the result collection method. + * @return the hashCode of the result collection. + */ + public int hashCode() { + return result.hashCode(); + } + /** The internal query result iterator supports all + * iterator methods plus close, allowing early release + * of resources. + */ + public class BasicQueryResultIterator extends Object implements QueryResultIterator { + + /** The internal iterator over the query results. + */ + Iterator internalIterator; + + /** The flag indicating whether the query result is + * closed. If the query result is closed, no further + * operations can be done on it. + */ + boolean closed; + + /** Construct a new query result iterator given the + * iterator over the results. + * @param it The iterator over the results of the query. + */ + private BasicQueryResultIterator (Iterator it) { + internalIterator = it; + closed = false; + } + + /** Return true if this query result iterator has not been + * closed and the internal iterator has more elements. + * @return true if there are more elements. + */ + public boolean hasNext() { + if (isClosed()) return false; + return internalIterator.hasNext(); + } + + /** Advance and return the next element of the iterator. + * @return the next element of the iterator. + */ + public java.lang.Object next() { + if (isClosed()) throw new NoSuchElementException(); + return internalIterator.next(); + } + + /** Close this iterator and release any resources held. After + * this method completes, the iterator will return false to + * hasNext(), and will throw NoSuchElementException to next(). + */ + public void close() { + // allow iterator to be garbage collected + internalIterator = null; + closed = true; + } + + /** Throw an exception. This iterator is read-only. + */ + public void remove() { + throw new UnsupportedOperationException (msg.msg("EXC_ReadOnly")); //NOI18N + } + + /** Return true if the user has closed this iterator. + * @return true if the user has closed this iterator. + */ + public boolean isClosed() { + return closed; + } + + } +} Property changes on: src/java/org/apache/jdo/query/BasicQueryResult.java ___________________________________________________________________ Name: svn:executable + * Index: src/java/org/apache/jdo/query/QueryResultIterator.java =================================================================== --- src/java/org/apache/jdo/query/QueryResultIterator.java (revision 0) +++ src/java/org/apache/jdo/query/QueryResultIterator.java (revision 0) @@ -0,0 +1,40 @@ +/* + * Copyright 2005 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * QueryResultIterator.java + * + * Created on March 18, 2001, 12:34 PM + */ + +package org.apache.jdo.query; + +/** This interface is used to iterate a query result. It is + * returned to the user in response to the iterator() method + * of the query result Collection. + * @author Craig Russell + * @version 0.9 + */ +public interface QueryResultIterator extends java.util.Iterator { + + /** Close this iterator and release any resources held. After + * this method completes, the iterator will return false to + * hasNext(), and will throw NoSuchElementException to next(). + */ + void close(); + +} + Property changes on: src/java/org/apache/jdo/query/QueryResultIterator.java ___________________________________________________________________ Name: svn:executable + * Index: src/java/org/apache/jdo/jdoql/QueryResult.java =================================================================== --- src/java/org/apache/jdo/jdoql/QueryResult.java (revision 170604) +++ src/java/org/apache/jdo/jdoql/QueryResult.java (working copy) @@ -1,42 +0,0 @@ -/* - * Copyright 2005 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * QueryResult.java - * - * Created on March 18, 2001, 12:33 PM - */ - -package org.apache.jdo.jdoql; - -/** An instance of this interface is returned as the result of - * Query.execute(...). - * @author Craig Russell - * @version 0.9 - */ -public interface QueryResult extends java.util.Collection { - - /** Close this query result and invalidate all iterators - * that have been opened on it. After this method completes, - * no more iterators can be opened; and - * all iterators currently open on it will return false to - * hasNext(), and will throw NoSuchElementException to next(). - * - */ - void close(); - -} - Index: src/java/org/apache/jdo/jdoql/QueryResultHelper.java =================================================================== --- src/java/org/apache/jdo/jdoql/QueryResultHelper.java (revision 170604) +++ src/java/org/apache/jdo/jdoql/QueryResultHelper.java (working copy) @@ -1,83 +0,0 @@ -/* - * Copyright 2005 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * QueryResultHelper.java - * - * Created on March 18, 2001, 12:35 PM - */ - -package org.apache.jdo.jdoql; - -import java.util.Collection; -import java.util.List; -import javax.jdo.Extent; - -import org.apache.jdo.jdoql.tree.QueryTree; -import org.apache.jdo.jdoql.tree.ValueTable; - - -/** This interface is a helper for the query execution strategy - * of the StoreManager. When a query is executed, the filter - * is parsed. The parsed query, candidate collection or extent, - * and actual parameters of the execute are stored in the - * QueryResultHelper. - * This interface also provides methods useful for ordering - * the candidate objects and for filtering objects. - * @author Craig Russell - * @version 1.0 - */ -public interface QueryResultHelper { - - /** Return the candidate Collection or Extent specified by - * the user. - * @return the candidate Collection or Extent. - */ - Object getCandidates(); - - /** This method filters the specified collection, removing all elements that - * are not assignment compatible to the candidate Class specified by the - * user, and then orders the results according to the ordering expression - * specified by the user. A new List is returned. - * @param candidates the collection of instances to be filtered and ordered - * @return the filtered parameter collection ordered by the ordering - * expression. - */ - List orderCandidates(Collection candidates); - - /** This method determines whether the specified object is assignment - * compatible to the candidate Class specified by the user and satisfies - * the query filter. - * @return <CODE>true</CODE> if the specified object is of the candidate - * class and satisfies the query filter; <CODE>false otherwise</CODE> - * @param obj the candidate object. - */ - boolean applyFilter(Object obj); - - /** Return the query tree which is either specified by the user or compiled - * from a JDOQL query. - * @return the query tree - * - */ - QueryTree getQueryTree(); - - /** This method returns the parameter values passed by the user - * in the execute(...) method. - * @return a ValueTable representing the parameter values - */ - ValueTable getParameterValues(); -} - Index: src/java/org/apache/jdo/jdoql/Bundle.properties =================================================================== --- src/java/org/apache/jdo/jdoql/Bundle.properties (revision 170604) +++ src/java/org/apache/jdo/jdoql/Bundle.properties (working copy) @@ -1,28 +0,0 @@ -# -# Copyright 2005 The Apache Software Foundation. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# This file should conform to netbeans standards -# (http://www.netbeans.org/i18n) - -# resource bundle for the messages -# key consists of: <PREFIX_><description> -# <PREFIX_> - any valid prefix like MSG_, EXC_, etc. -# <description> - short description started with the upper case letter and used -# upper case to represent each next word. - -# -# BasicQueryResult -# -EXC_ReadOnly=Read only Index: src/java/org/apache/jdo/jdoql/BasicQueryResult.java =================================================================== --- src/java/org/apache/jdo/jdoql/BasicQueryResult.java (revision 170604) +++ src/java/org/apache/jdo/jdoql/BasicQueryResult.java (working copy) @@ -1,310 +0,0 @@ -/* - * Copyright 2005 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * BasicQueryResult.java - * - * Created on March 18, 2001, 12:48 PM - */ - -package org.apache.jdo.jdoql; - -import java.util.Collection; -import java.util.Iterator; -import java.util.List; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.NoSuchElementException; - - -import javax.jdo.*; -import javax.jdo.spi.I18NHelper; - - -/** This class implements the basic query execution - * strategy. It first orders the candidate set - * using the query helper orderCandidates method. - * It then iterates over the ordered candidate - * collection, filtering each one, - * using the query helper applyFilter method and removing the - * objects that fail the filter. - * All of the methods of Collection are then delegated - * to the result collection. - * - * @author Craig Russell - * @version 1.0 - */ -public class BasicQueryResult extends Object implements QueryResult { - - /** The result after filtering the candidates for the - * proper class, ordering the results, and filtering - * candidates for the user-defined filter. - */ - final List result; - - /** The open iterators against the query results. - */ - HashSet iterators; - - /** The flag indicating whether the query result is - * closed. If the query result is closed, no further - * operations can be done on it. - */ - boolean closed; - - /** I18N support */ - private final static I18NHelper msg = - I18NHelper.getInstance(BasicQueryResult.class); - - /** Creates new BasicQueryResult - * @param qrh the query result helper provided - * by the query parser. - */ - public BasicQueryResult(QueryResultHelper qrh) { - iterators = new HashSet(); - Collection candidates; - // getCandidates returns either a Collection or an Extent - Object possibles = qrh.getCandidates(); - if (possibles instanceof Collection) { - candidates = (Collection) possibles; - } - else { - // iterate the Extent to create the candidate Collection - candidates = new ArrayList(); - Iterator it = ((Extent) possibles).iterator(); - while (it.hasNext()) { - candidates.add (it.next()); - } - } - // order the candidates according to the user's request - result = qrh.orderCandidates(candidates); - Iterator it = result.iterator(); - while (it.hasNext()) { - if (! qrh.applyFilter (it.next())) { - // remove non-qualifying elements and we are done. - it.remove(); - } - } - } - - /** This method closes the result set, closes all open iterators, and releases - * all resources that might be held by the result. - */ - public void close() { - closed = true; - for (Iterator qrii = iterators.iterator(); qrii.hasNext(); ) { - ((QueryResultIterator) qrii.next()).close(); - } - iterators = null; - result.clear(); - } - - /** This method throws UnsupportedOperationException because - * the collection is read-only. - * @param collection ignored. - * @return never. - */ - public boolean retainAll(java.util.Collection collection) { - throw new UnsupportedOperationException (msg.msg("EXC_ReadOnly")); //NOI18N - } - - /** This method delegates to the result collection method. - * @param obj the object to be tested. - * @return <CODE>true</CODE> if the result collection contains - * the parameter object. - */ - public boolean contains(java.lang.Object obj) { - return result.contains (obj); - } - - /** This method delegates to the result collection method. - * @return an array of all objects in the result - * collection that are of the runtime - * type of the parameter array. - * @param obj an array into which to place the - * objects from the result collection. - */ - public java.lang.Object[] toArray(java.lang.Object[] obj) { - return result.toArray (obj); - } - - /** This method delegates to the result collection method. - * @return an iterator over the result collection. - */ - public java.util.Iterator iterator() { - QueryResultIterator i = new BasicQueryResultIterator (result.iterator()); - if (closed) - i.close(); - else - iterators.add(i); - return i; - } - - /** This method delegates to the result collection method. - * @return the result collection as an array. - */ - public java.lang.Object[] toArray() { - return result.toArray(); - } - - /** This method throws UnsupportedOperationException because - * the collection is read-only. - * @param collection ignored. - * @return never. - */ - public boolean removeAll(java.util.Collection collection) { - throw new UnsupportedOperationException (msg.msg("EXC_ReadOnly")); //NOI18N - } - - /** This method throws UnsupportedOperationException because - * the collection is read-only. - * @param obj ignored. - * @return never. - */ - public boolean remove(java.lang.Object obj) { - throw new UnsupportedOperationException (msg.msg("EXC_ReadOnly")); //NOI18N - } - - /** This method throws UnsupportedOperationException because - * the collection is read-only. - */ - public void clear() { - throw new UnsupportedOperationException (msg.msg("EXC_ReadOnly")); //NOI18N - } - - /** This method throws UnsupportedOperationException because - * the collection is read-only. - * @param collection ignored. - * @return never. - */ - public boolean addAll(java.util.Collection collection) { - throw new UnsupportedOperationException (msg.msg("EXC_ReadOnly")); //NOI18N - } - - /** This method delegates to the result collection method. - * @return the size of the results. - */ - public int size() { - return result.size(); - } - - /** This method delegates to the result collection method. - * @return <CODE>true</CODE> if the result collection contains all of the - * elements in the parameter collection. - * @param collection a collection of elements to be tested. - */ - public boolean containsAll(java.util.Collection collection) { - return result.containsAll (collection); - } - - /** This method throws UnsupportedOperationException because - * the collection is read-only. - * @param obj ignored. - * @return never. - */ - public boolean add(java.lang.Object obj) { - throw new UnsupportedOperationException (msg.msg("EXC_ReadOnly")); //NOI18N - } - - /** This method delegates to the result collection method. - * @return <CODE>true</CODE> if the result collection is empty. - */ - public boolean isEmpty() { - return result.isEmpty(); - } - - /** This method delegates to the result collection method. - * @return <CODE>true</CODE> if the result collection is equal to the parameter - * collection. - * @param obj the object to which to compare this object. - */ - public boolean equals (Object obj) { - return result.equals (obj); - } - - /** This method delegates to the result collection method. - * @return the hashCode of the result collection. - */ - public int hashCode() { - return result.hashCode(); - } - /** The internal query result iterator supports all - * iterator methods plus close, allowing early release - * of resources. - */ - public class BasicQueryResultIterator extends Object implements QueryResultIterator { - - /** The internal iterator over the query results. - */ - Iterator internalIterator; - - /** The flag indicating whether the query result is - * closed. If the query result is closed, no further - * operations can be done on it. - */ - boolean closed; - - /** Construct a new query result iterator given the - * iterator over the results. - * @param it The iterator over the results of the query. - */ - private BasicQueryResultIterator (Iterator it) { - internalIterator = it; - closed = false; - } - - /** Return true if this query result iterator has not been - * closed and the internal iterator has more elements. - * @return true if there are more elements. - */ - public boolean hasNext() { - if (isClosed()) return false; - return internalIterator.hasNext(); - } - - /** Advance and return the next element of the iterator. - * @return the next element of the iterator. - */ - public java.lang.Object next() { - if (isClosed()) throw new NoSuchElementException(); - return internalIterator.next(); - } - - /** Close this iterator and release any resources held. After - * this method completes, the iterator will return false to - * hasNext(), and will throw NoSuchElementException to next(). - */ - public void close() { - // allow iterator to be garbage collected - internalIterator = null; - closed = true; - } - - /** Throw an exception. This iterator is read-only. - */ - public void remove() { - throw new UnsupportedOperationException (msg.msg("EXC_ReadOnly")); //NOI18N - } - - /** Return true if the user has closed this iterator. - * @return true if the user has closed this iterator. - */ - public boolean isClosed() { - return closed; - } - - } -} Index: src/java/org/apache/jdo/jdoql/QueryResultIterator.java =================================================================== --- src/java/org/apache/jdo/jdoql/QueryResultIterator.java (revision 170604) +++ src/java/org/apache/jdo/jdoql/QueryResultIterator.java (working copy) @@ -1,40 +0,0 @@ -/* - * Copyright 2005 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * QueryResultIterator.java - * - * Created on March 18, 2001, 12:34 PM - */ - -package org.apache.jdo.jdoql; - -/** This interface is used to iterate a query result. It is - * returned to the user in response to the iterator() method - * of the query result Collection. - * @author Craig Russell - * @version 0.9 - */ -public interface QueryResultIterator extends java.util.Iterator { - - /** Close this iterator and release any resources held. After - * this method completes, the iterator will return false to - * hasNext(), and will throw NoSuchElementException to next(). - */ - void close(); - -} - Index: src/java/org/apache/jdo/store/StoreManager.java =================================================================== --- src/java/org/apache/jdo/store/StoreManager.java (revision 170604) +++ src/java/org/apache/jdo/store/StoreManager.java (working copy) @@ -24,9 +24,9 @@ import javax.jdo.spi.PersistenceCapable; import javax.jdo.spi.StateManager; -import org.apache.jdo.jdoql.QueryResult; -import org.apache.jdo.jdoql.QueryResultHelper; import org.apache.jdo.pm.PersistenceManagerInternal; +import org.apache.jdo.query.QueryResult; +import org.apache.jdo.query.QueryResultHelper; import org.apache.jdo.state.StateManagerInternal; Index: src/java/org/apache/jdo/store/StoreManagerImpl.java =================================================================== --- src/java/org/apache/jdo/store/StoreManagerImpl.java (revision 170604) +++ src/java/org/apache/jdo/store/StoreManagerImpl.java (working copy) @@ -23,10 +23,10 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.jdo.jdoql.BasicQueryResult; -import org.apache.jdo.jdoql.QueryResult; -import org.apache.jdo.jdoql.QueryResultHelper; import org.apache.jdo.pm.PersistenceManagerInternal; +import org.apache.jdo.query.BasicQueryResult; +import org.apache.jdo.query.QueryResult; +import org.apache.jdo.query.QueryResultHelper; import org.apache.jdo.state.StateManagerInternal; import org.apache.jdo.util.I18NHelper;
