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

pack-priv Class UnaryDateTimestampOperatorNode

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

This class implements the timestamp( x) and date(x) functions. These two functions implement a few special cases of string conversions beyond the normal string to date/timestamp casts.

Field Summary

Modifier and TypeField and Description
private static final String
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
Inherited from org.apache.derby.impl.sql.compile.UnaryOperatorNode:
K_BASEK_XMLPARSEK_XMLSERIALIZEmethodNameoperandoperatorreceiverInterfaceTyperesultInterfaceTypeUnaryArgTypesUnaryMethodNamesUnaryOperatorsUnaryResultTypes

Constructor Summary

AccessConstructor and Description
pack-priv
UnaryDateTimestampOperatorNode(ValueNode
The operand of the function
operand
,
int
The kind of the result, Date or Timestamp.
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 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
)

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

Called by UnaryOperatorNode.bindExpression.

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 operator.

private void
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.

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

Field Detail

DATE_METHOD_NAMEback to summary
private static final String DATE_METHOD_NAME
K_DATEback to summary
pack-priv static final int K_DATE
K_TIMESTAMPback to summary
pack-priv static final int K_TIMESTAMP
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.

TIMESTAMP_METHOD_NAMEback to summary
private static final String TIMESTAMP_METHOD_NAME

Constructor Detail

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

The operand of the function

kind:int

The kind of the result, Date or Timestamp.

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.

Called by UnaryOperatorNode.bindExpression. If the operand is a constant then evaluate the function at compile time. Otherwise, if the operand input type is the same as the output type then discard this node altogether. If the function is "date" and the input is a timestamp then change this node to a cast.

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

The new top of the expression tree.

Annotations
@Override
Exceptions
StandardException:
Thrown on error
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 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
invalidOperandTypeback to summary
private void invalidOperandType() throws StandardException
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