com.generationjava.lang
Class NumberW

java.lang.Object
  extended by com.generationjava.lang.NumberW

public final class NumberW
extends java.lang.Object

Provides extra functionality for java Number classes.


Constructor Summary
NumberW()
           
 
Method Summary
static boolean containsDigits(java.lang.String val)
          Return true if the string contains only digit characters.
static java.math.BigDecimal createBigDecimal(java.lang.String val)
           
static java.math.BigInteger createBigInteger(java.lang.String val)
           
static java.lang.Double createDouble(java.lang.String val)
           
static java.lang.Float createFloat(java.lang.String val)
           
static java.lang.Integer createInteger(java.lang.String val)
           
static java.lang.Long createLong(java.lang.String val)
           
static java.lang.Number createNumber(java.lang.String val)
          Turns a string value into a java.lang.Number.
static boolean isNumber(java.lang.String str)
          Is a String a valid Java number.
static int minimum(int a, int b, int c)
          Get the minimum of three values.
static int stringToInt(java.lang.String str)
           
static int stringToInt(java.lang.String str, int def)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NumberW

public NumberW()
Method Detail

stringToInt

public static int stringToInt(java.lang.String str)

stringToInt

public static int stringToInt(java.lang.String str,
                              int def)

createNumber

public static java.lang.Number createNumber(java.lang.String val)
                                     throws java.lang.NumberFormatException
Turns a string value into a java.lang.Number. Strategy is to look for a decimal point. If that is seen then try first float and then try double. If this fails, then try int and then long. Assuming 50f fails and isn't 50, then try hexadecimal.

Parameters:
val - String containing a number
Returns:
Number created from the string
Throws:
java.lang.NumberFormatException

containsDigits

public static boolean containsDigits(java.lang.String val)
Return true if the string contains only digit characters.

Parameters:
val - String to check is only digits
Returns:
boolean contains only unicode numeric

createFloat

public static java.lang.Float createFloat(java.lang.String val)

createDouble

public static java.lang.Double createDouble(java.lang.String val)

createInteger

public static java.lang.Integer createInteger(java.lang.String val)

createLong

public static java.lang.Long createLong(java.lang.String val)

createBigInteger

public static java.math.BigInteger createBigInteger(java.lang.String val)

createBigDecimal

public static java.math.BigDecimal createBigDecimal(java.lang.String val)

minimum

public static int minimum(int a,
                          int b,
                          int c)
Get the minimum of three values.


isNumber

public static boolean isNumber(java.lang.String str)
Is a String a valid Java number. Doesn't allow scientific notation.