org.datanucleus.query.evaluator.memory
Class InMemoryExpressionEvaluator

java.lang.Object
  extended by org.datanucleus.query.evaluator.AbstractExpressionEvaluator
      extended by org.datanucleus.query.evaluator.memory.InMemoryExpressionEvaluator
All Implemented Interfaces:
ExpressionEvaluator

public class InMemoryExpressionEvaluator
extends AbstractExpressionEvaluator

Class providing evaluation of java "string-based" queries in-memory.


Field Summary
protected static Localiser LOCALISER
          Localisation utility for output messages
 
Constructor Summary
InMemoryExpressionEvaluator(ObjectManager om, java.util.Map params, java.util.Map<java.lang.String,java.lang.Object> state, Imports imports, ClassLoaderResolver clr, java.lang.String candidateAlias)
          Constructor for an in-memory evaluator.
 
Method Summary
 int getIntegerForLiteral(Literal lit)
          Convenience method to get an int value from the supplied literal.
 java.util.Map getParameterValues()
           
 java.lang.Object getValueForInvokeExpression(InvokeExpression invokeExpr)
          Method to evaluate an InvokeExpression.
 java.lang.Object getValueForPrimaryExpression(PrimaryExpression primExpr)
          Convenience method to get the value for a PrimaryExpression.
 java.lang.Object getValueForVariableExpression(VariableExpression varExpr)
          Convenience method to get the (current) value for a VariableExpression.
protected  java.lang.Object processAddExpression(Expression expr)
          Method to process the supplied ADD expression.
protected  java.lang.Object processAndExpression(Expression expr)
          Method to process the supplied AND expression.
protected  java.lang.Object processComExpression(Expression expr)
          Method to process the supplied COM expression.
protected  java.lang.Object processCreatorExpression(CreatorExpression expr)
          Method to process the supplied creator expression.
protected  java.lang.Object processDivExpression(Expression expr)
          Method to process the supplied DIV expression.
protected  java.lang.Object processEqExpression(Expression expr)
          Method to process the supplied EQ expression.
protected  java.lang.Object processGteqExpression(Expression expr)
          Method to process the supplied GTEQ expression.
protected  java.lang.Object processGtExpression(Expression expr)
          Method to process the supplied GT expression.
protected  java.lang.Object processInvokeExpression(InvokeExpression expr)
          Method to process the supplied invoke expression.
protected  java.lang.Object processIsExpression(Expression expr)
          Method to process the supplied IS (instanceof) expression.
protected  java.lang.Object processLikeExpression(Expression expr)
          Method to process the supplied LIKE expression.
protected  java.lang.Object processLiteral(Literal expr)
          Method to process the supplied invoke expression.
protected  java.lang.Object processLteqExpression(Expression expr)
          Method to process the supplied LTEQ expression.
protected  java.lang.Object processLtExpression(Expression expr)
          Method to process the supplied LT expression.
protected  java.lang.Object processModExpression(Expression expr)
          Method to process the supplied MOD expression.
protected  java.lang.Object processMulExpression(Expression expr)
          Method to process the supplied MUL expression.
protected  java.lang.Object processNegExpression(Expression expr)
          Method to process the supplied NEG expression.
protected  java.lang.Object processNoteqExpression(Expression expr)
          Method to process the supplied NOTEQ expression.
protected  java.lang.Object processNotExpression(Expression expr)
          Method to process the supplied NOT expression.
protected  java.lang.Object processOrExpression(Expression expr)
          Method to process the supplied OR expression.
protected  java.lang.Object processParameterExpression(ParameterExpression expr)
          Method to process the supplied parameter expression.
protected  java.lang.Object processPrimaryExpression(PrimaryExpression expr)
          Method to process the supplied primary expression.
protected  java.lang.Object processSubExpression(Expression expr)
          Method to process the supplied SUB expression.
protected  java.lang.Object processVariableExpression(VariableExpression expr)
          Method to process the supplied variable expression.
 void removeVariableValue(java.lang.String id)
          Method to remove a variable value.
 void setVariableValue(java.lang.String id, java.lang.Object value)
          Method to set the value for a variable.
 
Methods inherited from class org.datanucleus.query.evaluator.AbstractExpressionEvaluator
compileAdditiveMultiplicativeExpression, compileOrAndExpression, compilePrimaryExpression, compileRelationalExpression, compileUnaryExpression, evaluate, processCastExpression, processDistinctExpression, processInExpression, processIsnotExpression, processSubqueryExpression
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOCALISER

protected static final Localiser LOCALISER
Localisation utility for output messages

Constructor Detail

InMemoryExpressionEvaluator

public InMemoryExpressionEvaluator(ObjectManager om,
                                   java.util.Map params,
                                   java.util.Map<java.lang.String,java.lang.Object> state,
                                   Imports imports,
                                   ClassLoaderResolver clr,
                                   java.lang.String candidateAlias)
Constructor for an in-memory evaluator.

Parameters:
om - ObjectManager
params - Input parameters
state - Map of state values keyed by their symbolic name
imports - Any imports
clr - ClassLoader resolver
candidateAlias - Alias for the candidate class. With JDOQL this is "this".
Method Detail

getParameterValues

public java.util.Map getParameterValues()

processAndExpression

protected java.lang.Object processAndExpression(Expression expr)
Description copied from class: AbstractExpressionEvaluator
Method to process the supplied AND expression. To be implemented by subclasses.

Overrides:
processAndExpression in class AbstractExpressionEvaluator
Parameters:
expr - The expression
Returns:
The result

processEqExpression

protected java.lang.Object processEqExpression(Expression expr)
Description copied from class: AbstractExpressionEvaluator
Method to process the supplied EQ expression. To be implemented by subclasses.

Overrides:
processEqExpression in class AbstractExpressionEvaluator
Parameters:
expr - The expression
Returns:
The result

processLikeExpression

protected java.lang.Object processLikeExpression(Expression expr)
Description copied from class: AbstractExpressionEvaluator
Method to process the supplied LIKE expression. To be implemented by subclasses.

Overrides:
processLikeExpression in class AbstractExpressionEvaluator
Parameters:
expr - The expression
Returns:
The result

processNoteqExpression

protected java.lang.Object processNoteqExpression(Expression expr)
Description copied from class: AbstractExpressionEvaluator
Method to process the supplied NOTEQ expression. To be implemented by subclasses.

Overrides:
processNoteqExpression in class AbstractExpressionEvaluator
Parameters:
expr - The expression
Returns:
The result

processOrExpression

protected java.lang.Object processOrExpression(Expression expr)
Description copied from class: AbstractExpressionEvaluator
Method to process the supplied OR expression. To be implemented by subclasses.

Overrides:
processOrExpression in class AbstractExpressionEvaluator
Parameters:
expr - The expression
Returns:
The result

processGteqExpression

protected java.lang.Object processGteqExpression(Expression expr)
Description copied from class: AbstractExpressionEvaluator
Method to process the supplied GTEQ expression. To be implemented by subclasses.

Overrides:
processGteqExpression in class AbstractExpressionEvaluator
Parameters:
expr - The expression
Returns:
The result

processGtExpression

protected java.lang.Object processGtExpression(Expression expr)
Description copied from class: AbstractExpressionEvaluator
Method to process the supplied GT expression. To be implemented by subclasses.

Overrides:
processGtExpression in class AbstractExpressionEvaluator
Parameters:
expr - The expression
Returns:
The result

processIsExpression

protected java.lang.Object processIsExpression(Expression expr)
Description copied from class: AbstractExpressionEvaluator
Method to process the supplied IS (instanceof) expression. To be implemented by subclasses.

Overrides:
processIsExpression in class AbstractExpressionEvaluator
Parameters:
expr - The expression
Returns:
The result

processLteqExpression

protected java.lang.Object processLteqExpression(Expression expr)
Description copied from class: AbstractExpressionEvaluator
Method to process the supplied LTEQ expression. To be implemented by subclasses.

Overrides:
processLteqExpression in class AbstractExpressionEvaluator
Parameters:
expr - The expression
Returns:
The result

processLtExpression

protected java.lang.Object processLtExpression(Expression expr)
Description copied from class: AbstractExpressionEvaluator
Method to process the supplied LT expression. To be implemented by subclasses.

Overrides:
processLtExpression in class AbstractExpressionEvaluator
Parameters:
expr - The expression
Returns:
The result

processAddExpression

protected java.lang.Object processAddExpression(Expression expr)
Description copied from class: AbstractExpressionEvaluator
Method to process the supplied ADD expression. To be implemented by subclasses.

Overrides:
processAddExpression in class AbstractExpressionEvaluator
Parameters:
expr - The expression
Returns:
The result

processSubExpression

protected java.lang.Object processSubExpression(Expression expr)
Description copied from class: AbstractExpressionEvaluator
Method to process the supplied SUB expression. To be implemented by subclasses.

Overrides:
processSubExpression in class AbstractExpressionEvaluator
Parameters:
expr - The expression
Returns:
The result

processDivExpression

protected java.lang.Object processDivExpression(Expression expr)
Description copied from class: AbstractExpressionEvaluator
Method to process the supplied DIV expression. To be implemented by subclasses.

Overrides:
processDivExpression in class AbstractExpressionEvaluator
Parameters:
expr - The expression
Returns:
The result

processModExpression

protected java.lang.Object processModExpression(Expression expr)
Description copied from class: AbstractExpressionEvaluator
Method to process the supplied MOD expression. To be implemented by subclasses.

Overrides:
processModExpression in class AbstractExpressionEvaluator
Parameters:
expr - The expression
Returns:
The result

processMulExpression

protected java.lang.Object processMulExpression(Expression expr)
Description copied from class: AbstractExpressionEvaluator
Method to process the supplied MUL expression. To be implemented by subclasses.

Overrides:
processMulExpression in class AbstractExpressionEvaluator
Parameters:
expr - The expression
Returns:
The result

processNegExpression

protected java.lang.Object processNegExpression(Expression expr)
Description copied from class: AbstractExpressionEvaluator
Method to process the supplied NEG expression. To be implemented by subclasses.

Overrides:
processNegExpression in class AbstractExpressionEvaluator
Parameters:
expr - The expression
Returns:
The result

processComExpression

protected java.lang.Object processComExpression(Expression expr)
Description copied from class: AbstractExpressionEvaluator
Method to process the supplied COM expression. To be implemented by subclasses.

Overrides:
processComExpression in class AbstractExpressionEvaluator
Parameters:
expr - The expression
Returns:
The result

processNotExpression

protected java.lang.Object processNotExpression(Expression expr)
Description copied from class: AbstractExpressionEvaluator
Method to process the supplied NOT expression. To be implemented by subclasses.

Overrides:
processNotExpression in class AbstractExpressionEvaluator
Parameters:
expr - The expression
Returns:
The result

processCreatorExpression

protected java.lang.Object processCreatorExpression(CreatorExpression expr)
Description copied from class: AbstractExpressionEvaluator
Method to process the supplied creator expression. To be implemented by subclasses.

Overrides:
processCreatorExpression in class AbstractExpressionEvaluator
Parameters:
expr - The expression
Returns:
The result

processInvokeExpression

protected java.lang.Object processInvokeExpression(InvokeExpression expr)
Description copied from class: AbstractExpressionEvaluator
Method to process the supplied invoke expression. To be implemented by subclasses.

Overrides:
processInvokeExpression in class AbstractExpressionEvaluator
Parameters:
expr - The expression
Returns:
The result

processLiteral

protected java.lang.Object processLiteral(Literal expr)
Description copied from class: AbstractExpressionEvaluator
Method to process the supplied invoke expression. To be implemented by subclasses.

Overrides:
processLiteral in class AbstractExpressionEvaluator
Parameters:
expr - The expression
Returns:
The result

processVariableExpression

protected java.lang.Object processVariableExpression(VariableExpression expr)
Method to process the supplied variable expression. To be implemented by subclasses.

Overrides:
processVariableExpression in class AbstractExpressionEvaluator
Parameters:
expr - The expression
Returns:
The result

processParameterExpression

protected java.lang.Object processParameterExpression(ParameterExpression expr)
Description copied from class: AbstractExpressionEvaluator
Method to process the supplied parameter expression. To be implemented by subclasses.

Overrides:
processParameterExpression in class AbstractExpressionEvaluator
Parameters:
expr - The expression
Returns:
The result

processPrimaryExpression

protected java.lang.Object processPrimaryExpression(PrimaryExpression expr)
Description copied from class: AbstractExpressionEvaluator
Method to process the supplied primary expression. To be implemented by subclasses.

Overrides:
processPrimaryExpression in class AbstractExpressionEvaluator
Parameters:
expr - The expression
Returns:
The result

getValueForInvokeExpression

public java.lang.Object getValueForInvokeExpression(InvokeExpression invokeExpr)
Method to evaluate an InvokeExpression. Will navigate along chained invocations, evaluating the first one, then the second one etc until it gets the value for the passed in expression.

Parameters:
invokeExpr - The InvokeExpression
Returns:
The value

getIntegerForLiteral

public int getIntegerForLiteral(Literal lit)
Convenience method to get an int value from the supplied literal. Returns a value if it is convertible into an int.

Parameters:
lit - The literal
Returns:
The int value
Throws:
NucleusException - if impossible to convert into an int

getValueForPrimaryExpression

public java.lang.Object getValueForPrimaryExpression(PrimaryExpression primExpr)
Convenience method to get the value for a PrimaryExpression.

Parameters:
primExpr - Expression
Returns:
The value in the object for this expression

setVariableValue

public void setVariableValue(java.lang.String id,
                             java.lang.Object value)
Method to set the value for a variable.

Parameters:
id - Id of the variable
value - The value to use

removeVariableValue

public void removeVariableValue(java.lang.String id)
Method to remove a variable value.

Parameters:
id - The id of the variable

getValueForVariableExpression

public java.lang.Object getValueForVariableExpression(VariableExpression varExpr)
Convenience method to get the (current) value for a VariableExpression. If the variable has no current value, throws a VariableNotSetException.

Parameters:
varExpr - Variable Expression
Returns:
The value
Throws:
VariableNotSetException - Thrown when the variable has no value currently set.


Copyright © 2010. All Rights Reserved.