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

pack-priv Class UnaryArithmeticOperatorNode

extends UnaryOperatorNode
Class Inheritance
Imports
java.sql.Types, java.util.List, org.apache.derby.shared.common.error.StandardException, org.apache.derby.shared.common.reference.SQLState, org.apache.derby.iapi.services.compiler.MethodBuilder, org.apache.derby.iapi.services.context.ContextManager, org.apache.derby.iapi.types.DataTypeDescriptor, .TypeId

This node represents a unary arithmetic operator

Field Summary

Modifier and TypeField and Description
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv final int
kind

Hides org.apache.derby.impl.sql.compile.UnaryOperatorNode.kind.

This class is used to hold logically different objects for space efficiency.
private static final String[]
private static final String[]
Inherited from org.apache.derby.impl.sql.compile.UnaryOperatorNode:
K_BASEK_XMLPARSEK_XMLSERIALIZEmethodNameoperandoperatorreceiverInterfaceTyperesultInterfaceTypeUnaryArgTypesUnaryMethodNamesUnaryOperatorsUnaryResultTypes

Constructor Summary

AccessConstructor and Description
pack-priv
UnaryArithmeticOperatorNode(ValueNode
The operand of the node
operand
,
int
unary operator identity
kind
,
ContextManager
context manager
cm
)

Method Summary

Modifier and TypeMethod and Description
pack-priv ValueNode

Returns:

The new top of the expression tree.
bindExpression
(FromList
The query's FROM list
fromList
,
SubqueryList
The subquery list being built as we find SubqueryNodes
subqueryList
,
List<AggregateNode>
The aggregate list being built as we find AggregateNodes
aggregates
)

Overrides org.apache.derby.impl.sql.compile.UnaryOperatorNode.bindExpression.

Bind this operator

pack-priv void
bindParameter()

Overrides org.apache.derby.impl.sql.compile.UnaryOperatorNode.bindParameter.

For SQRT and ABS the parameter becomes a DOUBLE.

private void
bindSQRTABS()

Bind SQRT or ABS

private void
checkOperandIsNumeric(TypeId operandType)

Only called for Unary +/-.

pack-priv void
generateExpression(ExpressionClassBuilder
The ExpressionClassBuilder for the class we're generating
acb
,
MethodBuilder
The method the expression will go into
mb
)

Overrides org.apache.derby.impl.sql.compile.UnaryOperatorNode.generateExpression.

Do code generation for this unary plus operator

public boolean
pack-priv boolean
isSameNodeKind(ValueNode
The other value node whose kind we want to compare with.
o
)

Overrides org.apache.derby.impl.sql.compile.UnaryOperatorNode.isSameNodeKind.

Some node classes represent several logical node types (to reduce footprint), which we call kinds.

public boolean
requiresTypeFromContext()

Overrides org.apache.derby.impl.sql.compile.ValueNode.requiresTypeFromContext.

Unary + and - require their type to be set if they wrap another node (e.g. a parameter) that requires type from its context.

pack-priv void
setType(DataTypeDescriptor
The DataTypeServices to set in this ValueNode
descriptor
)

Overrides org.apache.derby.impl.sql.compile.ValueNode.setType.

We are overwriting this method here because for -?/+?, we now know the type of these dynamic parameters and hence we can do the parameter binding.

Inherited from org.apache.derby.impl.sql.compile.UnaryOperatorNode:
acceptChildrenaddXmlOpMethodParamsbindOperandcategorizeconstantExpressiongetOperandgetOperatorStringgetOrderableVariantTypegetParameterOperandgetReceiverInterfaceNameisConstantExpressionisEquivalentpreprocessprintSubNodesremapColumnReferencesToExpressionssetMethodNamesetOperatortoString

Field Detail

K_ABSback to summary
pack-priv static final int K_ABS
K_MINUSback to summary
pack-priv static final int K_MINUS
K_PLUSback to summary
pack-priv static final int K_PLUS
K_SQRTback to summary
pack-priv static final int K_SQRT
kindback to summary
pack-priv final int kind

Hides org.apache.derby.impl.sql.compile.UnaryOperatorNode.kind.

This class is used to hold logically different objects for space efficiency. kind represents the logical object type. See also ValueNode#isSameNodeKind.

UNARY_METHODSback to summary
private static final String[] UNARY_METHODS
UNARY_OPERATORSback to summary
private static final String[] UNARY_OPERATORS

Constructor Detail

UnaryArithmeticOperatorNodeback to summary
pack-priv UnaryArithmeticOperatorNode(ValueNode operand, int kind, ContextManager cm) throws StandardException
Parameters
operand:ValueNode

The operand of the node

kind:int

unary operator identity

cm:ContextManager

context manager

Method Detail

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

Overrides org.apache.derby.impl.sql.compile.UnaryOperatorNode.bindExpression.

Bind this operator

Parameters
fromList:FromList

The query's FROM list

subqueryList:SubqueryList

The subquery list being built as we find SubqueryNodes

aggregates:List<AggregateNode>

The aggregate list being built as we find AggregateNodes

Returns:ValueNode

The new top of the expression tree.

Annotations
@Override
Exceptions
StandardException:
Thrown on error
bindParameterback to summary
pack-priv void bindParameter() throws StandardException

Overrides org.apache.derby.impl.sql.compile.UnaryOperatorNode.bindParameter.

For SQRT and ABS the parameter becomes a DOUBLE. For unary + and - no change is made to the underlying node. Once this node's type is set using setType, then the underlying node will have its type set.

Annotations
@Override
Exceptions
StandardException:
Thrown if ? parameter doesn't have a type bound to it yet. ? parameter where it isn't allowed.
bindSQRTABSback to summary
private void bindSQRTABS() throws StandardException

Bind SQRT or ABS

Exceptions
StandardException:
Thrown on error
checkOperandIsNumericback to summary
private void checkOperandIsNumeric(TypeId operandType) throws StandardException

Only called for Unary +/-.

generateExpressionback to summary
pack-priv void generateExpression(ExpressionClassBuilder acb, MethodBuilder mb) throws StandardException

Overrides org.apache.derby.impl.sql.compile.UnaryOperatorNode.generateExpression.

Do code generation for this unary plus operator

Parameters
acb:ExpressionClassBuilder

The ExpressionClassBuilder for the class we're generating

mb:MethodBuilder

The method the expression will go into

Annotations
@Override
Exceptions
StandardException:
Thrown on error
isParameterNodeback to summary
public boolean isParameterNode()

Overrides org.apache.derby.impl.sql.compile.ValueNode.isParameterNode.

A +? or a -? is considered a parameter.

Annotations
@Override
isSameNodeKindback to summary
pack-priv boolean isSameNodeKind(ValueNode o)

Overrides org.apache.derby.impl.sql.compile.UnaryOperatorNode.isSameNodeKind.

Doc from org.apache.derby.impl.sql.compile.ValueNode.isSameNodeKind.

Some node classes represent several logical node types (to reduce footprint), which we call kinds. This means that implementations of isEquivalent cannot always just use instanceof to check if the other node represents the same kind. Hence this method needs to be overridden by all node classes that represent several kinds. This default implementation does not look at kinds. It is only called from implementations of isEquivalent.

Parameters
o:ValueNode

The other value node whose kind we want to compare with.

Returns:boolean

true if this and o represent the same logical node type, i.e. kind.

Annotations
@Override
requiresTypeFromContextback to summary
public boolean requiresTypeFromContext()

Overrides org.apache.derby.impl.sql.compile.ValueNode.requiresTypeFromContext.

Unary + and - require their type to be set if they wrap another node (e.g. a parameter) that requires type from its context.

Returns:boolean

Doc from org.apache.derby.impl.sql.compile.ValueNode.requiresTypeFromContext.

Whether this node's type will be determined from the context

Annotations
@Override
See Also
ValueNode#requiresTypeFromContext
setTypeback to summary
pack-priv void setType(DataTypeDescriptor descriptor) throws StandardException

Overrides org.apache.derby.impl.sql.compile.ValueNode.setType.

We are overwriting this method here because for -?/+?, we now know the type of these dynamic parameters and hence we can do the parameter binding. The setType method will call the binding code after setting the type of the parameter

Parameters
descriptor:DataTypeDescriptor

Doc from org.apache.derby.impl.sql.compile.ValueNode.setType.

The DataTypeServices to set in this ValueNode

Annotations
@Override