org.apache.jdo.impl.jdoql
Class QueryResultHelperImpl

java.lang.Object
  extended byorg.apache.jdo.impl.jdoql.QueryResultHelperImpl
All Implemented Interfaces:
org.apache.jdo.query.QueryResultHelper

public class QueryResultHelperImpl
extends java.lang.Object
implements org.apache.jdo.query.QueryResultHelper

This class implements the helper interface to support 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.

Author:
Michael Bouschen

Field Summary
private  java.lang.Class candidateClass
          The candidate class taken from the queryTree.
private  java.lang.Object candidates
          The candidates for this query evalutaion.
private  MemoryQuery eval
          The memory query evaluator.
private static org.apache.commons.logging.Log logger
          Logger
protected static org.apache.jdo.util.I18NHelper msg
          I18N support
private  OrderingComparator ordering
          The ordering comparator.
private  ParameterTable parameters
          The table of parameter values.
private  org.apache.jdo.pm.PersistenceManagerInternal pm
          The query PM
private  QueryTree queryTree
          The query tree.
private  TreeWalker treeWalker
          The tree walker used when applying the filter and do the ordering.
private  VariableTable variables
          The table of variable values.
 
Constructor Summary
QueryResultHelperImpl(org.apache.jdo.pm.PersistenceManagerInternal pm, QueryTree queryTree, java.lang.Object candidates, ParameterTable parameters, VariableTable variables)
           
 
Method Summary
 boolean applyFilter(java.lang.Object obj)
          This method determines whether the specified object is assignment compatible to the candidate Class specified by the user and satisfies the query filter.
static void checkPM(org.apache.jdo.pm.PersistenceManagerInternal queryPM, java.lang.Object value)
          Checks the PersistenceManager of the specified value to be identical to the one from the query instance.
 java.lang.Object getCandidates()
          Return the candidate Collection or Extent specified by the user.
 ValueTable getParameterValues()
          This method returns the parameter values passed by the user in the execute(...) method.
 QueryTree getQueryTree()
          Return the query tree which is either specified by the user or compiled from a JDOQL query.
 java.util.List orderCandidates(java.util.Collection candidates)
          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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

pm

private org.apache.jdo.pm.PersistenceManagerInternal pm
The query PM


queryTree

private QueryTree queryTree
The query tree.


candidates

private java.lang.Object candidates
The candidates for this query evalutaion.


parameters

private ParameterTable parameters
The table of parameter values.


variables

private VariableTable variables
The table of variable values.


eval

private MemoryQuery eval
The memory query evaluator.


treeWalker

private TreeWalker treeWalker
The tree walker used when applying the filter and do the ordering.


candidateClass

private java.lang.Class candidateClass
The candidate class taken from the queryTree.


ordering

private OrderingComparator ordering
The ordering comparator.


logger

private static org.apache.commons.logging.Log logger
Logger


msg

protected static final org.apache.jdo.util.I18NHelper msg
I18N support

Constructor Detail

QueryResultHelperImpl

public QueryResultHelperImpl(org.apache.jdo.pm.PersistenceManagerInternal pm,
                             QueryTree queryTree,
                             java.lang.Object candidates,
                             ParameterTable parameters,
                             VariableTable variables)
Method Detail

getCandidates

public java.lang.Object getCandidates()
Return the candidate Collection or Extent specified by the user.

Specified by:
getCandidates in interface org.apache.jdo.query.QueryResultHelper
Returns:
the candidate Collection or Extent.

orderCandidates

public java.util.List orderCandidates(java.util.Collection candidates)
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.

Specified by:
orderCandidates in interface org.apache.jdo.query.QueryResultHelper
Parameters:
candidates - the collection of instances to be filtered and ordered
Returns:
the filtered parameter collection ordered by the ordering expression.

applyFilter

public boolean applyFilter(java.lang.Object obj)
This method determines whether the specified object is assignment compatible to the candidate Class specified by the user and satisfies the query filter.

Specified by:
applyFilter in interface org.apache.jdo.query.QueryResultHelper
Parameters:
obj - the candidate object.
Returns:
true if the specified object is of the candidate class and satisfies the query filter; false otherwise

getQueryTree

public QueryTree getQueryTree()
Return the query tree which is either specified by the user or compiled from a JDOQL query.

Returns:
the query tree

getParameterValues

public ValueTable getParameterValues()
This method returns the parameter values passed by the user in the execute(...) method.

Returns:
a ValueTable representing the parameter values

checkPM

public static void checkPM(org.apache.jdo.pm.PersistenceManagerInternal queryPM,
                           java.lang.Object value)
Checks the PersistenceManager of the specified value to be identical to the one from the query instance.