com.foxsmart.ic.util
Class NumberUtils

java.lang.Object
  extended by com.foxsmart.ic.util.NumberUtils

public class NumberUtils
extends java.lang.Object

This class provides various number utilities via static methods.


Constructor Summary
NumberUtils()
           
 
Method Summary
static java.math.BigDecimal getBigDecimalNumber(java.lang.String number)
          Converts the passed in string to a BigDecimal.
static java.lang.Double getDoubleNumber(java.lang.String number)
          Converts the passed in string to a double.
static java.lang.Integer getIntegerNumber(java.lang.String number)
          Converts the passed in string to an integer.
static java.lang.Long getLongNumber(java.lang.String number)
          Converts the passed in string to a long.
static boolean isValidNumber(java.lang.Number number, java.lang.Number lowRange, java.lang.Number highRange)
          Determines if a number is valid and is between a specified range.
static boolean isValidNumber(java.lang.String number)
          Determines if the passed in string value is a number.
static boolean isValidNumber(java.lang.String number, java.lang.Integer lowRange, java.lang.Integer highRange)
          Determines if a number is valid and is between a specified range.
static void validateNumber(java.lang.Number number, java.lang.Number lowRange, java.lang.Number highRange)
          Validates that a number if between a specified range, inclusive.
static void validateNumber(java.lang.String number, java.lang.Number lowRange, java.lang.Number highRange)
          Validates that a number (specified as a string) is between a specified range, inclusive.
 
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

validateNumber

public static void validateNumber(java.lang.Number number,
                                  java.lang.Number lowRange,
                                  java.lang.Number highRange)
                           throws java.lang.IllegalArgumentException
Validates that a number if between a specified range, inclusive. If number is null, an exception will be thrown.

Parameters:
number - The number to validate.
lowRange - The low range for the number. If this parameter is null, no low range check will be performed.
highRange - The high range for the number. If this parameters is null, no high range check will be performed.
Throws:
java.lang.IllegalArgumentException - if the number fails a validation.

validateNumber

public static void validateNumber(java.lang.String number,
                                  java.lang.Number lowRange,
                                  java.lang.Number highRange)
                           throws java.lang.IllegalArgumentException
Validates that a number (specified as a string) is between a specified range, inclusive. If number is null or empty, an exception will be thrown.

Parameters:
number - The number to validate specified as a string.
lowRange - The low range for the number. If this parameter is null, no low range check will be performed.
highRange - The high range for the number. If this parameters is null, no high range check will be performed.
Throws:
java.lang.IllegalArgumentException - if the number fails a validation or if number isn't a valid number.

isValidNumber

public static boolean isValidNumber(java.lang.Number number,
                                    java.lang.Number lowRange,
                                    java.lang.Number highRange)
Determines if a number is valid and is between a specified range. See the validNumber methods for details.

Parameters:
number - The number to validate.
lowRange - The low range for the number. If this parameter is null, no low range check will be performed.
highRange - The high range for the number. If this parameters is null, no high range check will be performed.
Returns:
True if the number is valid or false if not.

isValidNumber

public static boolean isValidNumber(java.lang.String number,
                                    java.lang.Integer lowRange,
                                    java.lang.Integer highRange)
Determines if a number is valid and is between a specified range. See the validNumber methods for details.

Parameters:
number - The number to validate specified as a string.
lowRange - The low range for the number. If this parameter is null, no low range check will be performed.
highRange - The high range for the number. If this parameters is null, no high range check will be performed.
Returns:
True if the number is valid or false if not.

isValidNumber

public static boolean isValidNumber(java.lang.String number)
Determines if the passed in string value is a number.

Parameters:
number - The string to validate.
Returns:
True if the number is valid or false if not.

getIntegerNumber

public static java.lang.Integer getIntegerNumber(java.lang.String number)
                                          throws java.lang.IllegalArgumentException
Converts the passed in string to an integer. If the string can't be converted to a number, an exception is thrown. If null or the empty string is passed in, an exception is also thrown.

Parameters:
number - The string to convert to a number.
Returns:
the integer version of the number.
Throws:
java.lang.IllegalArgumentException - if the string isn't a valid number.

getLongNumber

public static java.lang.Long getLongNumber(java.lang.String number)
                                    throws java.lang.IllegalArgumentException
Converts the passed in string to a long. If the string can't be converted to a number, an exception is thrown. If null or the empty string is passed in, an exception is also thrown.

Parameters:
number - The string to convert to a number.
Returns:
the long version of the number.
Throws:
java.lang.IllegalArgumentException - if the string isn't a valid number.

getDoubleNumber

public static java.lang.Double getDoubleNumber(java.lang.String number)
                                        throws java.lang.IllegalArgumentException
Converts the passed in string to a double. If the string can't be converted to a number, an exception is thrown. If null or the empty string is passed in, an exception is also thrown.

Parameters:
number - The string to convert to a number.
Returns:
the double version of the number.
Throws:
java.lang.IllegalArgumentException - if the string isn't a valid number.

getBigDecimalNumber

public static java.math.BigDecimal getBigDecimalNumber(java.lang.String number)
                                                throws java.lang.IllegalArgumentException
Converts the passed in string to a BigDecimal. If the string can't be converted to a number, an exception is thrown. If null or the empty string is passed in, an exception is also thrown.

Parameters:
number - The string to convert to a number.
Returns:
the big decimal version of the number.
Throws:
java.lang.IllegalArgumentException - if the string isn't a valid number.


Copyright © 2005-2008 Fox Smart, Inc. All Rights Reserved.