Class JSONNumberValue


  • public class JSONNumberValue
    extends JSONValue
    JSON value class representing a number value.

    A number can either be a floating point number or an integer number. To avoid platform specific problems, all integer numbers can be up to signed 64 bits, and all floating point values are 64 bits.

    • Method Detail

      • fromDouble

        public static JSONNumberValue fromDouble​(double doubleValue)
        Factory method for constructing a JSONNumberValue from a double.
        Parameters:
        doubleValue - The double value.
        Returns:
        Newly created JSONNumberValue
      • fromNumberLiteral

        public static JSONNumberValue fromNumberLiteral​(java.lang.String literalValue)
        Factory method for constructing a JSONNumberValue from a number literal.
        Parameters:
        literalValue - The number literal, which might either be an integer value or a floating point value.
        Returns:
        null if literalValue is null or does not represent a number or a newly created JSONNumberValue.
      • isNumber

        public boolean isNumber()
        Description copied from class: JSONValue
        Get a boolean indicating whether this instance represents a JSON numeric value or not.
        Overrides:
        isNumber in class JSONValue
        Returns:
        true for objects representing a numeric value, false otherwise.
      • isInteger

        public boolean isInteger()
        Get a boolean indicating whether this JSONNumberValue represents an integer value or not.
        Returns:
        true if this instance represents an integer value, false otherwise.
      • isIntValue

        public boolean isIntValue()
        Get a boolean indicating whether this JSONNumberValue represents a 32-bit integer or not.
        Returns:
        true if this instance represents an integer value, false otherwise.
      • getIntValue

        public int getIntValue()
        Get a 32-bit integer value.

        If this instance is representing a double or long value, then the result is the value casted to an int.

        Returns:
        32-bit integer value represented by this instance.
      • getLongValue

        public long getLongValue()
        Get a 64-bit integer value.

        If this instance is representing a double, then the result is the value casted to a long.

        Returns:
        64-bit integer value represented by this instance.
      • getFloatValue

        public float getFloatValue()
        Get a 32-bit floating point value.
        Returns:
        32-bit floating point value represented by this instance.
      • getDoubleValue

        public double getDoubleValue()
        Get a 64-bit floating point value.
        Returns:
        64-bit floating point value represented by this instance.
      • isFinite

        public boolean isFinite()
        Checks if the number is finite.
        Returns:
        True if number is finite.