public final class StringParseUtil extends Object
Constructor and Description |
---|
StringParseUtil() |
Modifier and Type | Method and Description |
---|---|
static boolean |
parseBoolean(String s,
boolean d)
Turns a string into a boolean value and returns a default value if unsuccessful.
|
static int |
parseIfInt(String s,
int def) |
static int |
parseInt(String s,
int def)
Turns a string into an int and returns a default value if unsuccessful.
|
static int |
parseInt(String s,
int def,
int[] lastIdx,
boolean allowNegative)
Turns a string into an int and returns a default value if unsuccessful.
|
static Number |
parseIntRadix(String s,
int radix)
Turns a string into an int using a given radix.
|
static Number |
parseNumber(String s,
Number def)
Turns a string into a Number and returns a default value if unsuccessful.
|
static Number |
parseStrict(String s)
Use Java's "strict parsing" methods Integer.parseInt and Double.parseDouble to parse s "strictly".
|
public static boolean parseBoolean(String s, boolean d)
s
- the string to convertd
- the default valuepublic static int parseInt(String s, int def)
s
- the string to convertdef
- the default valuepublic static Number parseIntRadix(String s, int radix)
s
- the string to convertradix
- radix to usepublic static int parseInt(String s, int def, int[] lastIdx, boolean allowNegative)
s
- the string to convertdef
- the default valuelastIdx
- sets lastIdx[0] to the index of the last digitallowNegative
- if negative numbers are validpublic static Number parseNumber(String s, Number def)
s
- the string to convertdef
- the default valuepublic static Number parseStrict(String s)
s
- the string to convertpublic static int parseIfInt(String s, int def)