org.apache.derby.impl.sql.compile
Class UnaryArithmeticOperatorNode

java.lang.Object
  extended by org.apache.derby.impl.sql.compile.QueryTreeNode
      extended by org.apache.derby.impl.sql.compile.ValueNode
          extended by org.apache.derby.impl.sql.compile.UnaryOperatorNode
              extended by org.apache.derby.impl.sql.compile.UnaryArithmeticOperatorNode
All Implemented Interfaces:
Visitable

public class UnaryArithmeticOperatorNode
extends UnaryOperatorNode

This node represents a unary arithmetic operator


Field Summary
private static int ABSOLUTE
           
private  int operatorType
           
private static int SQRT
           
private static java.lang.String[] UNARY_METHODS
           
private static int UNARY_MINUS
           
private static java.lang.String[] UNARY_OPERATORS
           
private static int UNARY_PLUS
           
 
Fields inherited from class org.apache.derby.impl.sql.compile.UnaryOperatorNode
methodName, operand, operator, receiverInterfaceType, resultInterfaceType, UnaryArgTypes, UnaryMethodNames, UnaryOperators, UnaryResultTypes, XMLPARSE_OP, XMLSERIALIZE_OP
 
Fields inherited from class org.apache.derby.impl.sql.compile.ValueNode
transformed
 
Fields inherited from class org.apache.derby.impl.sql.compile.QueryTreeNode
AUTOINCREMENT_CREATE_MODIFY, AUTOINCREMENT_INC_INDEX, AUTOINCREMENT_IS_AUTOINCREMENT_INDEX, AUTOINCREMENT_START_INDEX, isPrivilegeCollectionRequired
 
Constructor Summary
UnaryArithmeticOperatorNode()
           
 
Method Summary
 ValueNode bindExpression(FromList fromList, SubqueryList subqueryList, java.util.Vector aggregateVector)
          Bind this operator
(package private)  void 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 +/-.
 void generateExpression(ExpressionClassBuilder acb, MethodBuilder mb)
          Do code generation for this unary plus operator
 void init(java.lang.Object operand)
          Initializer for a UnaryArithmeticOperatorNode
 boolean isParameterNode()
          A +?
 boolean requiresTypeFromContext()
          Unary + and - require their type to be set if they wrap another node (e.g. a parameter) that requires type from its context.
 void setType(DataTypeDescriptor descriptor)
          We are overwriting this method here because for -?
 
Methods inherited from class org.apache.derby.impl.sql.compile.UnaryOperatorNode
acceptChildren, addXmlOpMethodParams, bindOperand, categorize, constantExpression, getOperand, getOperatorString, getOrderableVariantType, getParameterOperand, getReceiverInterfaceName, init, isConstantExpression, isEquivalent, preprocess, printSubNodes, remapColumnReferencesToExpressions, setMethodName, setOperator, toString
 
Methods inherited from class org.apache.derby.impl.sql.compile.ValueNode
bindExpression, changeToCNF, checkIsBoolean, checkTopPredicatesForEqualsConditions, copyFields, eliminateNots, evaluateConstantExpressions, genEqualsFalseTree, generate, generateFilter, genIsNullTree, genSQLJavaSQLTree, getClone, getColumnName, getConstantValueAsObject, getDataValueFactory, getSchemaName, getSourceResultColumn, getTableName, getTablesReferenced, getTransformed, getTypeCompiler, getTypeId, getTypeServices, init, isBinaryEqualsOperatorNode, isBooleanFalse, isBooleanTrue, isCloneable, isInListProbeNode, isRelationalOperator, isSameNodeType, optimizableEqualityNode, putAndsOnTop, selectivity, setCollationInfo, setCollationInfo, setCollationUsingCompilationSchema, setCollationUsingCompilationSchema, setNullability, setTransformed, setType, setType, updatableByCursor, verifyChangeToCNF, verifyEliminateNots, verifyPutAndsOnTop
 
Methods inherited from class org.apache.derby.impl.sql.compile.QueryTreeNode
accept, bindOffsetFetch, bindRowMultiSet, bindUserType, checkReliability, checkReliability, convertDefaultNode, createTypeDependency, debugFlush, debugPrint, disablePrivilegeCollection, formatNodeString, foundString, generateAuthorizeCheck, getBeginOffset, getClassFactory, getCompilerContext, getContextManager, getCursorInfo, getDataDictionary, getDependencyManager, getEndOffset, getExecutionFactory, getGenericConstantActionFactory, getIntProperty, getLanguageConnectionContext, getNodeFactory, getNodeType, getNullNode, getParameterTypes, getRowEstimate, getSchemaDescriptor, getSchemaDescriptor, getStatementType, getTableDescriptor, getTypeCompiler, init, init, init, init, init, init, init, init, init, init, init, isAtomic, isInstanceOf, isPrivilegeCollectionRequired, isSessionSchema, isSessionSchema, makeConstantAction, makeTableName, makeTableName, nodeHeader, orReliability, parseStatement, printLabel, referencesSessionSchema, resolveTableToSynonym, setBeginOffset, setContextManager, setEndOffset, setNodeType, setRefActionInfo, stackPrint, treePrint, treePrint, verifyClassExist
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

UNARY_PLUS

private static final int UNARY_PLUS
See Also:
Constant Field Values

UNARY_MINUS

private static final int UNARY_MINUS
See Also:
Constant Field Values

SQRT

private static final int SQRT
See Also:
Constant Field Values

ABSOLUTE

private static final int ABSOLUTE
See Also:
Constant Field Values

UNARY_OPERATORS

private static final java.lang.String[] UNARY_OPERATORS

UNARY_METHODS

private static final java.lang.String[] UNARY_METHODS

operatorType

private int operatorType
Constructor Detail

UnaryArithmeticOperatorNode

public UnaryArithmeticOperatorNode()
Method Detail

init

public void init(java.lang.Object operand)
Initializer for a UnaryArithmeticOperatorNode

Overrides:
init in class UnaryOperatorNode
Parameters:
operand - The operand of the node

requiresTypeFromContext

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

Overrides:
requiresTypeFromContext in class ValueNode
Returns:
Whether this node's type will be determined from the context
See Also:
ValueNode.requiresTypeFromContext()

isParameterNode

public boolean isParameterNode()
A +? or a -? is considered a parameter.

Overrides:
isParameterNode in class ValueNode

bindParameter

void bindParameter()
             throws StandardException
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.

Overrides:
bindParameter in class UnaryOperatorNode
Throws:
StandardException - Thrown if ? parameter doesn't have a type bound to it yet. ? parameter where it isn't allowed.

bindExpression

public ValueNode bindExpression(FromList fromList,
                                SubqueryList subqueryList,
                                java.util.Vector aggregateVector)
                         throws StandardException
Bind this operator

Overrides:
bindExpression in class UnaryOperatorNode
Parameters:
fromList - The query's FROM list
subqueryList - The subquery list being built as we find SubqueryNodes
aggregateVector - The aggregate vector being built as we find AggregateNodes
Returns:
The new top of the expression tree.
Throws:
StandardException - Thrown on error

checkOperandIsNumeric

private void checkOperandIsNumeric(TypeId operandType)
                            throws StandardException
Only called for Unary +/-.

Throws:
StandardException

generateExpression

public void generateExpression(ExpressionClassBuilder acb,
                               MethodBuilder mb)
                        throws StandardException
Do code generation for this unary plus operator

Overrides:
generateExpression in class UnaryOperatorNode
Parameters:
acb - The ExpressionClassBuilder for the class we're generating
mb - The method the expression will go into
Throws:
StandardException - Thrown on error

bindSQRTABS

private void bindSQRTABS()
                  throws StandardException
Bind SQRT or ABS

Throws:
StandardException - Thrown on error

setType

public void setType(DataTypeDescriptor descriptor)
             throws StandardException
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

Overrides:
setType in class ValueNode
Parameters:
descriptor - The DataTypeServices to set in this ValueNode
Throws:
StandardException

Built on Thu 2010-12-23 20:49:13+0000, from revision ???

Apache Derby V10.6 Internals - Copyright © 2004,2007 The Apache Software Foundation. All Rights Reserved.