Class JavaValueNode
- java.lang.Object
-
- org.apache.derby.impl.sql.compile.QueryTreeNode
-
- org.apache.derby.impl.sql.compile.JavaValueNode
-
- All Implemented Interfaces:
Visitable
- Direct Known Subclasses:
GetCurrentConnectionNode
,MethodCallNode
,SQLToJavaValueNode
,StaticClassFieldReferenceNode
abstract class JavaValueNode extends QueryTreeNode
This abstract node class represents a data value in the Java domain.
-
-
Field Summary
Fields Modifier and Type Field Description private int
collationType
protected boolean
forCallStatement
protected JSQLType
jsqlType
private boolean
mustCastToPrimitive
private LocalField
receiverField
private boolean
returnValueDiscarded
private boolean
valueReturnedToSQLDomain
-
Fields inherited from class org.apache.derby.impl.sql.compile.QueryTreeNode
AUTOINCREMENT_CREATE_MODIFY, AUTOINCREMENT_CYCLE, AUTOINCREMENT_INC_INDEX, AUTOINCREMENT_IS_AUTOINCREMENT_INDEX, AUTOINCREMENT_START_INDEX
-
-
Constructor Summary
Constructors Constructor Description JavaValueNode(ContextManager cm)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description (package private) abstract JavaValueNode
bindExpression(FromList fromList, SubqueryList subqueryList, java.util.List<AggregateNode> aggregates)
(package private) void
castToPrimitive(boolean booleanValue)
Toggles whether the code generator should add a cast to extract a primitive value from an object.(package private) abstract boolean
categorize(JBitSet referencedTabs, boolean simplePredsOnly)
(package private) void
checkReliability(ValueNode sqlNode)
Check the reliability type of this java value.(package private) void
generate(ActivationClassBuilder acb, MethodBuilder mb)
Do the code generation for this node.(package private) abstract void
generateExpression(ExpressionClassBuilder acb, MethodBuilder mb)
General logic shared by Core compilation and by the Replication Filter compiler.(package private) boolean
generateReceiver(ExpressionClassBuilder acb, MethodBuilder mb)
Generate the expression that evaluates to the receiver.(package private) boolean
generateReceiver(ExpressionClassBuilder acb, MethodBuilder mb, JavaValueNode receiver)
Generate the expression that evaluates to the receiver.(package private) int
getCollationType()
(package private) java.lang.Object
getConstantValueAsObject()
(package private) DataTypeDescriptor
getDataType()
Get the resolved data type of this node.(package private) java.lang.String
getJavaTypeName()
(package private) JSQLType
getJSQLType()
Get the JSQLType that corresponds to this node.(package private) int
getOrderableVariantType()
Return the variant type for the underlying expression.(package private) java.lang.String
getPrimitiveTypeName()
(package private) void
getReceiverExpression(ExpressionClassBuilder acb, MethodBuilder mb, JavaValueNode receiver)
Get an expression that has the value of the receiver.(package private) boolean
isPrimitiveType()
(package private) static TypeId
mapToTypeID(JSQLType jsqlType)
Map a JSQLType to a compilation type id.(package private) void
markForCallStatement()
Mark this node as being for a CALL Statement.(package private) void
markReturnValueDiscarded()
Tell this node that nothing is done with the returned value(package private) boolean
mustCastToPrimitive()
Reports whether the code generator should add a cast to extract a primitive value from an object.(package private) abstract void
preprocess(int numTables, FromList outerFromList, SubqueryList outerSubqueryList, PredicateList outerPredicateList)
(package private) abstract JavaValueNode
remapColumnReferencesToExpressions()
(package private) boolean
returnValueDiscarded()
Tell whether the return value from this node is discarded(package private) void
returnValueToSQLDomain()
Inform this node that it returns its value to the SQL domain(package private) void
setCollationType(int type)
Set the collation type.(package private) void
setJavaTypeName(java.lang.String javaTypeName)
(package private) boolean
valueReturnedToSQLDomain()
Tell whether this node returns its value to the SQL domain-
Methods inherited from class org.apache.derby.impl.sql.compile.QueryTreeNode
accept, acceptChildren, addTag, addUDTUsagePriv, addUDTUsagePriv, bindOffsetFetch, bindRowMultiSet, bindUserCatalogType, bindUserType, checkReliability, checkReliability, convertDefaultNode, copyTagsFrom, createTypeDependency, debugFlush, debugPrint, disablePrivilegeCollection, formatNodeString, generateAuthorizeCheck, getBeginOffset, getClassFactory, getCompilerContext, getContext, getContextManager, getDataDictionary, getDependencyManager, getEndOffset, getExecutionFactory, getGenericConstantActionFactory, getIntProperty, getLanguageConnectionContext, getLongProperty, getNullNode, getOffsetOrderedNodes, getOptimizerFactory, getOptimizerTracer, getParameterTypes, getSchemaDescriptor, getSchemaDescriptor, getStatementType, getTableDescriptor, getTypeCompiler, getUDTDesc, isAtomic, isPrivilegeCollectionRequired, isSessionSchema, isSessionSchema, makeConstantAction, makeTableName, makeTableName, nodeHeader, optimizerTracingIsOn, orReliability, parseSearchCondition, parseStatement, printLabel, printSubNodes, referencesSessionSchema, resolveTableToSynonym, setBeginOffset, setEndOffset, setRefActionInfo, stackPrint, taggedWith, toString, treePrint, treePrint, verifyClassExist
-
-
-
-
Field Detail
-
mustCastToPrimitive
private boolean mustCastToPrimitive
-
forCallStatement
protected boolean forCallStatement
-
valueReturnedToSQLDomain
private boolean valueReturnedToSQLDomain
-
returnValueDiscarded
private boolean returnValueDiscarded
-
jsqlType
protected JSQLType jsqlType
-
receiverField
private LocalField receiverField
-
collationType
private int collationType
-
-
Constructor Detail
-
JavaValueNode
JavaValueNode(ContextManager cm)
-
-
Method Detail
-
getDataType
DataTypeDescriptor getDataType() throws StandardException
Get the resolved data type of this node. May be overridden by descendants.- Throws:
StandardException
-
isPrimitiveType
final boolean isPrimitiveType() throws StandardException
- Throws:
StandardException
-
getJavaTypeName
java.lang.String getJavaTypeName() throws StandardException
- Throws:
StandardException
-
setJavaTypeName
final void setJavaTypeName(java.lang.String javaTypeName)
-
getPrimitiveTypeName
java.lang.String getPrimitiveTypeName() throws StandardException
- Throws:
StandardException
-
castToPrimitive
final void castToPrimitive(boolean booleanValue)
Toggles whether the code generator should add a cast to extract a primitive value from an object.- Parameters:
booleanValue
- true if we want the code generator to add a cast false otherwise
-
mustCastToPrimitive
final boolean mustCastToPrimitive()
Reports whether the code generator should add a cast to extract a primitive value from an object.- Returns:
- true if we want the code generator to add a cast false otherwise
-
getJSQLType
JSQLType getJSQLType() throws StandardException
Get the JSQLType that corresponds to this node. Could be a SQLTYPE, a Java primitive, or a Java class.- Returns:
- the corresponding JSQLType
- Throws:
StandardException
-
mapToTypeID
static TypeId mapToTypeID(JSQLType jsqlType) throws StandardException
Map a JSQLType to a compilation type id.- Parameters:
jsqlType
- the universal type to map- Returns:
- the corresponding compilation type id
- Throws:
StandardException
-
markForCallStatement
final void markForCallStatement()
Mark this node as being for a CALL Statement. (void methods are only okay for CALL Statements)
-
remapColumnReferencesToExpressions
abstract JavaValueNode remapColumnReferencesToExpressions() throws StandardException
- Throws:
StandardException
- Thrown on error- See Also:
ValueNode.remapColumnReferencesToExpressions()
-
categorize
abstract boolean categorize(JBitSet referencedTabs, boolean simplePredsOnly) throws StandardException
- Throws:
StandardException
- Thrown on error- See Also:
ValueNode.categorize(org.apache.derby.iapi.util.JBitSet, boolean)
-
bindExpression
abstract JavaValueNode bindExpression(FromList fromList, SubqueryList subqueryList, java.util.List<AggregateNode> aggregates) throws StandardException
- Returns:
- the new node, usually this
- Throws:
StandardException
- Thrown on error- See Also:
ValueNode.bindExpression(org.apache.derby.impl.sql.compile.FromList, org.apache.derby.impl.sql.compile.SubqueryList, java.util.List<org.apache.derby.impl.sql.compile.AggregateNode>)
-
preprocess
abstract void preprocess(int numTables, FromList outerFromList, SubqueryList outerSubqueryList, PredicateList outerPredicateList) throws StandardException
-
getConstantValueAsObject
java.lang.Object getConstantValueAsObject() throws StandardException
- Throws:
StandardException
- Thrown on error- See Also:
ValueNode.getConstantValueAsObject()
-
generate
final void generate(ActivationClassBuilder acb, MethodBuilder mb) throws StandardException
Do the code generation for this node. Call the more general routine that generates expressions.- Overrides:
generate
in classQueryTreeNode
- Parameters:
acb
- The ActivationClassBuilder for the class being builtmb
- the method the expression will go into- Throws:
StandardException
- Thrown on error
-
generateReceiver
boolean generateReceiver(ExpressionClassBuilder acb, MethodBuilder mb) throws StandardException
Generate the expression that evaluates to the receiver. This is for the case where a java expression is being returned to the SQL domain, and we need to check whether the receiver is null (if so, the SQL value should be set to null, and this Java expression not evaluated). Instance method calls and field references have receivers, while class method calls and calls to constructors do not. If this Java expression does not have a receiver, this method returns null. The implementation of this method should only generate the receiver once and cache it in a field. This is because there will be two references to the receiver, and we want to evaluate it only once.- Parameters:
acb
- The ExpressionClassBuilder for the class being builtmb
- the method the expression will go into- Returns:
- True if has compiled receiver.
- Throws:
StandardException
- Thrown on error
-
getOrderableVariantType
int getOrderableVariantType() throws StandardException
Return the variant type for the underlying expression. The variant type can be: VARIANT - variant within a scan (method calls and non-static field access) SCAN_INVARIANT - invariant within a scan (column references from outer tables) QUERY_INVARIANT - invariant within the life of a query (constant expressions)- Returns:
- The variant type for the underlying expression.
- Throws:
StandardException
-
generateExpression
abstract void generateExpression(ExpressionClassBuilder acb, MethodBuilder mb) throws StandardException
General logic shared by Core compilation and by the Replication Filter compiler. Every child of ValueNode must implement one of these methods.- Parameters:
acb
- The ExpressionClassBuilder for the class being builtmb
- the method the expression will go into- Throws:
StandardException
- Thrown on error
-
generateReceiver
final boolean generateReceiver(ExpressionClassBuilder acb, MethodBuilder mb, JavaValueNode receiver) throws StandardException
Generate the expression that evaluates to the receiver. This is for the case where a java expression is being returned to the SQL domain, and we need to check whether the receiver is null (if so, the SQL value should be set to null, and this Java expression not evaluated). Instance method calls and field references have receivers, while class method calls and calls to constructors do not. If this Java expression does not have a receiver, this method returns null. This also covers the case where a java expression is being returned to the Java domain. In this case, we need to check whether the receiver is null only if the value returned by the Java expression is an object (not a primitive type). We don't want to generate the expression here if we are returning a primitive type to the Java domain, because there's no point in checking whether the receiver is null in this case (we can't make the expression return a null value). Only generate the receiver once and cache it in a field. This is because there will be two references to the receiver, and we want to evaluate it only once.- Parameters:
acb
- The ActivationClassBuilder for the class being builtmb
- the method the expression will go intoreceiver
- The query tree form of the receiver expression- Returns:
- The compiled receiver, if any.
- Throws:
StandardException
- Thrown on error
-
getReceiverExpression
final void getReceiverExpression(ExpressionClassBuilder acb, MethodBuilder mb, JavaValueNode receiver) throws StandardException
Get an expression that has the value of the receiver. If a field holding the receiver value was already generated, use that. If not, generate the receiver value.- Parameters:
acb
- The ExpressionClassBuilder for the class we're generatingmb
- the method the expression will go intoreceiver
- The query tree form of the receiver expression- Throws:
StandardException
- Thrown on error
-
returnValueToSQLDomain
void returnValueToSQLDomain()
Inform this node that it returns its value to the SQL domain
-
valueReturnedToSQLDomain
boolean valueReturnedToSQLDomain()
Tell whether this node returns its value to the SQL domain
-
markReturnValueDiscarded
void markReturnValueDiscarded()
Tell this node that nothing is done with the returned value
-
returnValueDiscarded
boolean returnValueDiscarded()
Tell whether the return value from this node is discarded
-
checkReliability
void checkReliability(ValueNode sqlNode) throws StandardException
Check the reliability type of this java value.- Throws:
StandardException
- Thrown on error- See Also:
CompilerContext
-
getCollationType
int getCollationType()
- Returns:
- collationType as set by setCollationType
-
setCollationType
void setCollationType(int type)
Set the collation type. This will be used to determine the collation type for the SQLToJavaValueNode.- Parameters:
type
- one ofStringDataValue.COLLATION_TYPE_UCS_BASIC
orStringDataValue.COLLATION_TYPE_TERRITORY_BASED
-
-