|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.senn.magic.util.ReflectionUtils
public final class ReflectionUtils
Useful class for Reflection actions.
Constructor Summary | |
---|---|
ReflectionUtils()
|
Method Summary | |
---|---|
static Class |
getPrimitiveClass(Class wrapper)
Returns a primitive class for the provided wrapper. |
static Object |
invoke(Class clazz,
String method,
Object... args)
Invoke a method of a class by providing the class, method and an array of arguments. |
static Object |
invoke(Object instance,
String method,
Object... args)
Invoke a method of a class by providing the object, method and an array of arguments. |
static Object |
invokeUnaccessible(Class clazz,
String method,
Object... args)
Invoke a method ,that normally is not visible for the calling class, of a class by providing the class, method and an array of arguments. |
static Object |
invokeUnaccessible(Object instance,
String method,
Object... args)
Invoke a method ,that normally is not visible for the calling class, of a class by providing the object, method and an array of arguments. |
static boolean |
isPrimitive(Class clazz)
Checks whether a Class is a primitive datatype. |
static boolean |
isPrimitiveWrapper(Class clazz)
Checks whether a Class is a Wrapper-class of a primitive datatype. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ReflectionUtils()
Method Detail |
---|
public static Object invokeUnaccessible(Class clazz, String method, Object... args) throws Exception
Objects
, primitives were wrapped by Java
into their Wrapper-class.
clazz
- the class that contains the method and will be instantiatedmethod
- the name of the method (case sensitive!).
The method must be marked public!
args
- the arguments of the method an array of object
Object
- the return value as an object.
null
is returned when the method has no return value.
Exception
public static Object invokeUnaccessible(Object instance, String method, Object... args) throws Exception
Objects
, primitives were wrapped by Java
into their Wrapper-class.
instance
- the object that contains the method, leave null
for static methodsmethod
- the name of the method (case sensitive!).
The method must be marked public!
args
- the arguments of the method an array of object
Object
- the return value as an object.
null
is returned when the method has no return value.
Exception
public static Object invoke(Class clazz, String method, Object... args) throws Exception
Objects
, primitives were wrapped by Java
into their Wrapper-class.
clazz
- the class that contains the method and will be instantiatedmethod
- the name of the method (case sensitive!).
The method must be marked public!
args
- the arguments of the method an array of object
Object
- the return value as an object.
null
is returned when the method has no return value.
Exception
public static Object invoke(Object instance, String method, Object... args) throws Exception
Objects
, primitives were wrapped by Java
into their Wrapper-class.
instance
- the object that contains the method, leave null
for static methodsmethod
- the name of the method (case sensitive!).
The method must be marked public!
args
- the arguments of the method an array of object
Object
- the return value as an object.
null
is returned when the method has no return value.
Exception
public static Class getPrimitiveClass(Class wrapper)
Boolean
=> boolean
Byte
=> byte
Character
=> char
Double
=> double
Float
=> float
Integer
=> int
Long
=> long
Short
=> short
wrapper
- the Wrapper class
Class
- the matching primitive class, or null
if the class is not a Wrapper at allpublic static boolean isPrimitiveWrapper(Class clazz)
clazz
- the class to check
boolean
- true
if it's a wrapper, false
if it's notpublic static boolean isPrimitive(Class clazz)
clazz
- the class to check
boolean
- true
if it's a primitive, false
if it's not
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |