Class Operation

  • All Implemented Interfaces:
    ADQLObject, ADQLOperand

    public class Operation
    extends java.lang.Object
    implements ADQLOperand
    It represents a simple numeric operation (sum, difference, multiplication and division).
    Version:
    1.4 (09/2017)
    Author:
    Grégory Mantelet (CDS;ARI)
    See Also:
    OperationType
    • Constructor Detail

      • Operation

        public Operation​(ADQLOperand leftOp,
                         OperationType op,
                         ADQLOperand rightOp)
                  throws java.lang.NullPointerException,
                         java.lang.UnsupportedOperationException
        Builds an operation.
        Parameters:
        leftOp - Left operand.
        op - Operation symbol.
        rightOp - Right operand.
        Throws:
        java.lang.NullPointerException - If one of the given parameters is null.
        java.lang.UnsupportedOperationException
        See Also:
        setLeftOperand(ADQLOperand), setRightOperand(ADQLOperand)
      • Operation

        public Operation​(Operation toCopy)
                  throws java.lang.Exception
        Builds an Operation by copying the given one.
        Parameters:
        toCopy - The Operand to copy.
        Throws:
        java.lang.Exception - If there is an error during the copy.
    • Method Detail

      • getLeftOperand

        public final ADQLOperand getLeftOperand()
        Gets the left part of the operation.
        Returns:
        The left operand.
      • setLeftOperand

        public void setLeftOperand​(ADQLOperand newLeftOperand)
                            throws java.lang.NullPointerException,
                                   java.lang.UnsupportedOperationException
        Changes the left operand of this operation.
        Parameters:
        newLeftOperand - The new left operand.
        Throws:
        java.lang.NullPointerException - If the given operand is null.
        java.lang.UnsupportedOperationException - If the given operand is not numeric (see ADQLOperand.isNumeric()).
      • getOperation

        public final OperationType getOperation()
        Gets the operation symbol.
        Returns:
        The operation type.
        See Also:
        OperationType
      • setOperation

        public void setOperation​(OperationType newOperation)
        Changes the type of this operation (SUM, SUB, MULT, DIV).
        Parameters:
        newOperation - The new type of this operation.
        See Also:
        OperationType
      • getRightOperand

        public final ADQLOperand getRightOperand()
        Gets the right part of the operation.
        Returns:
        The right operand.
      • setRightOperand

        public void setRightOperand​(ADQLOperand newRightOperand)
                             throws java.lang.NullPointerException,
                                    java.lang.UnsupportedOperationException
        Changes the right operand of this operation.
        Parameters:
        newRightOperand - The new right operand of this operation.
        Throws:
        java.lang.NullPointerException - If the given operand is null.
        java.lang.UnsupportedOperationException - If the given operand is not numeric (see ADQLOperand.isNumeric()).
      • isString

        public final boolean isString()
        Always returns false.
        Specified by:
        isString in interface ADQLOperand
        Returns:
        true if this operand is a string, false otherwise.
        See Also:
        ADQLOperand.isString()
      • getPosition

        public final TextPosition getPosition()
        Description copied from interface: ADQLObject

        Gets the position of this object/token in the ADQL query.

        By default, no position should be set.

        Specified by:
        getPosition in interface ADQLObject
        Returns:
        Position of this ADQL item in the ADQL query, or NULL if not written originally in the query (for example, if added afterwards.
      • setPosition

        public final void setPosition​(TextPosition position)
        Sets the position at which this WrappedOperand has been found in the original ADQL query string.
        Parameters:
        position - Position of this WrappedOperand.
        Since:
        1.4
      • getCopy

        public ADQLObject getCopy()
                           throws java.lang.Exception
        Description copied from interface: ADQLObject
        Gets a (deep) copy of this ADQL object.
        Specified by:
        getCopy in interface ADQLObject
        Returns:
        The copy of this ADQL object.
        Throws:
        java.lang.Exception - If there is any error during the copy.
      • getName

        public java.lang.String getName()
        Description copied from interface: ADQLObject
        Gets the name of this object in ADQL.
        Specified by:
        getName in interface ADQLObject
        Returns:
        The name of this ADQL object.
      • toADQL

        public java.lang.String toADQL()
        Description copied from interface: ADQLObject
        Gets the ADQL expression of this object.
        Specified by:
        toADQL in interface ADQLObject
        Returns:
        The corresponding ADQL expression.