Class AbstractJsonFloatingPointBitsFromByteArray

  • Direct Known Subclasses:
    JsonDoubleBitsFromByteArray

    abstract class AbstractJsonFloatingPointBitsFromByteArray
    extends AbstractFloatValueParser
    Parses a JSon Number from a byte array.

    This class should have a type parameter for the return value of its parse methods. Unfortunately Java does not support type parameters for primitive types. As a workaround we use long. A long has enough bits to fit a double value or a float value.

    See JsonDoubleParser for the grammar of Number.

    • Constructor Detail

      • AbstractJsonFloatingPointBitsFromByteArray

        AbstractJsonFloatingPointBitsFromByteArray()
    • Method Detail

      • parseNumber

        public final long parseNumber​(byte[] str,
                                      int offset,
                                      int length)
        Parses a number production.

        See JsonDoubleParser for the grammar of number.

        Parameters:
        str - a string containing a FloatingPointLiteralWithWhiteSpace
        offset - start offset of FloatingPointLiteralWithWhiteSpace in str
        length - length of FloatingPointLiteralWithWhiteSpace in str
        Returns:
        the bit pattern of the parsed value, if the input is legal; otherwise, -1L.
      • valueOfFloatLiteral

        abstract long valueOfFloatLiteral​(byte[] str,
                                          int startIndex,
                                          int endIndex,
                                          boolean isNegative,
                                          long significand,
                                          int exponent,
                                          boolean isSignificandTruncated,
                                          int exponentOfTruncatedSignificand)
        Computes a float value from the given components of a decimal float literal.
        Parameters:
        str - the string that contains the float literal (and maybe more)
        startIndex - the start index (inclusive) of the float literal inside the string
        endIndex - the end index (exclusive) of the float literal inside the string
        isNegative - whether the float value is negative
        significand - the significand of the float value (can be truncated)
        exponent - the exponent of the float value
        isSignificandTruncated - whether the significand is truncated
        exponentOfTruncatedSignificand - the exponent value of the truncated significand
        Returns:
        the bit pattern of the parsed value, if the input is legal; otherwise, -1L.