Added: incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/state/TransientClean.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/state/TransientClean.java?view=auto&rev=158176
==============================================================================
--- incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/state/TransientClean.java (added)
+++ incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/state/TransientClean.java Fri Mar
18 17:02:29 2005
@@ -0,0 +1,127 @@
+/*
+ * 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.
+ */
+
+/*
+ * TransientClean.java August 10, 2001
+ */
+
+package org.apache.jdo.impl.state;
+
+import javax.jdo.JDOFatalInternalException;
+import javax.jdo.Transaction;
+
+/**
+ * This class represents TransientClean state specific state transitions as
+ * requested by StateManagerImpl. This state is the result of a call to
+ * makeTransactional on a Transient instance, or commit or rollback of a
+ * TransientDirty instance.
+ *
+ * @author Marina Vatkina
+ */
+class TransientClean extends LifeCycleState {
+
+ TransientClean() {
+ // these flags are set only in the constructor
+ // and shouldn't be changed afterwards
+ // (cannot make them final since they are declared in superclass
+ // but their values are specific to subclasses)
+ isPersistent = false;
+ isTransactional = true;
+ isDirty = false;
+ isNew = false;
+ isDeleted = false;
+
+ isFlushed = true;
+ isNavigable = true;
+ isRefreshable = true;
+ isBeforeImageUpdatable = false;
+
+ stateType = T_CLEAN;
+ }
+
+ /**
+ * @see LifeCycleState#transitionMakeTransient(StateManagerImpl sm, Transaction tx)
+ */
+ protected LifeCycleState transitionMakeTransient(StateManagerImpl sm,
+ Transaction tx) {
+ return this;
+ }
+
+ /**
+ * @see LifeCycleState#transitionMakeNontransactional(StateManagerImpl sm,
+ * Transaction tx)
+ */
+ protected LifeCycleState transitionMakeNontransactional(StateManagerImpl sm,
+ Transaction tx) {
+ sm.disconnect();
+ return changeState(TRANSIENT);
+ }
+
+ /**
+ * @see LifeCycleState#transitionMakePersistent(StateManagerImpl sm)
+ */
+ protected LifeCycleState transitionMakePersistent(StateManagerImpl sm) {
+ sm.registerTransactional();
+ return changeState(P_NEW);
+ }
+
+ /**
+ * @see LifeCycleState#transitionToAutoPersistent(StateManagerImpl sm)
+ */
+ protected LifeCycleState transitionToAutoPersistent(StateManagerImpl sm) {
+ sm.registerTransactional();
+ return changeState(AP_NEW);
+ }
+
+ /**
+ * @see LifeCycleState#transitionReadField(StateManagerImpl sm, Transaction tx)
+ */
+ protected LifeCycleState transitionReadField(StateManagerImpl sm, Transaction tx) {
+ return this;
+ }
+
+ /**
+ * @see LifeCycleState#transitionWriteField(StateManagerImpl sm, Transaction tx)
+ */
+ protected LifeCycleState transitionWriteField(StateManagerImpl sm,
+ Transaction tx) {
+ if (tx.isActive()) {
+ // This is the first change in the current transaction. Save image
+ // for rollback.
+ sm.createBeforeImage();
+ return changeState(T_DIRTY);
+ } else {
+ return this;
+ }
+ }
+
+ /**
+ * This is a no-op.
+ * @see LifeCycleState#transitionCommit(boolean retainValues, StateManagerImpl sm)
+ */
+ protected LifeCycleState transitionCommit(boolean retainValues, StateManagerImpl sm)
{
+ return this;
+ }
+
+ /**
+ * @see LifeCycleState#transitionRollback(boolean restoreValues, StateManagerImpl sm)
+ */
+ protected LifeCycleState transitionRollback(boolean restoreValues, StateManagerImpl sm)
{
+ sm.reset();
+ return this;
+ }
+}
+
Added: incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/state/TransientDirty.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/state/TransientDirty.java?view=auto&rev=158176
==============================================================================
--- incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/state/TransientDirty.java (added)
+++ incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/state/TransientDirty.java Fri Mar
18 17:02:29 2005
@@ -0,0 +1,96 @@
+/*
+ * 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.
+ */
+
+/*
+ * TransientDirty.java August 10, 2001
+ */
+
+package org.apache.jdo.impl.state;
+
+import javax.jdo.Transaction;
+
+/**
+ * This class represents TransientDirty state specific state transitions as
+ * requested by StateManagerImpl. This state is the result of a wrie operation
+ * on a TransientClean instance
+ *
+ * @author Marina Vatkina
+ */
+class TransientDirty extends LifeCycleState {
+
+ TransientDirty() {
+ // these flags are set only in the constructor
+ // and shouldn't be changed afterwards
+ // (cannot make them final since they are declared in superclass
+ // but their values are specific to subclasses)
+ isPersistent = false;
+ isTransactional = true;
+ isDirty = true;
+ isNew = false;
+ isDeleted = false;
+
+ isNavigable = true;
+ isRefreshable = true;
+ isBeforeImageUpdatable = true;
+ isFlushed = false;
+
+ stateType = T_DIRTY;
+ }
+
+ /**
+ * @see LifeCycleState#transitionMakeTransient(StateManagerImpl sm,
+ * Transaction tx)
+ */
+ protected LifeCycleState transitionMakeTransient(StateManagerImpl sm,
+ Transaction tx) {
+ return this;
+ }
+
+ /**
+ * @see LifeCycleState#transitionMakePersistent(StateManagerImpl sm)
+ */
+ protected LifeCycleState transitionMakePersistent(StateManagerImpl sm) {
+
+ sm.registerTransactional();
+ return changeState(P_NEW);
+ }
+
+ /**
+ * @see LifeCycleState#transitionToAutoPersistent(StateManagerImpl sm)
+ */
+ protected LifeCycleState transitionToAutoPersistent(StateManagerImpl sm) {
+ sm.registerTransactional();
+ return changeState(AP_NEW);
+ }
+
+ /**
+ * @see LifeCycleState#transitionCommit(boolean retainValues, StateManagerImpl sm)
+ */
+ protected LifeCycleState transitionCommit(boolean retainValues, StateManagerImpl sm)
{
+ sm.reset();
+ return changeState(T_CLEAN);
+ }
+
+ /**
+ * @see LifeCycleState#transitionRollback(boolean restoreValues, StateManagerImpl sm)
+ */
+ protected LifeCycleState transitionRollback(boolean restoreValues, StateManagerImpl sm)
{
+ sm.restoreFields();
+ sm.reset();
+ return changeState(T_CLEAN);
+ }
+
+}
Added: incubator/jdo/trunk/ri11/src/java/org/apache/jdo/jdoql/BasicQueryResult.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/src/java/org/apache/jdo/jdoql/BasicQueryResult.java?view=auto&rev=158176
==============================================================================
--- incubator/jdo/trunk/ri11/src/java/org/apache/jdo/jdoql/BasicQueryResult.java (added)
+++ incubator/jdo/trunk/ri11/src/java/org/apache/jdo/jdoql/BasicQueryResult.java Fri Mar 18
17:02:29 2005
@@ -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.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;
+ }
+
+ }
+}
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: <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
Added: incubator/jdo/trunk/ri11/src/java/org/apache/jdo/jdoql/JDOQueryException.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/src/java/org/apache/jdo/jdoql/JDOQueryException.java?view=auto&rev=158176
==============================================================================
--- incubator/jdo/trunk/ri11/src/java/org/apache/jdo/jdoql/JDOQueryException.java (added)
+++ incubator/jdo/trunk/ri11/src/java/org/apache/jdo/jdoql/JDOQueryException.java Fri Mar
18 17:02:29 2005
@@ -0,0 +1,61 @@
+/*
+ * 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.
+ */
+
+/*
+ * JDOQueryException.java
+ *
+ * Created on August 28, 2001
+ */
+
+package org.apache.jdo.jdoql;
+
+import javax.jdo.JDOUserException;
+
+/**
+ * This class represents query user errors.
+ *
+ * @author Michael Bouschen
+ */
+public class JDOQueryException
+ extends JDOUserException
+{
+ /**
+ * Creates a new <code>JDOQueryException</code> without detail message.
+ */
+ public JDOQueryException()
+ {
+ }
+
+ /**
+ * Constructs a new <code>JDOQueryException</code> with the specified detail
message.
+ * @param msg the detail message.
+ */
+ public JDOQueryException(String msg)
+ {
+ super(msg);
+ }
+
+ /**
+ * Constructs a new <code>JDOQueryException</code> with the specified detail
message
+ * and nested Exception.
+ * @param msg the detail message.
+ * @param nested the nested <code>Exception</code>.
+ */
+ 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 <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();
+}
+
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 @@
+<!--
+ 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.
+-->
+
+<html>
+<head>
+<title>Package org.apache.jdo.jdoql</title>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
+</head>
+
+<body bgcolor="#FFFFFF">
+<p>This package contains interfaces defining the query result and a basic implementation.
+Furthermore, it defines the the exception class JDOQueryException.</p>
+</body>
+</html>
|