Class Overview
Miscellaneous utility methods for number conversion and parsing.
Mainly for internal use within the framework; consider Jakarta's
Commons Lang for a more comprehensive suite of string utilities.
Summary
Public Methods |
static
<T extends Number>
T
|
convertNumberToTargetClass(Number number, Class<T> targetClass)
Convert the given number into an instance of the given target class.
|
static
<T extends Number>
T
|
parseNumber(String text, Class<T> targetClass)
Parse the given text into a number instance of the given target class,
using the corresponding decode / valueOf methods.
|
static
<T extends Number>
T
|
parseNumber(String text, Class<T> targetClass, NumberFormat numberFormat)
Parse the given text into a number instance of the given target class,
using the given NumberFormat.
|
[Expand]
Inherited Methods |
From class
java.lang.Object
Object
|
clone()
|
boolean
|
equals(Object arg0)
|
void
|
finalize()
|
final
Class<?>
|
getClass()
|
int
|
hashCode()
|
final
void
|
notify()
|
final
void
|
notifyAll()
|
String
|
toString()
|
final
void
|
wait()
|
final
void
|
wait(long arg0, int arg1)
|
final
void
|
wait(long arg0)
|
|
Public Constructors
Public Methods
public
static
T
convertNumberToTargetClass
(Number number, Class<T> targetClass)
Convert the given number into an instance of the given target class.
Parameters
number
| the number to convert |
targetClass
| the target class to convert to |
Throws
IllegalArgumentException
| if the target class is not supported
(i.e. not a standard Number subclass as included in the JDK) |
public
static
T
parseNumber
(String text, Class<T> targetClass)
Parse the given text into a number instance of the given target class,
using the corresponding decode
/ valueOf
methods.
Trims the input String
before attempting to parse the number.
Supports numbers in hex format (with leading "0x", "0X" or "#") as well.
Parameters
text
| the text to convert |
targetClass
| the target class to parse into |
Throws
IllegalArgumentException
| if the target class is not supported
(i.e. not a standard Number subclass as included in the JDK) |
public
static
T
parseNumber
(String text, Class<T> targetClass, NumberFormat numberFormat)
Parse the given text into a number instance of the given target class,
using the given NumberFormat. Trims the input String
before attempting to parse the number.
Parameters
text
| the text to convert |
targetClass
| the target class to parse into |
numberFormat
| the NumberFormat to use for parsing (if null ,
this method falls back to parseNumber(String, Class) ) |
Throws
IllegalArgumentException
| if the target class is not supported
(i.e. not a standard Number subclass as included in the JDK) |