Class AbstractJsonFloatingPointBitsFromByteArray
java.lang.Object
ch.randelshofer.fastdoubleparser.AbstractNumberParser
ch.randelshofer.fastdoubleparser.AbstractFloatValueParser
ch.randelshofer.fastdoubleparser.AbstractJsonFloatingPointBitsFromByteArray
- Direct Known Subclasses:
JsonDoubleBitsFromByteArray
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.
-
Field Summary
Fields inherited from class AbstractFloatValueParser
MAX_EXPONENT_NUMBER, MAX_INPUT_LENGTH, MINIMAL_NINETEEN_DIGIT_INTEGERFields inherited from class AbstractNumberParser
CHAR_TO_HEX_MAP, DECIMAL_POINT_CLASS, ILLEGAL_OFFSET_OR_ILLEGAL_LENGTH, OTHER_CLASS, SYNTAX_ERROR, SYNTAX_ERROR_BITS, VALUE_EXCEEDS_LIMITS -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal longparseNumber(byte[] str, int offset, int length) Parses anumberproduction.(package private) abstract longvalueOfFloatLiteral(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.Methods inherited from class AbstractNumberParser
charAt, charAt, charAt, checkBounds, checkBounds, lookupHex, lookupHex
-
Constructor Details
-
AbstractJsonFloatingPointBitsFromByteArray
AbstractJsonFloatingPointBitsFromByteArray()
-
-
Method Details
-
parseNumber
public final long parseNumber(byte[] str, int offset, int length) Parses anumberproduction.See
JsonDoubleParserfor the grammar ofnumber.- Parameters:
str- a string containing aFloatingPointLiteralWithWhiteSpaceoffset- start offset ofFloatingPointLiteralWithWhiteSpaceinstrlength- length ofFloatingPointLiteralWithWhiteSpaceinstr- 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 stringendIndex- the end index (exclusive) of the float literal inside the stringisNegative- whether the float value is negativesignificand- the significand of the float value (can be truncated)exponent- the exponent of the float valueisSignificandTruncated- whether the significand is truncatedexponentOfTruncatedSignificand- the exponent value of the truncated significand- Returns:
- the bit pattern of the parsed value, if the input is legal;
otherwise,
-1L.
-