Package ch.randelshofer.fastdoubleparser
Class AbstractNumberParser
- java.lang.Object
-
- ch.randelshofer.fastdoubleparser.AbstractNumberParser
-
- Direct Known Subclasses:
AbstractBigDecimalParser,AbstractBigIntegerParser,AbstractFloatValueParser
abstract class AbstractNumberParser extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static 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.(package private) static byteDECIMAL_POINT_CLASSSpecial value inCHAR_TO_HEX_MAPfor the decimal point character.static java.lang.StringILLEGAL_OFFSET_OR_ILLEGAL_LENGTHMessage text for theIllegalArgumentExceptionthat is thrown when offset or length are illegal(package private) static byteOTHER_CLASSSpecial value inCHAR_TO_HEX_MAPfor characters that are neither a hex digit nor a decimal point character..static java.lang.StringSYNTAX_ERRORMessage text for theNumberFormatExceptionthat is thrown when the syntax is illegal.static longSYNTAX_ERROR_BITSUses the unused mantissa of a NaN value to encode a syntax error.static java.lang.StringVALUE_EXCEEDS_LIMITSMessage text for theNumberFormatExceptionthat is thrown when there are too many input digits.
-
Constructor Summary
Constructors Constructor Description AbstractNumberParser()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description protected 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(java.lang.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 Detail
-
ILLEGAL_OFFSET_OR_ILLEGAL_LENGTH
public static final java.lang.String ILLEGAL_OFFSET_OR_ILLEGAL_LENGTH
Message text for theIllegalArgumentExceptionthat is thrown when offset or length are illegal- See Also:
- Constant Field Values
-
SYNTAX_ERROR
public static final java.lang.String SYNTAX_ERROR
Message text for theNumberFormatExceptionthat is thrown when the syntax is illegal.- See Also:
- Constant Field Values
-
SYNTAX_ERROR_BITS
public static final long SYNTAX_ERROR_BITS
Uses the unused mantissa of a NaN value to encode a syntax error.- See Also:
- Constant Field Values
-
VALUE_EXCEEDS_LIMITS
public static final java.lang.String VALUE_EXCEEDS_LIMITS
Message text for theNumberFormatExceptionthat is thrown when there are too many input digits.- See Also:
- Constant Field Values
-
DECIMAL_POINT_CLASS
static final byte DECIMAL_POINT_CLASS
Special value inCHAR_TO_HEX_MAPfor the decimal point character.- See Also:
- Constant Field Values
-
OTHER_CLASS
static final byte OTHER_CLASS
Special value inCHAR_TO_HEX_MAPfor characters that are neither a hex digit nor a decimal point character..- See Also:
- Constant Field Values
-
CHAR_TO_HEX_MAP
static final byte[] CHAR_TO_HEX_MAP
Includes all non-negative values of abyte, so that we only have to check for byte values < 0 before accessing this array.
-
-
Method Detail
-
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
protected static char charAt(java.lang.CharSequence 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
-
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
-
-