public final class NumberInput extends Object
Modifier and Type | Field and Description |
---|---|
static String |
NASTY_SMALL_DOUBLE
Textual representation of a double constant that can cause nasty problems
with JDK (see http://www.exploringbinary.com/java-hangs-when-converting-2-2250738585072012e-308).
|
Constructor and Description |
---|
NumberInput() |
Modifier and Type | Method and Description |
---|---|
static boolean |
inLongRange(char[] digitChars,
int offset,
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 numberStr,
boolean negative)
Similar to
inLongRange(char[],int,int,boolean) , but
with String argument |
static double |
parseAsDouble(String input,
double defaultValue) |
static int |
parseAsInt(String input,
int defaultValue) |
static long |
parseAsLong(String input,
long defaultValue) |
static BigDecimal |
parseBigDecimal(char[] buffer) |
static BigDecimal |
parseBigDecimal(char[] buffer,
int offset,
int len) |
static BigDecimal |
parseBigDecimal(String numStr) |
static double |
parseDouble(String numStr) |
static int |
parseInt(char[] digitChars,
int offset,
int len)
Fast method for parsing integers that are known to fit into
regular 32-bit signed int type.
|
static int |
parseInt(String str)
Helper method to (more) efficiently parse integer numbers from
String values.
|
static long |
parseLong(char[] digitChars,
int offset,
int len) |
static long |
parseLong(String str) |
public static final String NASTY_SMALL_DOUBLE
public static int parseInt(char[] digitChars, int offset, int len)
Note: public to let unit tests call it
public static int parseInt(String str)
public static long parseLong(char[] digitChars, int offset, int len)
public static long parseLong(String str)
public static boolean inLongRange(char[] digitChars, int offset, int len, boolean negative)
negative
- Whether original number had a minus sign (which is
NOT passed to this method) or notpublic static boolean inLongRange(String numberStr, boolean negative)
inLongRange(char[],int,int,boolean)
, but
with String argumentnegative
- Whether original number had a minus sign (which is
NOT passed to this method) or notpublic static int parseAsInt(String input, int defaultValue)
public static long parseAsLong(String input, long defaultValue)
public static double parseAsDouble(String input, double defaultValue)
public static double parseDouble(String numStr) throws NumberFormatException
NumberFormatException
public static BigDecimal parseBigDecimal(String numStr) throws NumberFormatException
NumberFormatException
public static BigDecimal parseBigDecimal(char[] buffer) throws NumberFormatException
NumberFormatException
public static BigDecimal parseBigDecimal(char[] buffer, int offset, int len) throws NumberFormatException
NumberFormatException
Copyright © 2012-2014 FasterXML. All Rights Reserved.