public class OAReflect extends Object
Constructor and Description |
---|
OAReflect() |
Modifier and Type | Method and Description |
---|---|
static Object |
convertParameterFromString(Class clazz,
String value)
Convert a String value to a different value of Class clazz.
|
static Object |
convertParameterFromString(Class c,
String value,
String format)
Convert a String value to a different value of Class clazz.
|
static Object |
convertParameterFromString(Method method,
String value)
Convert String to required object needed as a parameter to Method.
|
static Object |
convertParameterFromString(Method method,
String value,
String format)
Convert String to required object needed as a parameter to Method.
|
static Object |
executeMethod(Object object,
Method[] method)
Run the following methods from a starting Object.
|
static Object |
executeMethod(Object object,
String path)
Run the following methods based on a property path from a starting Object.
|
static Class |
getClass(Method m)
If a "get" method, will find type of class to send method, else will find the type of return class.
|
static String[] |
getClasses(String packageName)
Get name of all classes in a package.
|
static String |
getClassPath(Class clazz)
Finds the class path used to be able to load a class.
|
static Class |
getClassWrapper(Class clazz) |
static Object |
getEmptyPrimitive(Class c) |
static Method |
getMethod(Class clazz,
String methodName) |
static Method |
getMethod(Class clazz,
String methodName,
Class classParam) |
static Method |
getMethod(Class clazz,
String methodName,
int paramCount)
Finds a Method in a class.
|
static Method |
getMethod(Class clazz,
String methodName,
int paramCount,
Object[] args)
20121028
|
static Method |
getMethod(Class clazz,
String methodName,
Object[] args) |
static Method[] |
getMethods(Class clazz,
String propertyPath)
Get the methods for a property path.
|
static Method[] |
getMethods(Class clazz,
String propertyPath,
boolean bThrowException) |
static Method[] |
getMethods(Class clazz,
String propertyPath,
Class substituteClass,
boolean bThrowException)
Get the methods for a property path.
|
static Class |
getPrimitiveClassWrapper(Class classPrimitive)
Returns Class used to wrap a primitive Class.
|
static Object |
getPrimitiveClassWrapperObject(Class clazz)
Returns an Object that is of a wrapper class for a primitive type.
|
static Object |
getPropertyValue(Object object,
Method method)
Uses reflection to get returned value of a method.
|
static Object |
getPropertyValue(Object object,
Method[] method)
This method will walk through the methods starting with the object supplied and then using the returned object.
|
static Object |
getPropertyValue(Object object,
Method[] method,
int amt) |
static String |
getPropertyValueAsString(Object object,
Method method)
Convert the returned object of a method call to a String value.
|
static String |
getPropertyValueAsString(Object object,
Method[] method)
Convert the returned object to a String value.
|
static String |
getPropertyValueAsString(Object object,
Method[] method,
String format)
Convert the returned object, from an array of method calls, to a String value.
|
static String |
getPropertyValueAsString(Object object,
Method method,
String format) |
static String |
getPropertyValueAsString(Object object,
Method method,
String format,
String nullValue) |
static boolean |
isEqualEvenIfWrapper(Class c1,
Class c2) |
static boolean |
isFloat(Class clazz)
Determines if a class is a Float.
|
static boolean |
isInteger(Class clazz)
Determines if a class is a Integer.
|
static boolean |
isNumber(Class clazz)
Determines if a class is a Number.
|
static boolean |
isPrimitiveClassWrapper(Class clazz) |
static void |
main(String[] args) |
static void |
setPropertyValue(Object object,
Method method,
Object newValue)
Invokes method for an Object using an object value.
|
static void |
setPropertyValue(Object object,
Method method,
String value)
Converts a String object to object type required by method and invokes method
|
static void |
setPropertyValue(Object object,
Method method,
String value,
String format)
Converts a String object to object type required by method and invokes method
|
public static Method getMethod(Class clazz, String methodName, int paramCount)
clazz
- is the Class to use to find method name.methodName
- is case insensitive name of method. public static Method getMethod(Class clazz, String methodName, int paramCount, Object[] args)
args
- list of arguments used in method callpublic static Method[] getMethods(Class clazz, String propertyPath)
clazz
- beginning Class object to start with.propertyPath
- is dot "." separated list (case insensitive). Note: if any of the propertyNames is a Hub, then it will use the Hub's activeObject when retrieving the property.
getPropertyValue(Object,Method)
,
getMethods(Class,String,boolean)
public static Method[] getMethods(Class clazz, String propertyPath, boolean bThrowException)
public static Method[] getMethods(Class clazz, String propertyPath, Class substituteClass, boolean bThrowException)
clazz
- beginning Class object to start with.propertyPath
- is dot "." separated list (case insensitive). Note: if any of the propertyNames is a Hub, then it will use the Hub's activeObject when retrieving the property.
bThrowException
- flag to know if an exception should be thrown if methods are not found.substituteClass
- class to use if a link property is of type OAObject.classthrows OAException if methods can not be found and bThrowException is true. also can use newer
OAPropertyPath, which has more info, including the methods
public static Object convertParameterFromString(Method method, String value)
method
- is Method that value will be sent to.value
- is String that needs to be converted so that it can be used with method.OAConverter
public static Object convertParameterFromString(Method method, String value, String format)
method
- is Method that value will be sent to.value
- is String that needs to be converted so that it can be used with method.format
- is text format used for String.OAConverter
public static Object convertParameterFromString(Class clazz, String value)
clazz
- Class to convert String value to.value
- is String to convert.OAConverter
public static Object convertParameterFromString(Class c, String value, String format)
value
- is String to convert.format
- is text format used for String.OAConverter
public static String getPropertyValueAsString(Object object, Method[] method)
object
- beginning object to use when calling methods.method
- array of methods to call. Will use object for the first method, then will follow using the returned object for each
method.getMethods(java.lang.Class, java.lang.String)
,
getPropertyValue(java.lang.Object, java.lang.reflect.Method[])
public static String getPropertyValueAsString(Object object, Method[] method, String format)
object
- beginning object to use when calling methods.method
- array of methods to call. Will use object for the first method, then will follow using the returned object for each
method.format
- text format to use for conversion to string value.getMethods(java.lang.Class, java.lang.String)
,
getPropertyValue(java.lang.Object, java.lang.reflect.Method[])
public static String getPropertyValueAsString(Object object, Method method)
object
- beginning object to use when calling methods.method
- array of methods to call. Will use object for the first method, then will follow using the returned object for each
method. param format text format to use for conversion to string value.getMethods(java.lang.Class, java.lang.String)
,
getPropertyValue(java.lang.Object, java.lang.reflect.Method[])
public static String getPropertyValueAsString(Object object, Method method, String format)
getPropertyValueAsString(Object,Method[])
public static String getPropertyValueAsString(Object object, Method method, String format, String nullValue)
getPropertyValueAsString(Object,Method[])
public static Object executeMethod(Object object, Method[] method)
public static Object executeMethod(Object object, String path)
public static Object getPropertyValue(Object object, Method[] method)
object
- beginning object to usemethod[]
- methods of property pathgetMethods(java.lang.Class, java.lang.String)
,
getPropertyValueAsString(java.lang.Object, java.lang.reflect.Method[])
public static Object getPropertyValue(Object object, Method method)
public static void setPropertyValue(Object object, Method method, String value)
value
- String value to use with methodconvertParameterFromString(java.lang.reflect.Method, java.lang.String)
public static void setPropertyValue(Object object, Method method, String value, String format)
value
- String value to use with methodformat
- is format used for value.convertParameterFromString(java.lang.reflect.Method, java.lang.String)
public static void setPropertyValue(Object object, Method method, Object newValue)
public static Class getClass(Method m)
public static boolean isNumber(Class clazz)
public static boolean isInteger(Class clazz)
public static boolean isFloat(Class clazz)
public static Class getPrimitiveClassWrapper(Class classPrimitive)
public static boolean isPrimitiveClassWrapper(Class clazz)
public static Object getPrimitiveClassWrapperObject(Class clazz)
public static String[] getClasses(String packageName) throws ClassNotFoundException, IOException
packageName
- ClassNotFoundException
IOException
public static String getClassPath(Class clazz)
Copyright © 1999–2025 ViaOA. All rights reserved.