com.mongodb.util
Class StringParseUtil

java.lang.Object
  extended by com.mongodb.util.StringParseUtil

public final class StringParseUtil
extends java.lang.Object


Constructor Summary
StringParseUtil()
           
 
Method Summary
static boolean parseBoolean(java.lang.String s, boolean d)
          Turns a string into a boolean value and returns a default value if unsuccessful.
static int parseIfInt(java.lang.String s, int def)
           
static int parseInt(java.lang.String s, int def)
          Turns a string into an int and returns a default value if unsuccessful.
static int parseInt(java.lang.String s, int def, int[] lastIdx, boolean allowNegative)
          Turns a string into an int and returns a default value if unsuccessful.
static java.lang.Number parseIntRadix(java.lang.String s, int radix)
          Turns a string into an int using a given radix.
static java.lang.Number parseNumber(java.lang.String s, java.lang.Number def)
          Turns a string into a Number and returns a default value if unsuccessful.
static java.lang.Number parseStrict(java.lang.String s)
          Use Java's "strict parsing" methods Integer.parseInt and Double.parseDouble to parse s "strictly".
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StringParseUtil

public StringParseUtil()
Method Detail

parseBoolean

public static boolean parseBoolean(java.lang.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

parseInt

public static int parseInt(java.lang.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

parseIntRadix

public static java.lang.Number parseIntRadix(java.lang.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

parseInt

public static int parseInt(java.lang.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

parseNumber

public static java.lang.Number parseNumber(java.lang.String s,
                                           java.lang.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

parseStrict

public static java.lang.Number parseStrict(java.lang.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

parseIfInt

public static int parseIfInt(java.lang.String s,
                             int def)