Package com.microstrategy.utils
Class ReflectionHelper
- java.lang.Object
- 
- java.util.AbstractMap<K,V>
- 
- java.util.HashMap
- 
- com.microstrategy.utils.ReflectionHelper
 
 
 
- 
- All Implemented Interfaces:
- java.io.Serializable,- java.lang.Cloneable,- java.util.Map
 
 public class ReflectionHelper extends java.util.HashMapA helper class that allows creating new object instances and getting/setting object's properties via reflection- Since:
- MicroStrategy Web 8.0.1
- See Also:
- Serialized Form
 
- 
- 
Constructor SummaryConstructors Constructor Description ReflectionHelper()
 - 
Method SummaryAll Methods Static Methods Concrete Methods Modifier and Type Method Description static voidaddAllowedClassName(java.lang.String fqcn)Add a fully qualified class name into the allowed class name set, so that it could be used through Java Reflectionstatic voidaddAllowedClassNames(java.util.Collection<java.lang.String> collection)static java.lang.ClassclassForName(java.lang.String className)Return a Class object for the class with the given name.protected static java.lang.ClassclassForName(java.lang.String className, boolean skipValidation)static java.lang.Objectget(java.lang.Object ob, java.lang.String name)Gets the object's property valuestatic java.lang.StringgetEnumerationValue(java.lang.String enumValue)Returns the value of the constant defined in the Java fully qualified class name and constant name received as a parameter.static java.lang.reflect.MethodgetSetterMethod(java.lang.Class type, java.lang.String name)static java.lang.ObjectinvokeGetter(java.lang.Object ob, java.lang.String name)static java.lang.ObjectnewInstance(java.lang.String className)Creates a new instance for the class with the given name.protected static java.lang.ObjectnewInstance(java.lang.String className, boolean skipValidation)static java.lang.ObjectnewInstance(java.lang.String className, java.lang.Class[] parameterTypes, java.lang.Object[] initargs)Creates a new instance for the class with the given name.protected static java.lang.ObjectnewInstance(java.lang.String className, java.lang.Class[] parameterTypes, java.lang.Object[] initargs, boolean skipValidation)static voidset(java.lang.Object ob, java.lang.String propName, java.lang.Object value)Gets the object's property value- 
Methods inherited from class java.util.HashMapclear, clone, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, forEach, get, getOrDefault, isEmpty, keySet, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
 
- 
 
- 
- 
- 
Method Detail- 
addAllowedClassNamepublic static void addAllowedClassName(java.lang.String fqcn) Add a fully qualified class name into the allowed class name set, so that it could be used through Java Reflection- Parameters:
- fqcn- The fully qualified class name
 
 - 
addAllowedClassNamespublic static void addAllowedClassNames(java.util.Collection<java.lang.String> collection) 
 - 
newInstancepublic static java.lang.Object newInstance(java.lang.String className) throws java.lang.ClassNotFoundExceptionCreates 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:
- java.lang.ClassNotFoundException- If the class is not found in the class path
- Since:
- MicroStrategy Web 9.0.0
 
 - 
newInstanceprotected static java.lang.Object newInstance(java.lang.String className, boolean skipValidation) throws java.lang.ClassNotFoundException- Throws:
- java.lang.ClassNotFoundException
 
 - 
newInstancepublic static java.lang.Object newInstance(java.lang.String className, java.lang.Class[] parameterTypes, java.lang.Object[] initargs) throws java.lang.ClassNotFoundException, java.lang.NoSuchMethodExceptionCreates 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:
- java.lang.ClassNotFoundException- If the class is not found in the class path
- java.lang.NoSuchMethodException
- Since:
- MicroStrategy Web 9.0.0
- See Also:
- Class.getConstructor(java.lang.Class<?>...)
 
 - 
newInstanceprotected static java.lang.Object newInstance(java.lang.String className, java.lang.Class[] parameterTypes, java.lang.Object[] initargs, boolean skipValidation) throws java.lang.ClassNotFoundException, java.lang.NoSuchMethodException- Throws:
- java.lang.ClassNotFoundException
- java.lang.NoSuchMethodException
 
 - 
classForNamepublic static java.lang.Class classForName(java.lang.String className) throws java.lang.ClassNotFoundExceptionReturn a Class object for the class with the given name.- Parameters:
- className- A fully qualified class name
- Throws:
- java.lang.ClassNotFoundException- If the class is not found in the class-path (this includes the extended class path that includes all customizations).
- Since:
- MicroStrategy Web 9.0.0
- See Also:
- Class.forName(java.lang.String),- Customizations.getClassLoader()
 
 - 
classForNameprotected static java.lang.Class classForName(java.lang.String className, boolean skipValidation) throws java.lang.ClassNotFoundException- Throws:
- java.lang.ClassNotFoundException
 
 - 
getpublic static java.lang.Object get(java.lang.Object ob, java.lang.String name)Gets the object's property value- Parameters:
- ob- object
- name- property name
- Returns:
- property value;
 
 - 
setpublic static void set(java.lang.Object ob, java.lang.String propName, java.lang.Object value)Gets the object's property value- Parameters:
- ob- object
- propName- property name
- value- new value
 
 - 
invokeGetterpublic static java.lang.Object invokeGetter(java.lang.Object ob, java.lang.String name)
 - 
getEnumerationValuepublic static java.lang.String getEnumerationValue(java.lang.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"
- Since:
- MicroStrategy Web 9.0.0
 
 - 
getSetterMethodpublic static java.lang.reflect.Method getSetterMethod(java.lang.Class type, java.lang.String name)- Since:
- MicroStrategy Web 8.1.0
 
 
- 
 
-