Class AbstractNumberParser

java.lang.Object
ch.randelshofer.fastdoubleparser.AbstractNumberParser
Direct Known Subclasses:
AbstractBigDecimalParser, AbstractBigIntegerParser, AbstractFloatValueParser

abstract class AbstractNumberParser extends Object
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    (package private) static final byte[]
    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 final byte
    Special value in CHAR_TO_HEX_MAP for the decimal point character.
    static final String
    Message text for the IllegalArgumentException that is thrown when offset or length are illegal
    (package private) static final byte
    Special value in CHAR_TO_HEX_MAP for characters that are neither a hex digit nor a decimal point character..
    static final String
    Message text for the NumberFormatException that is thrown when the syntax is illegal.
    static final long
    Uses the unused mantissa of a NaN value to encode a syntax error.
    static final String
    Message text for the NumberFormatException that is thrown when there are too many input digits.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    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(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 Object

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

    • ILLEGAL_OFFSET_OR_ILLEGAL_LENGTH

      public static final String ILLEGAL_OFFSET_OR_ILLEGAL_LENGTH
      Message text for the IllegalArgumentException that is thrown when offset or length are illegal
      See Also:
    • SYNTAX_ERROR

      public static final String SYNTAX_ERROR
      Message text for the NumberFormatException that is thrown when the syntax is illegal.
      See Also:
    • 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:
    • VALUE_EXCEEDS_LIMITS

      public static final String VALUE_EXCEEDS_LIMITS
      Message text for the NumberFormatException that is thrown when there are too many input digits.
      See Also:
    • DECIMAL_POINT_CLASS

      static final byte DECIMAL_POINT_CLASS
      Special value in CHAR_TO_HEX_MAP for the decimal point character.
      See Also:
    • 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:
    • 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 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 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(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