|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.sadun.util.TypeWrapper
An helper class to automatically wrap primitive types into their corresponding object types.
Constructor Summary | |
TypeWrapper()
|
Method Summary | |
static java.lang.Object |
convertValue(java.lang.Object value,
java.lang.Class targetType)
Convert the given value to the given target type, or throws a IllegalArgumentException if no conversion is possible |
static java.lang.Class |
getUnwrappedPrimitiveType(java.lang.Class wrapperCls)
Return the primitive type class for a wrapper type. |
static java.lang.Class |
getWrapperClass(java.lang.Class primitiveCls)
Return the class of the wrapper object for the given primitive type. |
static boolean |
isConvertible(java.lang.Class srcType,
java.lang.Class destType)
Verifies if a source type can be legally promoted to a destination type. |
static boolean |
isPrimitiveOrWrapper(java.lang.Class cls)
|
static boolean |
isPrimitiveWrapper(java.lang.Class cls)
|
static void |
main(java.lang.String[] args)
|
static java.lang.Object |
wrap(boolean v)
|
static java.lang.Object |
wrap(byte v)
|
static java.lang.Object |
wrap(char v)
|
static java.lang.Object |
wrap(double v)
|
static java.lang.Object |
wrap(float v)
|
static java.lang.Object |
wrap(int v)
|
static java.lang.Object |
wrap(long v)
|
static java.lang.Object |
wrap(java.lang.Object obj)
|
static java.lang.Object |
wrap(short v)
|
static java.lang.Object |
wrapFromString(java.lang.Class primitiveCls,
java.lang.String value)
Return a wrapper object corresponding to passed value, interpreted according to the given primitive (or primtitive wrapper) class . |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public TypeWrapper()
Method Detail |
public static java.lang.Object wrap(byte v)
public static java.lang.Object wrap(short v)
public static java.lang.Object wrap(int v)
public static java.lang.Object wrap(long v)
public static java.lang.Object wrap(float v)
public static java.lang.Object wrap(double v)
public static java.lang.Object wrap(char v)
public static java.lang.Object wrap(boolean v)
public static java.lang.Object wrap(java.lang.Object obj)
public static java.lang.Class getWrapperClass(java.lang.Class primitiveCls)
primitiveCls
- the Class of the primitive type
public static java.lang.Object wrapFromString(java.lang.Class primitiveCls, java.lang.String value)
primitiveCls
- the Class of the primitive (or wrapper) typevalue
- the value to intepretpublic static java.lang.Class getUnwrappedPrimitiveType(java.lang.Class wrapperCls)
wrapperCls
-
public static boolean isPrimitiveWrapper(java.lang.Class cls)
public static boolean isPrimitiveOrWrapper(java.lang.Class cls)
public static void main(java.lang.String[] args)
public static boolean isConvertible(java.lang.Class srcType, java.lang.Class destType)
public static java.lang.Object convertValue(java.lang.Object value, java.lang.Class targetType)
value
- the value to converttargetType
- the type to convert to
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |