Class AbstractJsonFloatingPointBitsFromCharSequence

Direct Known Subclasses:
JsonDoubleBitsFromCharSequence

abstract class AbstractJsonFloatingPointBitsFromCharSequence extends AbstractFloatValueParser
Parses a JSON number from a CharSequence.

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 Details

    • AbstractJsonFloatingPointBitsFromCharSequence

      AbstractJsonFloatingPointBitsFromCharSequence()
  • Method Details

    • parseNumber

      public final long parseNumber(CharSequence 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(CharSequence 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 number literal.
      Parameters:
      str - the string that contains the number literal (and maybe more)
      startIndex - the start index (inclusive) of the number literal inside the string
      endIndex - the end index (exclusive) of the number 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.