|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jasig.portal.lang.TypeConverter
public final class TypeConverter
The TypeConverter class provides efficient and
consistent static type converter utilities for the basic types.
| Field Summary | |
|---|---|
private static char[] |
DIGITS
Hexidecimal digits. |
static java.lang.String |
FALSE
Canonical string representation of false. |
static java.lang.String |
TRUE
Canonical string representation of true. |
| Constructor Summary | |
|---|---|
private |
TypeConverter()
Private constructor. |
| Method Summary | |
|---|---|
static boolean |
isInt(java.lang.String value)
Returns true if the value can be parsed to an
int. |
static boolean |
toBoolean(java.lang.String value)
Returns the boolean value represented by the
specified string, ignoring case. |
static byte |
toByte(java.lang.String value)
Returns a signed decimal byte value. |
static char |
toChar(java.lang.String value)
Returns the first character of the string. |
static double |
toDouble(java.lang.String value)
Returns a new double initialized to the value represented by the specified String, as performed by the valueOf method of class Double. |
static float |
toFloat(java.lang.String value)
Returns a new float initialized to the value represented by the specified String, as performed by the valueOf method of class Double. |
static java.lang.String |
toHexString(byte[] values)
Returns a hexidecimal string representation of the specified byte array. |
static java.lang.String |
toHexString(long value)
Converts a long value to a hexidecimal string. |
static int |
toInt(java.lang.String value)
Parses the string argument as a signed decimal integer. |
static long |
toLong(java.lang.String value)
Parses the string argument as a signed long in the radix specified by the second argument. |
static short |
toShort(java.lang.String value)
Returns the short representation of the specified
string. |
static java.lang.String |
toString(boolean value)
Returns a canonical String object representing the
specified boolean. |
static java.lang.String |
toString(byte value)
Returns a string representation of the argument of radix 10. |
static java.lang.String |
toString(char value)
Returns a string representation of the argument. |
static java.lang.String |
toString(double value)
Returns a string representation of the specified double. |
static java.lang.String |
toString(float value)
Returns a string representation of the specified float. |
static java.lang.String |
toString(int value)
Returns a string representation of the specified int. |
static java.lang.String |
toString(long value)
Returns a string representation of the specified long. |
static java.lang.String |
toString(short value)
Returns a string representation of the specified short value of radix 10. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String TRUE
true.
public static final java.lang.String FALSE
false.
private static final char[] DIGITS
| Constructor Detail |
|---|
private TypeConverter()
| Method Detail |
|---|
public static final java.lang.String toString(boolean value)
String object representing the
specified boolean. If the value is
true, the string "true" will be
returned; if the value is false, the string
"false".
value - boolean value to be converted
boolean valuepublic static final boolean toBoolean(java.lang.String value)
boolean value represented by the
specified string, ignoring case. If the value is neither
"true", nor "false" (ignoring case),
an IllegalArgumentException is thrown.
Note: This implementation is different than the
java.lang.Boolean implementation. The
java.lang.Boolean treats null and any
non-"true" value (ignoring case) as
false, i.e., there is no validation of
false values.
value - string representation of a boolean value
boolean value represented by the argument
java.lang.IllegalArgumentException - if value is (ignoring case)
neither "true", nor "false"public static final java.lang.String toString(byte value)
value - byte value to be converted
public static final byte toByte(java.lang.String value)
byte value. The
characters in the string must all be decimal digits, except
that the first character may be an ASCII minus sign '-'
('-') to indicate a negative value.
value - string representation of a byte value
byte value represented by the argument
java.lang.IllegalArgumentException - if argument is not a parseable
bytepublic static final java.lang.String toString(char value)
value - char value to be converted
public static final char toChar(java.lang.String value)
value - string representation of the char
char representation of the argument
java.lang.IllegalArgumentException - if value is
null or of zero lengthpublic static final java.lang.String toString(short value)
short value of radix 10.
value - short value to be converted
public static final short toShort(java.lang.String value)
short representation of the specified
string. The characters in the string must all be decimal
digits, except that the first character may be an ASCII minus
sign '-' ('-') to indicate a negative value.
value - string representation of the short
short representation of the argument
java.lang.IllegalArgumentException - if argument is not a parseable
shortpublic static final java.lang.String toString(int value)
int.
value - int >value to be converted
public static final int toInt(java.lang.String value)
value - string representation of the int
int representation of the argument
java.lang.IllegalArgumentException - if string does not contain a
parseable intpublic static final boolean isInt(java.lang.String value)
true if the value can be parsed to an
int.
value - string representation of the int
true if argument is an int;
otherwise falsepublic static final java.lang.String toString(long value)
long.
value - long value to be converted
public static final long toLong(java.lang.String value)
value - string representation of the long
long representation of the argument
java.lang.IllegalArgumentException - if string does not contain a
parseable longpublic static final java.lang.String toString(float value)
float.
value - float value to be converted
public static final float toFloat(java.lang.String value)
value - string representation of the long
long representation of the argument
java.lang.IllegalArgumentException - if string does not contain a
parseable longpublic static final java.lang.String toString(double value)
double.
value - double value to be converted
public static final double toDouble(java.lang.String value)
value - string representation of the long
long representation of the argument
java.lang.IllegalArgumentException - if string does not contain a
parseable longpublic static final java.lang.String toHexString(byte[] values)
values - byte array to be converted
public static final java.lang.String toHexString(long value)
value - long to be converted
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||