Package adql.query.operand

## Class Operation

- java.lang.Object
- - adql.query.operand.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 Summary

    Constructors
    Constructor | Description
    --- | ---
    `Operation​(ADQLOperand leftOp, OperationType op, ADQLOperand rightOp)` | Builds an operation.
    `Operation​(Operation toCopy)` | Builds an Operation by copying the given one.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `ADQLIterator` | `adqlIterator()` | Gets an iterator on the intern ADQL objects.
    `ADQLObject` | `getCopy()` | Gets a (deep) copy of this ADQL object.
    `ADQLOperand` | `getLeftOperand()` | Gets the left part of the operation.
    `java.lang.String` | `getName()` | Gets the name of this object in ADQL.
    `OperationType` | `getOperation()` | Gets the operation symbol.
    `TextPosition` | `getPosition()` | Gets the position of this object/token in the ADQL query.
    `ADQLOperand` | `getRightOperand()` | Gets the right part of the operation.
    `boolean` | `isGeometry()` | Always returns false.
    `boolean` | `isNumeric()` | Always returns true.
    `boolean` | `isString()` | Always returns false.
    `void` | `setLeftOperand​(ADQLOperand newLeftOperand)` | Changes the left operand of this operation.
    `void` | `setOperation​(OperationType newOperation)` | Changes the type of this operation (SUM, SUB, MULT, DIV).
    `void` | `setPosition​(TextPosition position)` | Sets the position at which this `WrappedOperand` has been found in the original ADQL query string.
    `void` | `setRightOperand​(ADQLOperand newRightOperand)` | Changes the right operand of this operation.
    `java.lang.String` | `toADQL()` | Gets the ADQL expression of this object.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### 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()`).

    - #### isNumeric

          public final boolean isNumeric()

      Always returns true.
      Specified by:
        `isNumeric` in interface `ADQLOperand`
      Returns:
        true if this operand is numeric, false otherwise.
      See Also:
        `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

    - #### isGeometry

          public final boolean isGeometry()

      Always returns false.
      Specified by:
        `isGeometry` in interface `ADQLOperand`
      Returns:
        true if this operand is a geometry, false otherwise.
      See Also:
        `ADQLOperand.isGeometry()`

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

    - #### adqlIterator

          public ADQLIterator adqlIterator()

      Description copied from interface: `ADQLObject`

      Gets an iterator on the intern ADQL objects.

      Note:The returned iterator is particularly used by a `ISearchHandler` extension to browse a whole ADQL tree.

      Specified by:
        `adqlIterator` in interface `ADQLObject`
      Returns:
        An ADQL objects iterator.
      See Also:
        `ADQLIterator`, `ISearchHandler`

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