Class AbstractNumberParser

    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) static byte[] CHAR_TO_HEX_MAP
      Includes all non-negative values of a byte, so that we only have to check for byte values < 0 before accessing this array.
      (package private) static byte DECIMAL_POINT_CLASS
      Special value in CHAR_TO_HEX_MAP for the decimal point character.
      static java.lang.String ILLEGAL_OFFSET_OR_ILLEGAL_LENGTH
      Message text for the IllegalArgumentException that is thrown when offset or length are illegal
      (package private) static byte OTHER_CLASS
      Special value in CHAR_TO_HEX_MAP for characters that are neither a hex digit nor a decimal point character..
      static java.lang.String SYNTAX_ERROR
      Message text for the NumberFormatException that is thrown when the syntax is illegal.
      static long SYNTAX_ERROR_BITS
      Uses the unused mantissa of a NaN value to encode a syntax error.
      static java.lang.String VALUE_EXCEEDS_LIMITS
      Message text for the NumberFormatException that is thrown when there are too many input digits.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      protected static byte charAt​(byte[] str, int i, int endIndex)
      Returns the character at the specified index if index is < endIndex; otherwise returns 0.
      protected static char charAt​(char[] str, int i, int endIndex)
      Returns the character at the specified index if index is < endIndex; otherwise returns 0.
      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.
      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.
      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.
      protected static int lookupHex​(byte ch)
      Looks the character up in the CHAR_TO_HEX_MAP returns a value < 0 if the character is not in the map.
      protected static int lookupHex​(char ch)
      Looks the character up in the CHAR_TO_HEX_MAP returns a value < 0 if the character is not in the map.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • ILLEGAL_OFFSET_OR_ILLEGAL_LENGTH

        public static final java.lang.String ILLEGAL_OFFSET_OR_ILLEGAL_LENGTH
        Message text for the IllegalArgumentException that 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 the NumberFormatException that 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 the NumberFormatException that is thrown when there are too many input digits.
        See Also:
        Constant Field Values
      • OTHER_CLASS

        static final byte OTHER_CLASS
        Special value in CHAR_TO_HEX_MAP for 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 a byte, so that we only have to check for byte values < 0 before accessing this array.
    • Constructor Detail

      • AbstractNumberParser

        AbstractNumberParser()
    • 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 string
        i - the index
        endIndex - 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 string
        i - the index
        endIndex - 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 string
        i - the index
        endIndex - the end index
        Returns:
        the character or 0
      • lookupHex

        protected static int lookupHex​(byte ch)
        Looks the character up in the CHAR_TO_HEX_MAP returns 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 the CHAR_TO_HEX_MAP returns 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