Interface IonNumber

  • All Superinterfaces:
    java.lang.Cloneable, IonValue
    All Known Subinterfaces:
    IonDecimal, IonFloat, IonInt

    public interface IonNumber
    extends IonValue
    Common functionality of Ion int, decimal, and float types.

    WARNING: This interface should not be implemented or extended by code outside of this library.

    • Method Detail

      • bigDecimalValue

        java.math.BigDecimal bigDecimalValue()
        Gets the value of this Ion number as a BigDecimal.

        This method will throw an exception for non-null, non-numeric values. It's recommended to call isNumericValue() before calling this method.

        Negative zero is supported by IonDecimal and IonFloat, but not by BigDecimal. If you need to distinguish positive and negative zero, you should call IonDecimal.decimalValue() or IonFloat.doubleValue() after casting to the appropriate type.

        Returns:
        the BigDecimal value, or null if this.isNullValue().
        Throws:
        java.lang.NumberFormatException - if this value is nan, +inf, or -inf, because BigDecimal cannot represent those values.
      • isNumericValue

        boolean isNumericValue()
        Determines whether this value is numeric. Returns true if this value is none of null, nan, +inf, and -inf, and false if it is any of them.
        Returns:
        a checked condition whether this value is numeric.