public final class

StringParseUtil

extends Object
java.lang.Object
   ↳ com.mongodb.util.StringParseUtil

Summary

Public Constructors
StringParseUtil()
Public Methods
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, int[] lastIdx, boolean allowNegative)
Turns a string into an int and returns a default value if unsuccessful.
static int parseInt(String s, int def)
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".
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public StringParseUtil ()

Public Methods

public static boolean parseBoolean (String s, boolean d)

Turns a string into a boolean value and returns a default value if unsuccessful.

Parameters
s the string to convert
d the default value
Returns
  • equivalent boolean value

public static int parseIfInt (String s, int def)

public static int parseInt (String s, int def, int[] lastIdx, boolean allowNegative)

Turns a string into an int and returns a default value if unsuccessful.

Parameters
s the string to convert
def the default value
lastIdx sets lastIdx[0] to the index of the last digit
allowNegative if negative numbers are valid
Returns
  • the int value

public static int parseInt (String s, int def)

Turns a string into an int and returns a default value if unsuccessful.

Parameters
s the string to convert
def the default value
Returns
  • the int value

public static Number parseIntRadix (String s, int radix)

Turns a string into an int using a given radix.

Parameters
s the string to convert
radix radix to use
Returns
  • the int value

public static Number parseNumber (String s, Number def)

Turns a string into a Number and returns a default value if unsuccessful.

Parameters
s the string to convert
def the default value
Returns
  • the numeric value

public static Number parseStrict (String s)

Use Java's "strict parsing" methods Integer.parseInt and Double.parseDouble to parse s "strictly". i.e. if it's neither a double or an integer, fail.

Parameters
s the string to convert
Returns
  • the numeric value