Class UnaryArithmeticOperatorNode

All Implemented Interfaces:
Visitable

class UnaryArithmeticOperatorNode extends UnaryOperatorNode
This node represents a unary arithmetic operator
  • Field Details

  • Constructor Details

  • Method Details

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

      ValueNode bindExpression(FromList fromList, SubqueryList subqueryList, List<AggregateNode> aggregates) 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
      aggregates - The aggregate list 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

      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

      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
    • isSameNodeKind

      boolean isSameNodeKind(ValueNode o)
      Description copied from class: ValueNode
      Some node classes represent several logical node types (to reduce footprint), which we call kinds. This means that implementations of ValueNode.isEquivalent(org.apache.derby.impl.sql.compile.ValueNode) 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.
      Overrides:
      isSameNodeKind in class UnaryOperatorNode
      Parameters:
      o - The other value node whose kind we want to compare with.
      Returns:
      true if this and o represent the same logical node type, i.e. kind.