|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object texsoft.java.object.XsObjectUtil
This class provides some usefull utility reflection related methods and provides internal utility methods for the texsoft.java.object package (with package visibility).
The class is declared abstract so only its static methods can be used.
Constructor Summary | |
XsObjectUtil()
|
Method Summary | |
static java.lang.String |
capitalize(java.lang.String prop)
Returns the String passed as argument capitalized. |
static java.lang.Object |
fromNull(java.lang.Class type)
If type is a primitive type returns an appropriate wrapper set to 0, '\0' or false depending on the type, otherwise simply return null . |
static java.lang.Object |
fromString(java.lang.Class type,
java.lang.String v)
Try a conversion from String to the class type. |
static java.lang.Class |
getClassForName(java.lang.String type)
Given a full qualified class name type, returns the corresponding Class object. |
static java.lang.String |
getNameForClass(java.lang.String fullname)
Given a full qualified class name returns the name only of the class, the package part is removed if present. |
static java.lang.String |
getPackageForClass(java.lang.String fullname)
Given a full qualified class name return the package part only, if the class name has not package part return an empty String. |
static java.lang.Class |
getWrapperFor(java.lang.Class type)
If type is a primitive type returns the appropriate wrapper Class for it otherwise returns type itself. |
static boolean |
isNumeric(java.lang.Class type)
Returns true if the passed Class is a numeric primitive Java type
or a wrapper class for a numeric primitive Java type. |
static boolean |
isNumericPrimitive(java.lang.Class type)
Returns true if the passed Class
is a numeric primitive Java type. |
static boolean |
isNumericWrapper(java.lang.Class type)
Returns true if the passed Class is a wrapper
for a numeric primitive Java type. |
static boolean |
isPrimitive(java.lang.Class type)
Returns true if the passed Class
is a primitive Java type. |
static boolean |
isPrimitiveWrapper(java.lang.Class type)
Returns true if the passed Class is a wrapper for a primitive Java type. |
static java.lang.Object |
toObject(boolean v)
Given a boolean returns a Boolean object initialized with
the passed argument. |
static java.lang.Object |
toObject(byte v)
Given a byte returns a Byte object initialized with
the passed argument. |
static java.lang.Object |
toObject(char v)
Given a char returns a Character object initialized with
the passed argument. |
static java.lang.Object |
toObject(double v)
Given a double returns a Double object initialized with
the passed argument. |
static java.lang.Object |
toObject(float v)
Given a float returns a Float object initialized with
the passed argument. |
static java.lang.Object |
toObject(int v)
Given a int returns a Integer object initialized with
the passed argument. |
static java.lang.Object |
toObject(long v)
Given a long returns a Long object initialized with
the passed argument. |
static java.lang.Object |
toObject(short v)
Given a short returns a Short object initialized with
the passed argument. |
static java.lang.String |
unCapitalize(java.lang.String prop)
Returns the String passed as argument uncapitalized. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public XsObjectUtil()
Method Detail |
public static java.lang.String capitalize(java.lang.String prop)
prop
- a string to be capitalized.
public static java.lang.String unCapitalize(java.lang.String prop)
prop
- a string to be uncapitalized.
public static boolean isPrimitive(java.lang.Class type)
true
if the passed Class
is a primitive Java type.
type
- object to be checked.
true
if the passed Class is a primitive Java type.public static boolean isNumericPrimitive(java.lang.Class type)
true
if the passed Class
is a numeric primitive Java type.
type
- object to be checked.
true
if the passed Class is a numeric primitive Java type.public static boolean isPrimitiveWrapper(java.lang.Class type)
true
if the passed Class is a wrapper for a primitive Java type.
type
- object to be checked.
true
is the passed Class is a wrapper of a primitive Java type.public static boolean isNumericWrapper(java.lang.Class type)
true
if the passed Class is a wrapper
for a numeric primitive Java type.
type
- Class to be checked
true
if the passed Class is a wrapper for a numeric primitive Java typepublic static boolean isNumeric(java.lang.Class type)
true
if the passed Class is a numeric primitive Java type
or a wrapper class for a numeric primitive Java type.
type
- Class object to be checked.
true
if the passed Class is a numeric primitive Java type
or a wrapper class for a numeric primitive Java type.public static java.lang.String getNameForClass(java.lang.String fullname)
fullname
- full qualified class name.
public static java.lang.String getPackageForClass(java.lang.String fullname)
fullname
- full qualified class name.
public static java.lang.Object fromString(java.lang.Class type, java.lang.String v)
If type is a primitive types return a corresponding wrapper. If type is a non primitive type try to create a new instance of it with a constructor that get a String parameter. It assumes that the given class has a constructor that accept a String argument from which the object itselft can be initialized.
Returns null
if it can't convert, in which case the caller must
handle the situation and throw and exception if appropriate.
NullPointerException and numeric conversion exceptions are not catched inside
and may be thrown and should be handled by the caller.
type
- class type to which the String parameter v has to be converted.v
- string value to be converted into object of class type.
null
if the string can't be
converted to type.public static java.lang.Object fromNull(java.lang.Class type)
null
.
type
- class for which a null rapresentation has to be returned.
public static java.lang.Class getWrapperFor(java.lang.Class type)
type
- class for which a wrapper class has to be returned.
public static java.lang.Class getClassForName(java.lang.String type) throws java.lang.ClassNotFoundException
type
- class name for which the Class object has to be returned, can be also a
primitive type as "int", "char", "void", etc.
java.lang.ClassNotFoundException
- throws if the given class name type does not match any loaded class.public static java.lang.Object toObject(byte v)
byte
returns a Byte
object initialized with
the passed argument.
v
- a byte value
public static java.lang.Object toObject(short v)
short
returns a Short
object initialized with
the passed argument.
v
- a short value
public static java.lang.Object toObject(int v)
int
returns a Integer
object initialized with
the passed argument.
v
- a int value
public static java.lang.Object toObject(long v)
long
returns a Long
object initialized with
the passed argument.
v
- a long value
public static java.lang.Object toObject(float v)
float
returns a Float
object initialized with
the passed argument.
v
- a float value
public static java.lang.Object toObject(double v)
double
returns a Double
object initialized with
the passed argument.
v
- a double value
public static java.lang.Object toObject(char v)
char
returns a Character
object initialized with
the passed argument.
v
- a char value
public static java.lang.Object toObject(boolean v)
boolean
returns a Boolean
object initialized with
the passed argument.
v
- a boolean value
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |