com.adobe.mediacore.utils
Class NumberUtils

java.lang.Object
  extended by com.adobe.mediacore.utils.NumberUtils

public class NumberUtils
extends Object

Class containing various helper methods related to numbers.


Constructor Summary
NumberUtils()
           
 
Method Summary
static boolean isNumeric(String input)
          Check if the input provided is a number.
static boolean parseBoolean(String value)
          Parse input to boolean.
static long parseLong(String value, long defaultValue)
          Returns the long value extracted from the provided string.
static long parseNumber(String value, long defaultValue)
          Returns the long value extracted from the provided string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NumberUtils

public NumberUtils()
Method Detail

parseLong

public static long parseLong(String value,
                             long defaultValue)
Returns the long value extracted from the provided string.

If the provided string doesn't contain a valid number or a NumberFormatException is raised while parsing the provided value to Long, then the default value will be returned.

Parameters:
value - the string value to be parsed
defaultValue - the default value to be returned in case of an error
Returns:
the long value if the input can be parsed, defaultValue otherwise.

parseNumber

public static long parseNumber(String value,
                               long defaultValue)
Returns the long value extracted from the provided string.

If the provided string doesn't contain a valid number or a NumberFormatException is raised while parsing the provided value to Double, then the default value will be returned.

Parameters:
value - the input string to be parsed to number
defaultValue - the default value to be returned in case of an error
Returns:
the long value if the input can be parsed, defaultValue otherwise.

parseBoolean

public static boolean parseBoolean(String value)
                            throws NumberFormatException
Parse input to boolean.

Parameters:
value - the input string to be parsed to boolean
Returns:
the boolean value
Throws:
NumberFormatException - if the input is not a boolean

isNumeric

public static boolean isNumeric(String input)
Check if the input provided is a number.

Parameters:
input - the string to be checked
Returns:
true if the input is a number, false otherwise