true
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 true
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 true
if the result collection is empty.
+ */
+ public boolean isEmpty() {
+ return result.isEmpty();
+ }
+
+ /** This method delegates to the result collection method.
+ * @return true
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;
+ }
+
+ }
+}
Added: incubator/jdo/trunk/ri11/src/java/org/apache/jdo/jdoql/Bundle.properties
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/src/java/org/apache/jdo/jdoql/Bundle.properties?view=auto&rev=158176
==============================================================================
--- incubator/jdo/trunk/ri11/src/java/org/apache/jdo/jdoql/Bundle.properties (added)
+++ incubator/jdo/trunk/ri11/src/java/org/apache/jdo/jdoql/Bundle.properties Fri Mar 18 17:02:29 2005
@@ -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: JDOQueryException
without detail message.
+ */
+ public JDOQueryException()
+ {
+ }
+
+ /**
+ * Constructs a new JDOQueryException
with the specified detail message.
+ * @param msg the detail message.
+ */
+ public JDOQueryException(String msg)
+ {
+ super(msg);
+ }
+
+ /**
+ * Constructs a new JDOQueryException
with the specified detail message
+ * and nested Exception.
+ * @param msg the detail message.
+ * @param nested the nested Exception
.
+ */
+ public JDOQueryException(String msg, Throwable nested)
+ {
+ super(msg, nested);
+ }
+}
Added: incubator/jdo/trunk/ri11/src/java/org/apache/jdo/jdoql/QueryResult.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/src/java/org/apache/jdo/jdoql/QueryResult.java?view=auto&rev=158176
==============================================================================
--- incubator/jdo/trunk/ri11/src/java/org/apache/jdo/jdoql/QueryResult.java (added)
+++ incubator/jdo/trunk/ri11/src/java/org/apache/jdo/jdoql/QueryResult.java Fri Mar 18 17:02:29 2005
@@ -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.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();
+
+}
+
Added: incubator/jdo/trunk/ri11/src/java/org/apache/jdo/jdoql/QueryResultHelper.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/src/java/org/apache/jdo/jdoql/QueryResultHelper.java?view=auto&rev=158176
==============================================================================
--- incubator/jdo/trunk/ri11/src/java/org/apache/jdo/jdoql/QueryResultHelper.java (added)
+++ incubator/jdo/trunk/ri11/src/java/org/apache/jdo/jdoql/QueryResultHelper.java Fri Mar 18 17:02:29 2005
@@ -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.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 true
if the specified object is of the candidate
+ * class and satisfies the query filter; false otherwise
+ * @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();
+}
+
Added: incubator/jdo/trunk/ri11/src/java/org/apache/jdo/jdoql/QueryResultIterator.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/src/java/org/apache/jdo/jdoql/QueryResultIterator.java?view=auto&rev=158176
==============================================================================
--- incubator/jdo/trunk/ri11/src/java/org/apache/jdo/jdoql/QueryResultIterator.java (added)
+++ incubator/jdo/trunk/ri11/src/java/org/apache/jdo/jdoql/QueryResultIterator.java Fri Mar 18 17:02:29 2005
@@ -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.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();
+
+}
+
Added: incubator/jdo/trunk/ri11/src/java/org/apache/jdo/jdoql/package.html
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/src/java/org/apache/jdo/jdoql/package.html?view=auto&rev=158176
==============================================================================
--- incubator/jdo/trunk/ri11/src/java/org/apache/jdo/jdoql/package.html (added)
+++ incubator/jdo/trunk/ri11/src/java/org/apache/jdo/jdoql/package.html Fri Mar 18 17:02:29 2005
@@ -0,0 +1,27 @@
+
+
+
+
+This package contains interfaces defining the query result and a basic implementation. +Furthermore, it defines the the exception class JDOQueryException.
+ +