Cumulus4j API
(1.0.0)

org.cumulus4j.store.query
Class QueryEvaluator

java.lang.Object
  extended by org.cumulus4j.store.query.QueryEvaluator
Direct Known Subclasses:
JDOQueryEvaluator

public abstract class QueryEvaluator
extends Object

API-agnostic query implementation. An instance of this class performs the actual query. It is used by both APIs, JDO and JPA.

Author:
Marco หงุ่ยตระกูล-Schulze - marco at nightlabs dot de

Field Summary
static String RESULTS_SET
          Name under which any set of results are stored in the state map.
 
Constructor Summary
QueryEvaluator(String language, Query query, QueryCompilation compilation, Map<String,Object> parameterValues, ClassLoaderResolver clr, PersistenceManagerConnection pmConn)
           
 
Method Summary
protected abstract  Collection<Object> evaluateSubquery(Query subquery, QueryCompilation compilation, Object outerCandidate)
           
 List<Object> execute()
           
 Set<Long> getAllDataEntryIDsForCandidateClasses(Set<ClassMeta> candidateClassMetas)
           
 String getCandidateAlias()
           
 ClassLoaderResolver getClassLoaderResolver()
           
 QueryCompilation getCompilation()
           
 CryptoContext getCryptoContext()
           
 EncryptionHandler getEncryptionHandler()
           
 ExecutionContext getExecutionContext()
           
 AbstractExpressionEvaluator<?> getExpressionEvaluator()
           
 String getLanguage()
           
 Object getObjectForClassMetaAndObjectIDString(ClassMeta classMeta, String objectIDString)
           
 Object getObjectForDataEntry(DataEntry dataEntry)
           
 Map<String,Object> getParameterValues()
           
 PersistenceManagerConnection getPersistenceManagerConnection()
           
 PersistenceManager getPersistenceManagerForData()
           
 PersistenceManager getPersistenceManagerForIndex()
           
 Query getQuery()
           
 Map<String,Object> getState()
           
 Cumulus4jStoreManager getStoreManager()
           
 Class<?> getValueType(Symbol symbol)
          Get a Symbol's valueType by taking ResultDescriptors into account.
 Class<?> getValueType(Symbol symbol, boolean throwExceptionIfNotFound)
           Get a Symbol's valueType by taking ResultDescriptors into account.
 boolean isComplete()
           
 ResultDescriptor popResultDescriptor()
          Pop a ResultDescriptor from the stack.
 void pushResultDescriptor(ResultDescriptor resultDescriptor)
          Push a ResultDescriptor onto the stack.
 void setIncomplete()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RESULTS_SET

public static final String RESULTS_SET
Name under which any set of results are stored in the state map. Used for aggregation.

See Also:
Constant Field Values
Constructor Detail

QueryEvaluator

public QueryEvaluator(String language,
                      Query query,
                      QueryCompilation compilation,
                      Map<String,Object> parameterValues,
                      ClassLoaderResolver clr,
                      PersistenceManagerConnection pmConn)
Parameters:
language - Query language (JDOQL, JPQL, etc)
compilation - generic compilation
parameterValues - Input values for the params
clr - ClassLoader resolver
pmConn - our backend-PersistenceManager connection(s).
Method Detail

isComplete

public boolean isComplete()

setIncomplete

public void setIncomplete()

getLanguage

public String getLanguage()

getCandidateAlias

public String getCandidateAlias()

getQuery

public Query getQuery()

getCompilation

public QueryCompilation getCompilation()

getParameterValues

public Map<String,Object> getParameterValues()

getState

public Map<String,Object> getState()

getClassLoaderResolver

public ClassLoaderResolver getClassLoaderResolver()

getExecutionContext

public ExecutionContext getExecutionContext()

getStoreManager

public Cumulus4jStoreManager getStoreManager()

getPersistenceManagerConnection

public PersistenceManagerConnection getPersistenceManagerConnection()

getPersistenceManagerForData

public PersistenceManager getPersistenceManagerForData()

getPersistenceManagerForIndex

public PersistenceManager getPersistenceManagerForIndex()

getEncryptionHandler

public EncryptionHandler getEncryptionHandler()

pushResultDescriptor

public void pushResultDescriptor(ResultDescriptor resultDescriptor)
Push a ResultDescriptor onto the stack.

Parameters:
resultDescriptor - the descriptor to be pushed.

popResultDescriptor

public ResultDescriptor popResultDescriptor()
Pop a ResultDescriptor from the stack.

Returns:
the popped descriptor (which is the last one pushed).

getValueType

public Class<?> getValueType(Symbol symbol)
Get a Symbol's valueType by taking ResultDescriptors into account. Delegates to getValueType(Symbol, boolean) with throwExceptionIfNotFound == true.

Parameters:
symbol - the symbol whose valueType should be resolved.
Returns:
the type - never null.
See Also:
getValueType(Symbol, boolean)

getValueType

public Class<?> getValueType(Symbol symbol,
                             boolean throwExceptionIfNotFound)

Get a Symbol's valueType by taking ResultDescriptors into account.

This method (or alternatively getValueType(Symbol)) should always be used instead of directly accessing Symbol.getValueType()!!! This allows for implicit variables (which are not declared).

This method first checks, if Symbol.getValueType() returns a value and if so, returns it. Otherwise it searches the stack of ResultDescriptors (maintained via pushResultDescriptor(ResultDescriptor) and popResultDescriptor()) and returns the first found ResultDescriptor.getResultType().

Parameters:
symbol - the symbol whose valueType should be resolved.
throwExceptionIfNotFound - whether to throw an IllegalStateException [exception type might be changed without notice!], if the type cannot be resolved. If false this method returns null instead.
Returns:
the type or null, if not resolvable and throwExceptionIfNotFound == false.
See Also:
getValueType(Symbol), pushResultDescriptor(ResultDescriptor), popResultDescriptor()

evaluateSubquery

protected abstract Collection<Object> evaluateSubquery(Query subquery,
                                                       QueryCompilation compilation,
                                                       Object outerCandidate)

execute

public List<Object> execute()

getExpressionEvaluator

public AbstractExpressionEvaluator<?> getExpressionEvaluator()

getObjectForDataEntry

public Object getObjectForDataEntry(DataEntry dataEntry)

getObjectForClassMetaAndObjectIDString

public Object getObjectForClassMetaAndObjectIDString(ClassMeta classMeta,
                                                     String objectIDString)

getAllDataEntryIDsForCandidateClasses

public Set<Long> getAllDataEntryIDsForCandidateClasses(Set<ClassMeta> candidateClassMetas)

getCryptoContext

public CryptoContext getCryptoContext()

Cumulus4j API
(1.0.0)

Copyright © 2012 NightLabs Consulting GmbH. All Rights Reserved.