Package adql.query.operand

## Class NumericConstant

- java.lang.Object
- - adql.query.operand.NumericConstant

- All Implemented Interfaces:
    `ADQLObject`, `ADQLOperand`

      public class NumericConstant
      extends java.lang.Object
      implements ADQLOperand

  A numeric (integer, double, ...) constant.
  Version:
    1.4 (09/2017)
  Author:
    Grégory Mantelet (CDS;ARI)

- - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `protected TextPosition` | `position` | Position of this operand.
    `protected java.lang.String` | `value` |

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `NumericConstant​(double val)` | The numeric value is saved as a string so that the exact user format can be saved.
    `NumericConstant​(long val)` | The numeric value is saved as a string so that the exact user format can be saved.
    `NumericConstant​(NumericConstant toCopy)` | Builds a NumericConstant by copying the given one.
    `NumericConstant​(java.lang.String value)` | The numeric value is saved as a string so that the exact user format can be saved.
    `NumericConstant​(java.lang.String value, boolean checkNumeric)` | The numeric value is saved as a string so that the exact user format can be saved.

  - ### 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.
    `java.lang.String` | `getName()` | Gets the name of this object in ADQL.
    `double` | `getNumericValue()` |
    `TextPosition` | `getPosition()` | Gets the position of this object/token in the ADQL query.
    `java.lang.String` | `getValue()` |
    `boolean` | `isGeometry()` | Always returns false.
    `boolean` | `isNumeric()` | Always returns true.
    `boolean` | `isString()` | Always returns false.
    `void` | `setPosition​(TextPosition position)` | Sets the position at which this `NumericConstant` has been found in the original ADQL query string.
    `void` | `setValue​(double value)` | Sets the given value.
    `void` | `setValue​(long value)` | Sets the given value.
    `void` | `setValue​(java.lang.String value)` | Sets the given value (it must be convertible in a Double).
    `void` | `setValue​(java.lang.String value, boolean checkNumeric)` | Sets the given value.
    `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`

- - ### Field Detail

    - #### value

          protected java.lang.String value

    - #### position

          protected TextPosition position

      Position of this operand.
      Since:
        1.4

  - ### Constructor Detail

    - #### NumericConstant

          public NumericConstant​(java.lang.String value)
                          throws java.lang.NumberFormatException

      The numeric value is saved as a string so that the exact user format can be saved. The given string must be convertible in a Double value.
      Parameters:
        `value` - The numeric value (in a String variable).
      Throws:
        `java.lang.NumberFormatException` - If it is impossible to convert the given value in a Double.
      See Also:
        `setValue(String)`

    - #### NumericConstant

          public NumericConstant​(long val)

      The numeric value is saved as a string so that the exact user format can be saved.
      Parameters:
        `val` - The numeric value.

    - #### NumericConstant

          public NumericConstant​(double val)

      The numeric value is saved as a string so that the exact user format can be saved.
      Parameters:
        `val` - The numeric value.

    - #### NumericConstant

          public NumericConstant​(java.lang.String value,
                                 boolean checkNumeric)
                          throws java.lang.NumberFormatException

      The numeric value is saved as a string so that the exact user format can be saved. It is possible to force the value (no check to known whether this value is numeric or not is done) by setting the boolean parameter to false.
      Parameters:
        `value` - The numeric value (in a String variable).
        `checkNumeric` - true to check whether the given value is numeric, false otherwise.
      Throws:
        `java.lang.NumberFormatException` - If it is impossible to convert the given value in a Double.
      See Also:
        `setValue(String, boolean)`

    - #### NumericConstant

          public NumericConstant​(NumericConstant toCopy)

      Builds a NumericConstant by copying the given one.
      Parameters:
        `toCopy` - The NumericConstant to copy.

  - ### Method Detail

    - #### getValue

          public java.lang.String getValue()

    - #### getNumericValue

          public double getNumericValue()

    - #### setValue

          public void setValue​(long value)

      Sets the given value.
      Parameters:
        `value` - The numeric value.

    - #### setValue

          public void setValue​(double value)

      Sets the given value.
      Parameters:
        `value` - The numeric value.

    - #### setValue

          public void setValue​(java.lang.String value)
                        throws java.lang.NumberFormatException

      Sets the given value (it must be convertible in a Double).
      Parameters:
        `value` - The numeric value.
      Throws:
        `java.lang.NumberFormatException` - If it is impossible to convert the given value in a Double.
      See Also:
        `setValue(String, boolean)`

    - #### setValue

          public void setValue​(java.lang.String value,
                               boolean checkNumeric)
                        throws java.lang.NumberFormatException

      Sets the given value. It is possible to force the value (no check to known whether this value is numeric or not is done) by setting the boolean parameter to false.
      Parameters:
        `value` - The numeric value.
        `checkNumeric` - true to check whether the given value is numeric, false otherwise.
      Throws:
        `java.lang.NumberFormatException` - If the given value can not be converted in a Double.

    - #### 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 `NumericConstant` has been found in the original ADQL query string.
      Parameters:
        `position` - Position of this `NumericConstant`.
      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()

      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.

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