Class NumberInput
java.lang.Object
edu.internet2.middleware.grouperClientExt.com.fasterxml.jackson.core.io.NumberInput
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
inLongRange
(char[] ch, int off, int len, boolean negative) Helper method for determining if given String representation of an integral number would fit in 64-bit Java long or not.static boolean
inLongRange
(String s, boolean negative) Similar toinLongRange(char[],int,int,boolean)
, but with String argumentstatic double
parseAsDouble
(String s, double def) static double
parseAsDouble
(String s, double def, boolean useFastParser) static int
parseAsInt
(String s, int def) static long
parseAsLong
(String s, long def) static BigDecimal
parseBigDecimal
(char[] ch) static BigDecimal
parseBigDecimal
(char[] ch, int off, int len) static BigDecimal
static BigInteger
static double
static double
parseDouble
(String s, boolean useFastParser) static float
parseFloat
(String s) static float
parseFloat
(String s, boolean useFastParser) static int
parseInt
(char[] ch, int off, int len) Fast method for parsing unsigned integers that are known to fit into regular 32-bit signed int type.static int
Helper method to (more) efficiently parse integer numbers from String values.static long
parseLong
(char[] ch, int off, int len) static long
Similar toparseInt(String)
but forlong
values.
-
Field Details
-
NASTY_SMALL_DOUBLE
Deprecated.Since 2.14 -- do not useFormerly used constant for a value that was problematic on certain pre-1.8 JDKs.- See Also:
-
-
Constructor Details
-
NumberInput
public NumberInput()
-
-
Method Details
-
parseInt
public static int parseInt(char[] ch, int off, int len) Fast method for parsing unsigned integers that are known to fit into regular 32-bit signed int type. This means that length is between 1 and 9 digits (inclusive) and there is no sign character.Note: public to let unit tests call it; not meant to be used by any code outside this package.
- Parameters:
ch
- Buffer that contains integer value to decodeoff
- Offset of the first digit character in bufferlen
- Length of the number to decode (in characters)- Returns:
- Decoded
int
value
-
parseInt
Helper method to (more) efficiently parse integer numbers from String values. Input String must be simple Java integer value. No range checks are made to verify that the value fits in 32-bit Javaint
: caller is expected to only calls this in cases where this can be guaranteed (basically: number of digits does not exceed 9)NOTE: semantics differ significantly from
parseInt(char[], int, int)
.- Parameters:
s
- String that contains integer value to decode- Returns:
- Decoded
int
value
-
parseLong
public static long parseLong(char[] ch, int off, int len) -
parseLong
Similar toparseInt(String)
but forlong
values.- Parameters:
s
- String that containslong
value to decode- Returns:
- Decoded
long
value
-
inLongRange
public static boolean inLongRange(char[] ch, int off, int len, boolean negative) Helper method for determining if given String representation of an integral number would fit in 64-bit Java long or not. Note that input String must NOT contain leading minus sign (even if 'negative' is set to true).- Parameters:
ch
- Buffer that contains long value to checkoff
- Offset of the first digit character in bufferlen
- Length of the number to decode (in characters)negative
- Whether original number had a minus sign (which is NOT passed to this method) or not- Returns:
True
if specified String representation is within Javalong
range;false
if not.
-
inLongRange
Similar toinLongRange(char[],int,int,boolean)
, but with String argument- Parameters:
s
- String that containslong
value to checknegative
- Whether original number had a minus sign (which is NOT passed to this method) or not- Returns:
True
if specified String representation is within Javalong
range;false
if not.
-
parseAsInt
-
parseAsLong
-
parseAsDouble
- Parameters:
s
- a string representing a number to parsedef
- the default to return if `s` is not a parseable number- Returns:
- closest matching double (or `def` if there is an issue with `s`) where useFastParser=false
- See Also:
-
parseAsDouble
- Parameters:
s
- a string representing a number to parsedef
- the default to return if `s` is not a parseable numberuseFastParser
- whether to useedu.internet2.middleware.grouperClientExt.com.fasterxml.jackson.core.io.doubleparser
- Returns:
- closest matching double (or `def` if there is an issue with `s`)
- Since:
- 2.14
-
parseDouble
- Parameters:
s
- a string representing a number to parse- Returns:
- closest matching double
- Throws:
NumberFormatException
- if string cannot be represented by a double where useFastParser=false- See Also:
-
parseDouble
- Parameters:
s
- a string representing a number to parseuseFastParser
- whether to useedu.internet2.middleware.grouperClientExt.com.fasterxml.jackson.core.io.doubleparser
- Returns:
- closest matching double
- Throws:
NumberFormatException
- if string cannot be represented by a double- Since:
- v2.14
-
parseFloat
- Parameters:
s
- a string representing a number to parse- Returns:
- closest matching float
- Throws:
NumberFormatException
- if string cannot be represented by a float where useFastParser=false- Since:
- v2.14
- See Also:
-
parseFloat
- Parameters:
s
- a string representing a number to parseuseFastParser
- whether to useedu.internet2.middleware.grouperClientExt.com.fasterxml.jackson.core.io.doubleparser
- Returns:
- closest matching float
- Throws:
NumberFormatException
- if string cannot be represented by a float- Since:
- v2.14
-
parseBigDecimal
- Throws:
NumberFormatException
-
parseBigDecimal
- Throws:
NumberFormatException
-
parseBigDecimal
- Throws:
NumberFormatException
-
parseBigInteger
- Parameters:
s
- a string representing a number to parse- Returns:
- a BigInteger
- Throws:
NumberFormatException
- if string cannot be represented by a BigInteger- Since:
- v2.14
-