org.jicengine.operation
Class ReflectionUtils
java.lang.Object
org.jicengine.operation.ReflectionUtils
- Direct Known Subclasses:
- BeanUtils
- public class ReflectionUtils
- extends java.lang.Object
- Version:
- 1.0
- Author:
- .timo
Method Summary |
protected static java.lang.String |
formatParameters(java.lang.Object[] parameters)
|
protected static java.lang.Class |
getActorClass(java.lang.Object instanceOrClass)
|
static java.lang.Object |
getFieldValue(java.lang.Object instance,
java.lang.Class ownerClass,
java.lang.String fieldName)
|
protected static java.lang.Class[] |
getTypes(java.lang.Object[] parameters)
|
static java.lang.Object |
instantiate(java.lang.Class instantiatedClass,
java.lang.Object[] parameters)
|
static java.lang.Object |
invokeMethod(java.lang.Object actor,
java.lang.String methodName,
java.lang.Object[] parameters)
Invokes a method. |
static java.lang.Object |
invokeStaticMethod(java.lang.Class actorClass,
java.lang.String methodName,
java.lang.Object[] parameters)
|
protected static java.lang.Class |
primitiveTypeToWrapperType(java.lang.Class primitiveType)
|
protected static java.lang.Class |
primitiveWrapperToPrimitiveType(java.lang.Class objectClass)
|
static void |
setFieldValue(java.lang.Object instance,
java.lang.Class ownerClass,
java.lang.String fieldName,
java.lang.Object fieldValue)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ReflectionUtils
public ReflectionUtils()
setFieldValue
public static void setFieldValue(java.lang.Object instance,
java.lang.Class ownerClass,
java.lang.String fieldName,
java.lang.Object fieldValue)
throws java.lang.Exception
- Throws:
java.lang.Exception
getFieldValue
public static java.lang.Object getFieldValue(java.lang.Object instance,
java.lang.Class ownerClass,
java.lang.String fieldName)
throws java.lang.Exception
- Parameters:
instance
- the instance whose field is referenced. may be null, if
the field in question is a static field.ownerClass
- the class that 'owns' the field.fieldName
- the name of the field.
- Throws:
java.lang.Exception
getActorClass
protected static java.lang.Class getActorClass(java.lang.Object instanceOrClass)
invokeMethod
public static java.lang.Object invokeMethod(java.lang.Object actor,
java.lang.String methodName,
java.lang.Object[] parameters)
throws java.lang.NoSuchMethodException,
java.lang.IllegalAccessException,
java.lang.IllegalArgumentException,
java.lang.reflect.InvocationTargetException
- Invokes a method.
- Parameters:
methodName
- the name of the method, like
'addLayer' or 'setName'actor
- Description of the Parameterparameters
- Description of the Parameter
- Returns:
- an Object, if the invoked method
returned something. null if the methods return-type is void.
- Throws:
ReflectionUtils.NoSuchMethodException
- if no matching method was found
java.lang.IllegalAccessException
- see Method.invoke()
java.lang.IllegalArgumentException
- see Method.invoke()
java.lang.reflect.InvocationTargetException
- if the invoked method throwed an
Exception
java.lang.NoSuchMethodException
- Description of the Exception
invokeStaticMethod
public static java.lang.Object invokeStaticMethod(java.lang.Class actorClass,
java.lang.String methodName,
java.lang.Object[] parameters)
throws java.lang.NoSuchMethodException,
java.lang.IllegalAccessException,
java.lang.IllegalArgumentException,
java.lang.reflect.InvocationTargetException
- Throws:
java.lang.NoSuchMethodException
java.lang.IllegalAccessException
java.lang.IllegalArgumentException
java.lang.reflect.InvocationTargetException
instantiate
public static java.lang.Object instantiate(java.lang.Class instantiatedClass,
java.lang.Object[] parameters)
throws java.lang.NoSuchMethodException,
java.lang.InstantiationException,
java.lang.IllegalAccessException,
java.lang.reflect.InvocationTargetException
- Throws:
java.lang.NoSuchMethodException
java.lang.InstantiationException
java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
primitiveWrapperToPrimitiveType
protected static java.lang.Class primitiveWrapperToPrimitiveType(java.lang.Class objectClass)
- Parameters:
objectClass
- Description of the Parameter
- Returns:
- the Class representing a primitive, if the argument
Class is java.lang.Integer, java.lang.Double or any other primitive
wrapper. null if the argument class is not a wrapper.
primitiveTypeToWrapperType
protected static java.lang.Class primitiveTypeToWrapperType(java.lang.Class primitiveType)
- Parameters:
primitiveType
- Description of the Parameter
- Returns:
- null if the argument class is not a primitive type.
formatParameters
protected static java.lang.String formatParameters(java.lang.Object[] parameters)
getTypes
protected static java.lang.Class[] getTypes(java.lang.Object[] parameters)