org.datanucleus.store.mapped.expression
Class UnboundVariable

java.lang.Object
  extended by org.datanucleus.store.mapped.expression.ScalarExpression
      extended by org.datanucleus.store.mapped.expression.UnboundVariable

public class UnboundVariable
extends ScalarExpression

Representation of an unbound variable in a Query.


Nested Class Summary
static interface UnboundVariable.VariableBinder
           
 
Nested classes/interfaces inherited from class org.datanucleus.store.mapped.expression.ScalarExpression
ScalarExpression.DatastoreFieldExpression, ScalarExpression.DyadicOperator, ScalarExpression.ExpressionList, ScalarExpression.IllegalArgumentTypeException, ScalarExpression.IllegalOperationException, ScalarExpression.MethodInvocationException, ScalarExpression.MonadicOperator, ScalarExpression.Operator
 
Field Summary
 
Fields inherited from class org.datanucleus.store.mapped.expression.ScalarExpression
aliasIdentifier, checkForTypeAssignability, expressionList, FILTER, LOCALISER, lowestOperator, mapping, OP_ADD, OP_AND, OP_BETWEEN, OP_COM, OP_CONCAT, OP_DIV, OP_EQ, OP_GT, OP_GTEQ, OP_IN, OP_IS, OP_ISNOT, OP_LIKE, OP_LT, OP_LTEQ, OP_MOD, OP_MUL, OP_NEG, OP_NOT, OP_NOTEQ, OP_NOTIN, OP_NOTLIKE, OP_OR, OP_SUB, parameterName, PROJECTION, qs, st, te
 
Constructor Summary
UnboundVariable(QueryExpression qs, java.lang.String name, java.lang.Class type, UnboundVariable.VariableBinder binder)
          Constructor.
 
Method Summary
 ScalarExpression accessField(java.lang.String fieldName, boolean innerJoin)
          Method to access a field in the class of the variable.
 void bindTo(ScalarExpression qsc)
          Method to bind this variable to its expression, using the JDOQL compiler.
 BooleanExpression eq(ScalarExpression expr)
          Checks if one expression is equals the other expression
 ScalarExpression.ExpressionList getExpressionList()
          Returns the expression list.
 LogicSetExpression getLogicSetExpression()
          Accessor for the table expression being used by this expression.
 java.lang.String getVariableName()
          Accessor for the variable name.
 java.lang.Class getVariableType()
          Accessor for the variable type.
 BooleanExpression noteq(ScalarExpression expr)
          Checks if one expression is not equals the other expression
 void setVariableType(java.lang.Class type)
          Mutator for the variable type in the case where we have an implicit variable and its type is not known at construction.
 StatementText toStatementText()
          StatementText representation of this expression.
 StatementText toStatementText(int mode)
          Change the output statement text to refer to the bound to expression since it has real fields and this is only a variable.
 
Methods inherited from class org.datanucleus.store.mapped.expression.ScalarExpression
add, and, as, assertValidTypeForParameterComparison, callMethod, cast, checkForTypeAssignability, com, div, encloseWithInParentheses, eor, equals, getAlias, getConsistentTypeForParameterComparison, getMapping, getNonAliasExpression, getQueryExpression, gt, gteq, in, instanceOf, ior, lt, lteq, mod, mul, neg, not, setParameterName, sub, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

UnboundVariable

public UnboundVariable(QueryExpression qs,
                       java.lang.String name,
                       java.lang.Class type,
                       UnboundVariable.VariableBinder binder)
Constructor.

Parameters:
qs - The Query Expression
name - Name of the variable
type - Type of the variable (if known at this point)
binder - The Binder that we can bind with this variable when we know which expression to bind to.
Method Detail

getVariableName

public java.lang.String getVariableName()
Accessor for the variable name.

Returns:
The variable name

getLogicSetExpression

public LogicSetExpression getLogicSetExpression()
Description copied from class: ScalarExpression
Accessor for the table expression being used by this expression.

Overrides:
getLogicSetExpression in class ScalarExpression
Returns:
may return null, if type is unknown

getVariableType

public java.lang.Class getVariableType()
Accessor for the variable type.

Returns:
The variable type

setVariableType

public void setVariableType(java.lang.Class type)
Mutator for the variable type in the case where we have an implicit variable and its type is not known at construction. Only updates the type if it was null at construction.

Parameters:
type - The type

bindTo

public void bindTo(ScalarExpression qsc)
Method to bind this variable to its expression, using the JDOQL compiler.

Parameters:
qsc - The expression to bind to.

toStatementText

public StatementText toStatementText(int mode)
Change the output statement text to refer to the bound to expression since it has real fields and this is only a variable.

Overrides:
toStatementText in class ScalarExpression
Parameters:
mode - Mode of operation
Returns:
The statement text for this unbound variable

getExpressionList

public ScalarExpression.ExpressionList getExpressionList()
Description copied from class: ScalarExpression
Returns the expression list.

Overrides:
getExpressionList in class ScalarExpression
Returns:
The expressions list with atomic expressions (ScalarExpression.FieldExpression). A expression in this list can't be split down

toStatementText

public StatementText toStatementText()
StatementText representation of this expression. I.E. A Boolean field may be stored in boolean format like 0 or 1, and it can also be stored in other formats, like Y or N, TRUE or FALSE, and so on. The projection mode for the boolean field is the real content of the value stored, (e.g. Y or N), and opposed to that the filter mode for the boolean field is always represented by a boolean expression (e.g. Y=Y or N=N) In SQL, the projection can be exemplified as "SELECT BOOLEAN_FIELD ... " and the filter as "SELECT COLUMNS ... WHERE BOOLEAN_FIELD ='Y'"

Returns:
the StatementText

eq

public BooleanExpression eq(ScalarExpression expr)
Checks if one expression is equals the other expression

Overrides:
eq in class ScalarExpression
Parameters:
expr - the expression to check if this is equals to the expression
Returns:
the BooleanExpression

noteq

public BooleanExpression noteq(ScalarExpression expr)
Checks if one expression is not equals the other expression

Overrides:
noteq in class ScalarExpression
Parameters:
expr - the expression to check if this is not equals to the expression
Returns:
the BooleanExpression

accessField

public ScalarExpression accessField(java.lang.String fieldName,
                                    boolean innerJoin)
Method to access a field in the class of the variable.

Overrides:
accessField in class ScalarExpression
Parameters:
fieldName - Name of the field to access
innerJoin - whether to use an inner join to access this field
Returns:
The scalar expression for the field


Copyright © 2010. All Rights Reserved.