|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.javalid.core.support.ReflectionSupport
public class ReflectionSupport
Supportive class for reflective and/or class related methods.
Changes for 1.1
| Method Summary | |
|---|---|
static java.lang.Object |
convertValueToType(java.lang.String value,
java.lang.String type)
Converts given value to given type, types supported are: - java.lang.String - java.lang.Byte - java.lang.Short - java.lang.Integer - java.lang.Float - java.lang.Double - java.lang.Long And for each listed one their primitive equivalent (byte, short, int etc.), except String. |
static java.lang.reflect.Field |
findField(java.lang.Class clazz,
java.lang.String fieldName)
|
static java.lang.reflect.Field |
findField(java.lang.Object instance,
java.lang.String fieldName)
Finds field (private fields included). |
static java.lang.reflect.Method |
findMethod(java.lang.Object instance,
java.lang.String methodName)
Finds given methodName on given instance, if found returns the method if not found raises a JvException. |
static java.lang.reflect.Method |
findMethod(java.lang.Object instance,
java.lang.String methodName,
java.lang.Class[] paramTypes)
Finds given methodName on given instance, if found returns the method if not found raises a JvException. |
static java.lang.Class[] |
getClassValues(JvParam[] params,
java.lang.Object[] valueParams,
JvConfigurationWrapper jvConfigWrapper)
Returns the classes for given parameter values (in the same order). |
static java.lang.String |
getPathForMethod(java.lang.reflect.Method method)
Create a path for given method. |
static java.lang.String |
getPrimitiveAsObjectString(java.lang.String type)
|
static java.lang.Class |
getPrimitiveClassType(java.lang.String type)
For given primitive type (byte,short,int,long,float,double) returns equivalent Class. |
static java.lang.Object |
getValueFromField(java.lang.Object object,
java.lang.reflect.Field field)
Retrieves the value from given field, first calls setAccessible(true) to allow access to private fields. |
static java.lang.Object |
getValueFromField(java.lang.Object object,
java.lang.reflect.Field field,
java.lang.String[] proxyRecognizers)
Retrieves the value from given field, first calls setAccessible(true) to allow access to private fields. |
static java.lang.Object[] |
getValuesForJvParams(java.lang.Object valueRequiringValidation,
java.lang.String currentValidationPath,
JvParam[] params,
JvConfigurationWrapper configWrapper)
Returns the values for given parameter. |
static java.lang.Object |
instantiate(java.lang.Class clazz)
Instantiates given class (must hava a public non-args constructor). |
static java.lang.Object |
instantiate(java.lang.Class clazz,
java.lang.Class[] params,
java.lang.Object[] values)
Instantiates given class. |
static java.lang.Object |
instantiate(java.lang.String className)
Convenience method, which tries to locate and create a class first and then calls instantiate(clazz). |
static java.lang.Object |
instantiate(java.lang.String className,
java.lang.Class[] params,
java.lang.Object[] values)
Uses given className and tries to locate it, then calls instantiate(..) method of this class. |
static java.lang.Object |
invokeMethod(java.lang.Object object,
java.lang.reflect.Method method,
java.lang.Object[] params)
Invokes given method using the object and parameters provided. |
static boolean |
isPrimitiveClassType(java.lang.String type)
Returns if given type is a primitive class type. |
static boolean |
isPrimitiveSupportedType(java.lang.String type)
Returns true if given type is supported by the framework (in core validation implementations or just in general). |
static boolean |
isValidFieldForValidation(java.lang.reflect.Field field)
Returns true if given field is non-static, basically we allow every field for validation except for static fields. |
static boolean |
isValidGetMethod(java.lang.reflect.Method method)
Returns true if given method conforms to the standard javabean standard for a get method. |
static java.lang.String |
propertyToGetMethod(java.lang.String propertyName)
Converts given property name to a valid get method name. |
static java.lang.Class |
removeProxyClass(java.lang.Class currentClass,
java.lang.String[] proxyRecognizers)
Checks given class if it contains a proxyRecognizer, if so goes to the super class and checks again, until none is found anymore. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static final java.lang.String propertyToGetMethod(java.lang.String propertyName)
propertyName - The name to make a get method name from
JavalidException - If propertyName is null or emptypublic static final boolean isValidGetMethod(java.lang.reflect.Method method)
method - The method to check
public static final boolean isValidFieldForValidation(java.lang.reflect.Field field)
field - The field to check
public static final java.lang.Object invokeMethod(java.lang.Object object,
java.lang.reflect.Method method,
java.lang.Object[] params)
object - The object to invoke the method on (or null if static method)method - The method to invokeparams - The parameters of the method (can be null if no parameters)
public static final java.lang.Object getValueFromField(java.lang.Object object,
java.lang.reflect.Field field)
object - The instance the field is fromfield - The field
public static final java.lang.Object getValueFromField(java.lang.Object object,
java.lang.reflect.Field field,
java.lang.String[] proxyRecognizers)
object - The instanace the field is fromfield - The fieldproxyRecognizers - Proxy recognizers, assures that the actual instance is looked up instead, can be null.
public static final java.lang.Object instantiate(java.lang.String className)
className - The className to create instance for
public static final java.lang.Object instantiate(java.lang.Class clazz)
clazz - The class to instantiate.
public static final java.lang.Object instantiate(java.lang.String className,
java.lang.Class[] params,
java.lang.Object[] values)
className - The name of a classparams - values -
instantiate(Class clazz, Class[] params, Object[] values)
public static final java.lang.Object instantiate(java.lang.Class clazz,
java.lang.Class[] params,
java.lang.Object[] values)
clazz - The clazz to useparams - The parameter types of the constructor to lookupvalues - The values to use when instantiating
JavalidException - for any error that occurs during creation
public static final java.lang.reflect.Method findMethod(java.lang.Object instance,
java.lang.String methodName)
instance - The instance to checkmethodName - The methodname to lookup
public static final java.lang.reflect.Method findMethod(java.lang.Object instance,
java.lang.String methodName,
java.lang.Class[] paramTypes)
instance - The instance to checkmethodName - The methodname to lookupparamTypes - The formal parameter types for this method
public static final java.lang.reflect.Field findField(java.lang.Object instance,
java.lang.String fieldName)
instance - InstancefieldName - Name of field
public static final java.lang.reflect.Field findField(java.lang.Class clazz,
java.lang.String fieldName)
public static final java.lang.String getPathForMethod(java.lang.reflect.Method method)
method - The method to create a path (used by validation message to store a path)
public static final java.lang.Object[] getValuesForJvParams(java.lang.Object valueRequiringValidation,
java.lang.String currentValidationPath,
JvParam[] params,
JvConfigurationWrapper configWrapper)
valueRequiringValidation - The actual value that requires validation, this is
used when one of the JvParam instances require to pass this as parameter.currentValidationPath - The current path of the validationparams - The parameters to initializeconfigWrapper - The configuration of the jv framework
public static final java.lang.Object convertValueToType(java.lang.String value,
java.lang.String type)
value - The value to convert, if null returns null. If empty and type is NOT java.lang.String it is set to null for the other types (problem with annotations that don't allow null values)type - One of the supported types
public static final boolean isPrimitiveSupportedType(java.lang.String type)
Currently supported are:
- java.lang.String
- java.lang.Byte
- java.lang.Short
- java.lang.Integer
- java.lang.Float
- java.lang.Double
- java.lang.Long
And for each listed one their primitive equivalent (byte, short, int etc.).
type - The type to check, if null false is returned.
public static final java.lang.Class[] getClassValues(JvParam[] params,
java.lang.Object[] valueParams,
JvConfigurationWrapper jvConfigWrapper)
params - The matching JvParams array with the actual valuesvalueParams - The value array to get classes fromjvConfigWrapper - Configuration, to check proxy of classes parameters (if required)
JavalidException - if classnotfoundexception occurspublic static final boolean isPrimitiveClassType(java.lang.String type)
type - The type to check
public static final java.lang.Class getPrimitiveClassType(java.lang.String type)
type - Primitive type
public static final java.lang.String getPrimitiveAsObjectString(java.lang.String type)
public static final java.lang.Class removeProxyClass(java.lang.Class currentClass,
java.lang.String[] proxyRecognizers)
currentClass - The class to checkproxyRecognizers - Array with proxyRecognizers
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||