Package ch.randelshofer.fastdoubleparser
Class AbstractNumberParser
java.lang.Object
ch.randelshofer.fastdoubleparser.AbstractNumberParser
- Direct Known Subclasses:
AbstractBigDecimalParser,AbstractBigIntegerParser,AbstractFloatValueParser
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final byte[]Includes all non-negative values of abyte, so that we only have to check for byte values < 0 before accessing this array.(package private) static final byteSpecial value inCHAR_TO_HEX_MAPfor the decimal point character.static final StringMessage text for theIllegalArgumentExceptionthat is thrown when offset or length are illegal(package private) static final byteSpecial value inCHAR_TO_HEX_MAPfor characters that are neither a hex digit nor a decimal point character..static final StringMessage text for theNumberFormatExceptionthat is thrown when the syntax is illegal.static final longUses the unused mantissa of a NaN value to encode a syntax error.static final StringMessage text for theNumberFormatExceptionthat is thrown when there are too many input digits. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected static bytecharAt(byte[] str, int i, int endIndex) Returns the character at the specified index if index is < endIndex; otherwise returns 0.protected static charcharAt(char[] str, int i, int endIndex) Returns the character at the specified index if index is < endIndex; otherwise returns 0.protected static charcharAt(CharSequence str, int i, int endIndex) Returns the character at the specified index if index is < endIndex; otherwise returns 0.protected static intcheckBounds(int size, int offset, int length) Checks the bounds and returns the end index (exclusive) of the data in the array.protected static intcheckBounds(int size, int offset, int length, int maxInputLength) Checks the bounds and returns the end index (exclusive) of the data in the array.protected static intlookupHex(byte ch) Looks the character up in theCHAR_TO_HEX_MAPreturns a value < 0 if the character is not in the map.protected static intlookupHex(char ch) Looks the character up in theCHAR_TO_HEX_MAPreturns a value < 0 if the character is not in the map.
-
Field Details
-
ILLEGAL_OFFSET_OR_ILLEGAL_LENGTH
Message text for theIllegalArgumentExceptionthat is thrown when offset or length are illegal- See Also:
-
SYNTAX_ERROR
Message text for theNumberFormatExceptionthat is thrown when the syntax is illegal.- See Also:
-
SYNTAX_ERROR_BITS
public static final long SYNTAX_ERROR_BITSUses the unused mantissa of a NaN value to encode a syntax error.- See Also:
-
VALUE_EXCEEDS_LIMITS
Message text for theNumberFormatExceptionthat is thrown when there are too many input digits.- See Also:
-
DECIMAL_POINT_CLASS
static final byte DECIMAL_POINT_CLASSSpecial value inCHAR_TO_HEX_MAPfor the decimal point character.- See Also:
-
OTHER_CLASS
static final byte OTHER_CLASSSpecial value inCHAR_TO_HEX_MAPfor characters that are neither a hex digit nor a decimal point character..- See Also:
-
CHAR_TO_HEX_MAP
static final byte[] CHAR_TO_HEX_MAPIncludes all non-negative values of abyte, so that we only have to check for byte values < 0 before accessing this array.
-
-
Constructor Details
-
AbstractNumberParser
AbstractNumberParser()
-
-
Method Details
-
charAt
protected static byte charAt(byte[] str, int i, int endIndex) Returns the character at the specified index if index is < endIndex; otherwise returns 0.- Parameters:
str- the stringi- the indexendIndex- the end index- Returns:
- the character or 0
-
charAt
protected static char charAt(char[] str, int i, int endIndex) Returns the character at the specified index if index is < endIndex; otherwise returns 0.- Parameters:
str- the stringi- the indexendIndex- the end index- Returns:
- the character or 0
-
charAt
Returns the character at the specified index if index is < endIndex; otherwise returns 0.- Parameters:
str- the stringi- the indexendIndex- the end index- Returns:
- the character or 0
-
lookupHex
protected static int lookupHex(byte ch) Looks the character up in theCHAR_TO_HEX_MAPreturns a value < 0 if the character is not in the map.Returns -4 if the character is a decimal point.
- Parameters:
ch- a character- Returns:
- the hex value or a value < 0.
-
lookupHex
protected static int lookupHex(char ch) Looks the character up in theCHAR_TO_HEX_MAPreturns a value < 0 if the character is not in the map.Returns -1 if the character code is > 255.
Returns -4 if the character is a decimal point.
- Parameters:
ch- a character- Returns:
- the hex value or a value < 0.
-
checkBounds
protected static int checkBounds(int size, int offset, int length, int maxInputLength) Checks the bounds and returns the end index (exclusive) of the data in the array.- Parameters:
size- length of array (Must be in the range from 0 to max length of a Java array. This value is not checked, because this is an internal API!)offset- start-index of data into array (Must be non-negative and smaller than size)length- length of data (Must be non-negative and smaller than size - offset)maxInputLength- maximal input length that can yield a legal value- Returns:
- offset + length
-
checkBounds
protected static int checkBounds(int size, int offset, int length) Checks the bounds and returns the end index (exclusive) of the data in the array.- Parameters:
size- length of array (Must be in the range from 0 to max length of a Java array. This value is not checked, because this is an internal API!)offset- start-index of data into array (Must be non-negative and smaller than size)length- length of data (Must be non-negative and smaller than size - offset)- Returns:
- offset + length
-