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

pack-priv abstract Class JavaValueNode

extends QueryTreeNode
Class Inheritance
Known Direct Subclasses
org.apache.derby.impl.sql.compile.MethodCallNode, org.apache.derby.impl.sql.compile.SQLToJavaValueNode, org.apache.derby.impl.sql.compile.StaticClassFieldReferenceNode, org.apache.derby.impl.sql.compile.GetCurrentConnectionNode
Imports
java.lang.reflect.Modifier, java.util.List, org.apache.derby.shared.common.error.StandardException, org.apache.derby.shared.common.reference.SQLState, org.apache.derby.iapi.services.compiler.LocalField, .MethodBuilder, org.apache.derby.iapi.services.context.ContextManager, org.apache.derby.iapi.services.loader.ClassInspector, org.apache.derby.shared.common.sanity.SanityManager, org.apache.derby.iapi.sql.compile.CompilerContext, org.apache.derby.iapi.store.access.Qualifier, org.apache.derby.iapi.types.DataTypeDescriptor, .JSQLType, .TypeId, org.apache.derby.iapi.util.JBitSet

This abstract node class represents a data value in the Java domain.

Field Summary

Modifier and TypeField and Description
private int
protected boolean
protected JSQLType
private boolean
private LocalField
private boolean
private boolean
Inherited from org.apache.derby.impl.sql.compile.QueryTreeNode:
AUTOINCREMENT_CREATE_MODIFYAUTOINCREMENT_CYCLEAUTOINCREMENT_INC_INDEXAUTOINCREMENT_IS_AUTOINCREMENT_INDEXAUTOINCREMENT_START_INDEX

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv abstract JavaValueNode

Returns:

the new node, usually this
bindExpression
(FromList fromList, SubqueryList subqueryList, List<AggregateNode> aggregates)

pack-priv final void
castToPrimitive(boolean
true if we want the code generator to add a cast false otherwise
booleanValue
)

Toggles whether the code generator should add a cast to extract a primitive value from an object.

pack-priv abstract boolean
categorize(JBitSet referencedTabs, boolean simplePredsOnly)

pack-priv void
checkReliability(ValueNode sqlNode)

Check the reliability type of this java value.

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

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

Do the code generation for this node.

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

General logic shared by Core compilation and by the Replication Filter compiler.

pack-priv boolean

Returns:

True if has compiled receiver.
generateReceiver
(ExpressionClassBuilder
The ExpressionClassBuilder for the class being built
acb
,
MethodBuilder
the method the expression will go into
mb
)

Generate the expression that evaluates to the receiver.

pack-priv final boolean

Returns:

The compiled receiver, if any.
generateReceiver
(ExpressionClassBuilder
The ActivationClassBuilder for the class being built
acb
,
MethodBuilder
the method the expression will go into
mb
,
JavaValueNode
The query tree form of the receiver expression
receiver
)

Generate the expression that evaluates to the receiver.

pack-priv int

Returns:

collationType as set by setCollationType
getCollationType
()

pack-priv Object
pack-priv DataTypeDescriptor
getDataType()

Get the resolved data type of this node.

pack-priv String
pack-priv JSQLType

Returns:

the corresponding JSQLType
getJSQLType
()

Get the JSQLType that corresponds to this node.

pack-priv int

Returns:

The variant type for the underlying expression.
getOrderableVariantType
()

Return the variant type for the underlying expression.

pack-priv String
pack-priv final void
getReceiverExpression(ExpressionClassBuilder
The ExpressionClassBuilder for the class we're generating
acb
,
MethodBuilder
the method the expression will go into
mb
,
JavaValueNode
The query tree form of the receiver expression
receiver
)

Get an expression that has the value of the receiver.

pack-priv final boolean
pack-priv static TypeId

Returns:

the corresponding compilation type id
mapToTypeID
(JSQLType
the universal type to map
jsqlType
)

Map a JSQLType to a compilation type id.

pack-priv final void
markForCallStatement()

Mark this node as being for a CALL Statement.

pack-priv void
markReturnValueDiscarded()

Tell this node that nothing is done with the returned value

pack-priv final boolean

Returns:

true if we want the code generator to add a cast false otherwise
mustCastToPrimitive
()

Reports whether the code generator should add a cast to extract a primitive value from an object.

pack-priv abstract void
preprocess(int numTables, FromList outerFromList, SubqueryList outerSubqueryList, PredicateList outerPredicateList)

pack-priv abstract JavaValueNode
pack-priv boolean
returnValueDiscarded()

Tell whether the return value from this node is discarded

pack-priv void
returnValueToSQLDomain()

Inform this node that it returns its value to the SQL domain

pack-priv void
setCollationType(int
one of StringDataValue.COLLATION_TYPE_UCS_BASIC or StringDataValue.COLLATION_TYPE_TERRITORY_BASED
type
)

Set the collation type.

pack-priv final void
setJavaTypeName(String javaTypeName)

pack-priv boolean
valueReturnedToSQLDomain()

Tell whether this node returns its value to the SQL domain

Inherited from org.apache.derby.impl.sql.compile.QueryTreeNode:
acceptacceptChildrenaddTagaddUDTUsagePrivaddUDTUsagePrivbindOffsetFetchbindRowMultiSetbindUserCatalogTypebindUserTypecheckReliabilitycheckReliabilityconvertDefaultNodecopyTagsFromcreateTypeDependencydebugFlushdebugPrintdisablePrivilegeCollectionformatNodeStringgenerateAuthorizeCheckgetBeginOffsetgetClassFactorygetCompilerContextgetContextgetContextManagergetDataDictionarygetDependencyManagergetEndOffsetgetExecutionFactorygetGenericConstantActionFactorygetIntPropertygetLanguageConnectionContextgetLongPropertygetNullNodegetOffsetOrderedNodesgetOptimizerFactorygetOptimizerTracergetParameterTypesgetSchemaDescriptorgetSchemaDescriptorgetStatementTypegetTableDescriptorgetTypeCompilergetUDTDescisAtomicisPrivilegeCollectionRequiredisSessionSchemaisSessionSchemamakeConstantActionmakeTableNamemakeTableNamenodeHeaderoptimizerTracingIsOnorReliabilityparseSearchConditionparseStatementprintLabelprintSubNodesreferencesSessionSchemaresolveTableToSynonymsetBeginOffsetsetEndOffsetsetRefActionInfostackPrinttaggedWithtoStringtreePrinttreePrintverifyClassExist

Field Detail

collationTypeback to summary
private int collationType
forCallStatementback to summary
protected boolean forCallStatement
jsqlTypeback to summary
protected JSQLType jsqlType
mustCastToPrimitiveback to summary
private boolean mustCastToPrimitive
receiverFieldback to summary
private LocalField receiverField
returnValueDiscardedback to summary
private boolean returnValueDiscarded
valueReturnedToSQLDomainback to summary
private boolean valueReturnedToSQLDomain

Constructor Detail

JavaValueNodeback to summary
pack-priv JavaValueNode(ContextManager cm)

Method Detail

bindExpressionback to summary
pack-priv abstract JavaValueNode bindExpression(FromList fromList, SubqueryList subqueryList, List<AggregateNode> aggregates) throws StandardException
Returns:JavaValueNode

the new node, usually this

Exceptions
StandardException:
Thrown on error
See Also
ValueNode#bindExpression
castToPrimitiveback to summary
pack-priv final void castToPrimitive(boolean booleanValue)

Toggles whether the code generator should add a cast to extract a primitive value from an object.

Parameters
booleanValue:boolean

true if we want the code generator to add a cast false otherwise

categorizeback to summary
pack-priv abstract boolean categorize(JBitSet referencedTabs, boolean simplePredsOnly) throws StandardException
Exceptions
StandardException:
Thrown on error
See Also
ValueNode#categorize
checkReliabilityback to summary
pack-priv void checkReliability(ValueNode sqlNode) throws StandardException

Check the reliability type of this java value.

Exceptions
StandardException:
Thrown on error
See Also
org.apache.derby.iapi.sql.compile.CompilerContext
generateback to summary
pack-priv final void generate(ActivationClassBuilder acb, MethodBuilder mb) throws StandardException

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

Do the code generation for this node. Call the more general routine that generates expressions.

Parameters
acb:ActivationClassBuilder

The ActivationClassBuilder for the class being built

mb:MethodBuilder

the method the expression will go into

Annotations
@Override
Exceptions
StandardException:
Thrown on error
generateExpressionback to summary
pack-priv 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:ExpressionClassBuilder

The ExpressionClassBuilder for the class being built

mb:MethodBuilder

the method the expression will go into

Exceptions
StandardException:
Thrown on error
generateReceiverback to summary
pack-priv 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:ExpressionClassBuilder

The ExpressionClassBuilder for the class being built

mb:MethodBuilder

the method the expression will go into

Returns:boolean

True if has compiled receiver.

Exceptions
StandardException:
Thrown on error
generateReceiverback to summary
pack-priv 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:ExpressionClassBuilder

The ActivationClassBuilder for the class being built

mb:MethodBuilder

the method the expression will go into

receiver:JavaValueNode

The query tree form of the receiver expression

Returns:boolean

The compiled receiver, if any.

Exceptions
StandardException:
Thrown on error
getCollationTypeback to summary
pack-priv int getCollationType()
Returns:int

collationType as set by setCollationType

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

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

getJavaTypeNameback to summary
pack-priv String getJavaTypeName() throws StandardException
getJSQLTypeback to summary
pack-priv JSQLType getJSQLType() throws StandardException

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

Returns:JSQLType

the corresponding JSQLType

getOrderableVariantTypeback to summary
pack-priv 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:int

The variant type for the underlying expression.

getPrimitiveTypeNameback to summary
pack-priv String getPrimitiveTypeName() throws StandardException
getReceiverExpressionback to summary
pack-priv 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:ExpressionClassBuilder

The ExpressionClassBuilder for the class we're generating

mb:MethodBuilder

the method the expression will go into

receiver:JavaValueNode

The query tree form of the receiver expression

Exceptions
StandardException:
Thrown on error
isPrimitiveTypeback to summary
pack-priv final boolean isPrimitiveType() throws StandardException
mapToTypeIDback to summary
pack-priv static TypeId mapToTypeID(JSQLType jsqlType) throws StandardException

Map a JSQLType to a compilation type id.

Parameters
jsqlType:JSQLType

the universal type to map

Returns:TypeId

the corresponding compilation type id

markForCallStatementback to summary
pack-priv final void markForCallStatement()

Mark this node as being for a CALL Statement. (void methods are only okay for CALL Statements)

markReturnValueDiscardedback to summary
pack-priv void markReturnValueDiscarded()

Tell this node that nothing is done with the returned value

mustCastToPrimitiveback to summary
pack-priv final boolean mustCastToPrimitive()

Reports whether the code generator should add a cast to extract a primitive value from an object.

Returns:boolean

true if we want the code generator to add a cast false otherwise

preprocessback to summary
pack-priv abstract void preprocess(int numTables, FromList outerFromList, SubqueryList outerSubqueryList, PredicateList outerPredicateList) throws StandardException
Exceptions
StandardException:
Thrown on error
See Also
ValueNode#preprocess
remapColumnReferencesToExpressionsback to summary
pack-priv abstract JavaValueNode remapColumnReferencesToExpressions() throws StandardException
Exceptions
StandardException:
Thrown on error
See Also
ValueNode#remapColumnReferencesToExpressions
returnValueDiscardedback to summary
pack-priv boolean returnValueDiscarded()

Tell whether the return value from this node is discarded

returnValueToSQLDomainback to summary
pack-priv void returnValueToSQLDomain()

Inform this node that it returns its value to the SQL domain

setCollationTypeback to summary
pack-priv void setCollationType(int type)

Set the collation type. This will be used to determine the collation type for the SQLToJavaValueNode.

Parameters
type:int

one of StringDataValue.COLLATION_TYPE_UCS_BASIC or StringDataValue.COLLATION_TYPE_TERRITORY_BASED

setJavaTypeNameback to summary
pack-priv final void setJavaTypeName(String javaTypeName)
valueReturnedToSQLDomainback to summary
pack-priv boolean valueReturnedToSQLDomain()

Tell whether this node returns its value to the SQL domain