org.jpox.store.query
Class AbstractJavaQuery

java.lang.Object
  extended by org.jpox.store.query.Query
      extended by org.jpox.store.query.AbstractJavaQuery
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
AbstractJDOQLQuery, AbstractJPQLQuery

public abstract class AbstractJavaQuery
extends Query

Abstract representation of a Java-based query. To be extended by Java-based query languages.

Version:
$Revision$
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class org.jpox.store.query.Query
Query.SubqueryDefinition
 
Field Summary
protected  java.util.Collection candidateCollection
          Collection of candidates for this query.
protected  Extent candidateExtent
          Extent of candidates for this query.
protected  boolean distinct
          whether to apply "distinct" results.
protected  JPOXResultSetMetaData resultMetaData
          Result metadata (JPOX extension, allowing access to more info).
protected  ResultObjectFactory rof
          Factory for obtaining the results from the query result set.
protected  java.lang.String singleString
          Cached form of the single string form of the query.
protected static java.util.Map userDefinedScalarExpressions
          Register of user-defined ScalarExpression, provided via plugins.
 
Fields inherited from class org.jpox.store.query.Query
BULK_DELETE, BULK_UPDATE, candidateClass, candidateClassName, explicitParameters, explicitVariables, extensions, filter, from, fromInclNo, grouping, having, ignoreCache, implicitParameters, imports, isCompiled, LOCALISER, om, ordering, parameterNames, parsedImports, queryResults, range, result, resultClass, resultClassName, SELECT, subclasses, subqueries, toExclNo, type, unique, unmodifiable, update
 
Constructor Summary
AbstractJavaQuery(ObjectManager om)
          Constructor for a Java-based query.
 
Method Summary
protected  void discardCompiled()
          Method to discard our current compiled query due to changes.
 java.util.Collection getCandidateCollection()
          Accessor for the candidate collection (if specified using a collection).
 Extent getCandidateExtent()
          Accessor for the candidate Extent (if specified using an Extent).
 Imports getParsedImports()
          Accessor for the parsed imports.
 JPOXResultSetMetaData getResultSetMetaData()
          Retrieve the metadata for the results
abstract  java.lang.String getSingleStringQuery()
          Accessor for a single string form of the query.
static java.util.Map getUserDefinedScalarExpressions()
          Accessor for the user-defined scalar expressions.
static void registerScalarExpression(java.lang.Class literal, java.lang.Class scalarExpressionClass, java.lang.String name)
          Register ScalarExpressions for the given cls.
protected  void registerScalarExpressions(PluginManager pluginMgr, ClassLoaderResolver clr)
          Register ScalarExpression classes delcared as plug-ins extensions TODO currently register only the first time this class is instantiated.
 boolean resultHasOnlyAggregates(java.lang.String result)
          Convenience method to simple-parse the "result" clause returning if it includes solely aggregates.
 void setCandidates(java.util.Collection pcs)
          Set the candidate Collection to query.
 void setCandidates(Extent pcs)
          Set the candidate Extent to query.
 java.lang.String toString()
          Stringifier method
 
Methods inherited from class org.jpox.store.query.Query
addExtension, addSubquery, applyRangeChecks, assertIsModifiable, close, closeAll, compile, compileInternal, declareExplicitParameters, declareExplicitVariables, declareImports, deletePersistentAll, deletePersistentAll, deletePersistentAll, equals, execute, execute, execute, execute, executeWithArray, executeWithMap, getCandidateClass, getCandidateClassName, getExplicitParameters, getExplicitVariables, getExtension, getFetchPlan, getFilter, getFrom, getGrouping, getHaving, getIgnoreCache, getImports, getObjectManager, getOrdering, getRange, getRangeFromIncl, getRangeToExcl, getResult, getResultClass, getResultClassName, getStoreManager, getSubqueryForVariable, getType, getUpdate, hashCode, hasSubqueryForVariable, isCompiled, isSubclasses, isUnique, isUnmodifiable, performDeletePersistentAll, performExecute, prepareDatastore, resolveClassDeclaration, setCandidateClassName, setClass, setExtensions, setFetchPlan, setFilter, setFrom, setGrouping, setHaving, setIgnoreCache, setImplicitParameter, setImplicitParameter, setOrdering, setRange, setRange, setResult, setResultClass, setResultClassName, setResultMetaData, setSubclasses, setType, setUnique, setUnmodifiable, setUpdate, shouldReturnSingleRow
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

candidateExtent

protected transient Extent candidateExtent
Extent of candidates for this query.


candidateCollection

protected transient java.util.Collection candidateCollection
Collection of candidates for this query.


rof

protected transient ResultObjectFactory rof
Factory for obtaining the results from the query result set.


distinct

protected transient boolean distinct
whether to apply "distinct" results.


resultMetaData

protected transient JPOXResultSetMetaData resultMetaData
Result metadata (JPOX extension, allowing access to more info).


singleString

protected java.lang.String singleString
Cached form of the single string form of the query.


userDefinedScalarExpressions

protected static transient java.util.Map userDefinedScalarExpressions
Register of user-defined ScalarExpression, provided via plugins.

Constructor Detail

AbstractJavaQuery

public AbstractJavaQuery(ObjectManager om)
Constructor for a Java-based query.

Parameters:
om - The ObjectManager
Method Detail

setCandidates

public void setCandidates(Extent pcs)
Set the candidate Extent to query.

Specified by:
setCandidates in class Query
Parameters:
pcs - the Candidate Extent.
See Also:
Query.setCandidates(javax.jdo.Extent)

setCandidates

public void setCandidates(java.util.Collection pcs)
Set the candidate Collection to query.

Specified by:
setCandidates in class Query
Parameters:
pcs - the Candidate collection.
See Also:
Query.setCandidates(java.util.Collection)

getCandidateExtent

public Extent getCandidateExtent()
Accessor for the candidate Extent (if specified using an Extent).

Returns:
Candidate Extent

getCandidateCollection

public java.util.Collection getCandidateCollection()
Accessor for the candidate collection (if specified using a collection).

Returns:
Candidate collection

discardCompiled

protected void discardCompiled()
Method to discard our current compiled query due to changes.

Overrides:
discardCompiled in class Query
See Also:
Query.discardCompiled()

getParsedImports

public Imports getParsedImports()
Accessor for the parsed imports. If no imports are set then adds candidate class, user imports, and any user-defined expression packages.

Overrides:
getParsedImports in class Query
Returns:
Parsed imports

getResultSetMetaData

public JPOXResultSetMetaData getResultSetMetaData()
Retrieve the metadata for the results

Returns:
the ResultSetMetaData

resultHasOnlyAggregates

public boolean resultHasOnlyAggregates(java.lang.String result)
Convenience method to simple-parse the "result" clause returning if it includes solely aggregates. This is necessary since we need this information before creating the QueryStatement, after which we compile the result.

Parameters:
result - The result required
Returns:
Whether it has only aggregates

getSingleStringQuery

public abstract java.lang.String getSingleStringQuery()
Accessor for a single string form of the query.

Returns:
Single string form of the query.

toString

public java.lang.String toString()
Stringifier method

Overrides:
toString in class java.lang.Object
Returns:
Single-string form of this JDOQL query.

registerScalarExpression

public static void registerScalarExpression(java.lang.Class literal,
                                            java.lang.Class scalarExpressionClass,
                                            java.lang.String name)
Register ScalarExpressions for the given cls. It allows to perform operations in the query on cls.method([arglist]).

Parameters:
literal - the class providing the operations; e.g. java.lang.Math.class
scalarExpressionClass - the class with the corresponding ScalarExpression. eg. org.jpox.store.expression.MathExpression.class
name - alternative name of the given literal class

registerScalarExpressions

protected void registerScalarExpressions(PluginManager pluginMgr,
                                         ClassLoaderResolver clr)
Register ScalarExpression classes delcared as plug-ins extensions TODO currently register only the first time this class is instantiated. Should be registered per PMF?

Parameters:
pluginMgr - The PluginManager
clr - The ClassLoaderResolver to load the literal and ScalarExpression classes

getUserDefinedScalarExpressions

public static java.util.Map getUserDefinedScalarExpressions()
Accessor for the user-defined scalar expressions.

Returns:
Map of user-defined scalar expressions


Copyright © -2008 . All Rights Reserved.