public class

ReflectionHelper

extends HashMap<K, V>
java.lang.Object
   ↳ java.util.AbstractMap<K, V>
     ↳ java.util.HashMap<K, V>
       ↳ com.microstrategy.utils.ReflectionHelper

Class Overview

A helper class that allows creating new object instances and getting/setting object's properties via reflection

Summary

Public Constructors
ReflectionHelper()
Public Methods
static Class classForName(String className)
Return a Class object for the class with the given name.
static Object get(Object ob, String name)
Gets the object's property value
static String getEnumerationValue(String enumValue)
Returns the value of the constant defined in the Java fully qualified class name and constant name received as a parameter.
static Method getSetterMethod(Class type, String name)
static Object invokeGetter(Object ob, String name)
static Object newInstance(String className, Class[] parameterTypes, Object[] initargs)
Creates a new instance for the class with the given name.
static Object newInstance(String className)
Creates a new instance for the class with the given name.
static void set(Object ob, String propName, Object value)
Gets the object's property value
[Expand]
Inherited Methods
From class java.util.HashMap
From class java.util.AbstractMap
From class java.lang.Object
From interface java.util.Map

Public Constructors

public ReflectionHelper ()

Public Methods

public static Class classForName (String className)

Return a Class object for the class with the given name.

Parameters
className A fully qualified class name
Throws
ClassNotFoundException If the class is not found in the class-path (this includes the extended class path that includes all customizations).

public static Object get (Object ob, String name)

Gets the object's property value

Parameters
ob object
name property name
Returns
  • property value;

public static String getEnumerationValue (String enumValue)

Returns the value of the constant defined in the Java fully qualified class name and constant name received as a parameter. The value is always returned as a String regardless of the original data type. If the class cannot be resolved or the data member does not exist, null is returned.

Parameters
enumValue FCN of the data member to resolved. i.e. com.microstrategy.web.beans.EnumReportBeanEvents.REPORT_EVENT_EXECUTE
Returns
  • String object containing the value of the FCN memmber provided. For the previous example, the return value is "4001"

public static Method getSetterMethod (Class type, String name)

public static Object invokeGetter (Object ob, String name)

public static Object newInstance (String className, Class[] parameterTypes, Object[] initargs)

Creates a new instance for the class with the given name. The class is created using a constructor that expects the given list of parameters.

Parameters
className A fully qualified class name
parameterTypes An array with the parameter types
initargs An array with the values that shall be passed to the contructor. Clearly each argument needs to match the types passed in parameterTypes.
Returns
  • Object An instance of the given class.
Throws
ClassNotFoundException If the class is not found in the class path
NoSuchMethodException

public static Object newInstance (String className)

Creates a new instance for the class with the given name. The corresponding class needs to have a public non arguments constructor in order to successfully use this method.

Parameters
className A fully qualified class name
Returns
  • Object An instance of the given class.
Throws
ClassNotFoundException If the class is not found in the class path

public static void set (Object ob, String propName, Object value)

Gets the object's property value

Parameters
ob object
propName property name
value new value