Top Description Fields Constructors Methods
org.apache.derby.impl.sql.compile

pack-priv Class SQLToJavaValueNode

extends JavaValueNode
Class Inheritance
Imports
java.lang.reflect.Modifier, java.util.List, org.apache.derby.shared.common.error.StandardException, org.apache.derby.shared.common.reference.ClassName, org.apache.derby.iapi.services.classfile.VMOpcode, org.apache.derby.iapi.services.compiler.LocalField, .MethodBuilder, org.apache.derby.iapi.services.context.ContextManager, org.apache.derby.shared.common.sanity.SanityManager, org.apache.derby.iapi.sql.compile.Visitor, org.apache.derby.iapi.types.DataTypeDescriptor, .JSQLType, org.apache.derby.iapi.util.JBitSet

This node type converts a value in the SQL domain to a value in the Java domain.

Field Summary

Modifier and TypeField and Description
pack-priv LocalField
returnsNullOnNullState

If set then this SQL value is being passed into a SQL function declared RETURNS NULL ON NULL input.

pack-priv ValueNode
Inherited from org.apache.derby.impl.sql.compile.JavaValueNode:
forCallStatementjsqlType

Constructor Summary

AccessConstructor and Description
pack-priv
SQLToJavaValueNode(ValueNode
A ValueNode representing a SQL value to convert to the Java domain.
value
,
ContextManager
The context manager
cm
)

Constructor for a SQLToJavaValueNode

Method Summary

Modifier and TypeMethod and Description
pack-priv void
acceptChildren(Visitor
the visitor
v
)

Overrides org.apache.derby.impl.sql.compile.QueryTreeNode.acceptChildren.

Accept the visitor for all visitable children of this node.

pack-priv JavaValueNode

Returns:

this
bindExpression
(FromList
The FROM list for the query this expression is in, for binding columns.
fromList
,
SubqueryList
The subquery list being built as we find SubqueryNodes
subqueryList
,
List<AggregateNode>
The aggregate list being built as we find AggregateNodes
aggregates
)

Implements abstract org.apache.derby.impl.sql.compile.JavaValueNode.bindExpression.

Bind this expression.

pack-priv boolean

Returns:

boolean Whether or not source.expression is a ColumnReference or a VirtualColumnNode.
categorize
(JBitSet
JBitSet with bit map of referenced FromTables
referencedTabs
,
boolean
Whether or not to consider method calls, field references and conditional nodes when building bit map
simplePredsOnly
)

Implements abstract org.apache.derby.impl.sql.compile.JavaValueNode.categorize.

Categorize this predicate.

pack-priv void
generateExpression(ExpressionClassBuilder
The ExpressionClassBuilder for the class being built
acb
,
MethodBuilder
The method the expression will go into
mb
)

Implements abstract org.apache.derby.impl.sql.compile.JavaValueNode.generateExpression.

Generate code to get the Java value out of a SQL value.

private void
generateJavaValue(ExpressionClassBuilder
The ExpressionClassBuilder for the class being built
acb
,
MethodBuilder
The method the expression will go into
mbex
)

Generate code to cast the SQLValue to a Java value.

private void
generateReturnsNullOnNullCheck(MethodBuilder mb)

Generate the code for the returns Null on Null input check..

private void
generateSQLValue(ExpressionClassBuilder
The ExpressionClassBuilder for the class being built
acb
,
MethodBuilder
The method the expression will go into
mb
)

Generate the SQLvalue that this node wraps.

pack-priv Object
pack-priv DataTypeDescriptor
getDataType()

Overrides org.apache.derby.impl.sql.compile.JavaValueNode.getDataType.

Get the resolved data type of this node.

pack-priv String

Returns:

name of java class type
getJavaTypeName
()

Overrides org.apache.derby.impl.sql.compile.JavaValueNode.getJavaTypeName.

Returns the name of the java class type that this node coerces to.

pack-priv JSQLType

Returns:

the corresponding JSQLType
getJSQLType
()

Overrides org.apache.derby.impl.sql.compile.JavaValueNode.getJSQLType.

Get the JSQLType that corresponds to this node.

pack-priv int

Returns:

The variant type for the underlying expression.
getOrderableVariantType
()

Overrides org.apache.derby.impl.sql.compile.JavaValueNode.getOrderableVariantType.

Return the variant type for the underlying expression.

pack-priv String

Returns:

name of java primitive type
getPrimitiveTypeName
()

Overrides org.apache.derby.impl.sql.compile.JavaValueNode.getPrimitiveTypeName.

Returns the name of the java primitive type that this node coerces to.

private String

Returns:

name of interface corresponding to SQLValue
getSQLValueInterfaceName
()

Get the type name of the SQLValue we generate.

pack-priv ValueNode

Returns:

The underlying SQL ValueNode
getSQLValueNode
()

Get the SQL ValueNode that is being converted to a JavaValueNode

pack-priv void
preprocess(int
Number of tables in the DML Statement
numTables
,
FromList
FromList from outer query block
outerFromList
,
SubqueryList
SubqueryList from outer query block
outerSubqueryList
,
PredicateList
PredicateList from outer query block
outerPredicateList
)

Implements abstract org.apache.derby.impl.sql.compile.JavaValueNode.preprocess.

Preprocess an expression tree.

pack-priv void
printSubNodes(int
The depth of this node in the tree
depth
)

Overrides org.apache.derby.impl.sql.compile.QueryTreeNode.printSubNodes.

Prints the sub-nodes of this object.

pack-priv JavaValueNode

Returns:

JavaValueNode The remapped expression tree.
remapColumnReferencesToExpressions
()

Implements abstract org.apache.derby.impl.sql.compile.JavaValueNode.remapColumnReferencesToExpressions.

Remap all ColumnReferences in this tree to be clones of the underlying expression.

Inherited from org.apache.derby.impl.sql.compile.JavaValueNode:
castToPrimitivecheckReliabilitygenerategenerateReceivergenerateReceivergetCollationTypegetReceiverExpressionisPrimitiveTypemapToTypeIDmarkForCallStatementmarkReturnValueDiscardedmustCastToPrimitivereturnValueDiscardedreturnValueToSQLDomainsetCollationTypesetJavaTypeNamevalueReturnedToSQLDomain

Field Detail

returnsNullOnNullStateback to summary
pack-priv LocalField returnsNullOnNullState

If set then this SQL value is being passed into a SQL function declared RETURNS NULL ON NULL input. In this case this node performs NULL checking logic in addition simple translation from the SQL domain to the Java domain. Thus if this is set then this node can not be removed when it is paired with a JavaToSQLValueNode. This field is set at generate time of the enclosing StaticMethodCallNode.

valueback to summary
pack-priv ValueNode value

Constructor Detail

SQLToJavaValueNodeback to summary
pack-priv SQLToJavaValueNode(ValueNode value, ContextManager cm)

Constructor for a SQLToJavaValueNode

Parameters
value:ValueNode

A ValueNode representing a SQL value to convert to the Java domain.

cm:ContextManager

The context manager

Method Detail

acceptChildrenback to summary
pack-priv void acceptChildren(Visitor v) throws StandardException

Overrides org.apache.derby.impl.sql.compile.QueryTreeNode.acceptChildren.

Accept the visitor for all visitable children of this node.

Parameters
v:Visitor

the visitor

Annotations
@Override
Exceptions
StandardException:
on error
bindExpressionback to summary
pack-priv JavaValueNode bindExpression(FromList fromList, SubqueryList subqueryList, List<AggregateNode> aggregates) throws StandardException

Implements abstract org.apache.derby.impl.sql.compile.JavaValueNode.bindExpression.

Bind this expression. This means binding the sub-expressions, as well as figuring out what the return type is for this expression.

Parameters
fromList:FromList

The FROM list for the query this expression is in, for binding columns.

subqueryList:SubqueryList

The subquery list being built as we find SubqueryNodes

aggregates:List<AggregateNode>

The aggregate list being built as we find AggregateNodes

Returns:JavaValueNode

this

Exceptions
StandardException:
Thrown on error
categorizeback to summary
pack-priv boolean categorize(JBitSet referencedTabs, boolean simplePredsOnly) throws StandardException

Implements abstract org.apache.derby.impl.sql.compile.JavaValueNode.categorize.

Categorize this predicate. Initially, this means building a bit map of the referenced tables for each predicate. If the source of this ColumnReference (at the next underlying level) is not a ColumnReference or a VirtualColumnNode then this predicate will not be pushed down. For example, in: select * from (select 1 from s) a (x) where x = 1 we will not push down x = 1.

Note

It would be easy to handle the case of a constant, but if the inner SELECT returns an arbitrary expression, then we would have to copy that tree into the pushed predicate, and that tree could contain subqueries and method calls. RESOLVE - revisit this issue once we have views.

Parameters
referencedTabs:JBitSet

JBitSet with bit map of referenced FromTables

simplePredsOnly:boolean

Whether or not to consider method calls, field references and conditional nodes when building bit map

Returns:boolean

boolean Whether or not source.expression is a ColumnReference or a VirtualColumnNode.

Exceptions
StandardException:
Thrown on error
generateExpressionback to summary
pack-priv void generateExpression(ExpressionClassBuilder acb, MethodBuilder mb) throws StandardException

Implements abstract org.apache.derby.impl.sql.compile.JavaValueNode.generateExpression.

Generate code to get the Java value out of a SQL value. Every SQL type has a corresponding Java type. The getObject() method on the SQL type gets the right Java type. The generated code will be: () ((DataValueDescriptor) .getObject()) where comes from the getCorrespondingJavaTypeName() method of the value's TypeId.

Parameters
acb:ExpressionClassBuilder

The ExpressionClassBuilder for the class being built

mb:MethodBuilder

The method the expression will go into

Exceptions
StandardException:
Thrown on error
generateJavaValueback to summary
private void generateJavaValue(ExpressionClassBuilder acb, MethodBuilder mbex) throws StandardException

Generate code to cast the SQLValue to a Java value.

Parameters
acb:ExpressionClassBuilder

The ExpressionClassBuilder for the class being built

mbex:MethodBuilder

The method the expression will go into

Exceptions
StandardException:
Thrown on error
generateReturnsNullOnNullCheckback to summary
private void generateReturnsNullOnNullCheck(MethodBuilder mb)

Generate the code for the returns Null on Null input check.. Stack must contain the DataDescriptorValue.

generateSQLValueback to summary
private void generateSQLValue(ExpressionClassBuilder acb, MethodBuilder mb) throws StandardException

Generate the SQLvalue that this node wraps.

Parameters
acb:ExpressionClassBuilder

The ExpressionClassBuilder for the class being built

mb:MethodBuilder

The method the expression will go into

Exceptions
StandardException:
Thrown on error
getConstantValueAsObjectback to summary
pack-priv Object getConstantValueAsObject() throws StandardException

Overrides org.apache.derby.impl.sql.compile.JavaValueNode.getConstantValueAsObject.

Annotations
@Override
Exceptions
StandardException:
Thrown on error
See Also
ValueNode#getConstantValueAsObject
getDataTypeback to summary
pack-priv DataTypeDescriptor getDataType() throws StandardException

Overrides org.apache.derby.impl.sql.compile.JavaValueNode.getDataType.

Doc from org.apache.derby.impl.sql.compile.JavaValueNode.getDataType.

Get the resolved data type of this node. May be overridden by descendants.

Annotations
@Override
getJavaTypeNameback to summary
pack-priv String getJavaTypeName() throws StandardException

Overrides org.apache.derby.impl.sql.compile.JavaValueNode.getJavaTypeName.

Returns the name of the java class type that this node coerces to.

Returns:String

name of java class type

Annotations
@Override
getJSQLTypeback to summary
pack-priv JSQLType getJSQLType() throws StandardException

Overrides org.apache.derby.impl.sql.compile.JavaValueNode.getJSQLType.

Get the JSQLType that corresponds to this node. Could be a SQLTYPE, a Java primitive, or a Java class. Overrides method in JavaValueNode.

Returns:JSQLType

the corresponding JSQLType

Annotations
@Override
getOrderableVariantTypeback to summary
pack-priv int getOrderableVariantType() throws StandardException

Overrides org.apache.derby.impl.sql.compile.JavaValueNode.getOrderableVariantType.

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:int

The variant type for the underlying expression.

Annotations
@Override
Exceptions
StandardException:
thrown on error
getPrimitiveTypeNameback to summary
pack-priv String getPrimitiveTypeName() throws StandardException

Overrides org.apache.derby.impl.sql.compile.JavaValueNode.getPrimitiveTypeName.

Returns the name of the java primitive type that this node coerces to.

Returns:String

name of java primitive type

Annotations
@Override
Exceptions
StandardException:
Thrown on error
getSQLValueInterfaceNameback to summary
private String getSQLValueInterfaceName() throws StandardException

Get the type name of the SQLValue we generate.

Returns:String

name of interface corresponding to SQLValue

Exceptions
StandardException:
Thrown on error
getSQLValueNodeback to summary
pack-priv ValueNode getSQLValueNode()

Get the SQL ValueNode that is being converted to a JavaValueNode

Returns:ValueNode

The underlying SQL ValueNode

preprocessback to summary
pack-priv void preprocess(int numTables, FromList outerFromList, SubqueryList outerSubqueryList, PredicateList outerPredicateList) throws StandardException

Implements abstract org.apache.derby.impl.sql.compile.JavaValueNode.preprocess.

Preprocess an expression tree. We do a number of transformations here (including subqueries, IN lists, LIKE and BETWEEN) plus subquery flattening.

Note

This is done before the outer ResultSetNode is preprocessed.

Parameters
numTables:int

Number of tables in the DML Statement

outerFromList:FromList

FromList from outer query block

outerSubqueryList:SubqueryList

SubqueryList from outer query block

outerPredicateList:PredicateList

PredicateList from outer query block

Exceptions
StandardException:
Thrown on error
printSubNodesback to summary
pack-priv void printSubNodes(int depth)

Overrides org.apache.derby.impl.sql.compile.QueryTreeNode.printSubNodes.

Prints the sub-nodes of this object. See QueryTreeNode.java for how tree printing is supposed to work.

Parameters
depth:int

The depth of this node in the tree

Annotations
@Override
remapColumnReferencesToExpressionsback to summary
pack-priv JavaValueNode remapColumnReferencesToExpressions() throws StandardException

Implements abstract org.apache.derby.impl.sql.compile.JavaValueNode.remapColumnReferencesToExpressions.

Remap all ColumnReferences in this tree to be clones of the underlying expression.

Returns:JavaValueNode

JavaValueNode The remapped expression tree.

Exceptions
StandardException:
Thrown on error