|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.softwareag.centrasite.appl.framework.util.Reflection
public final class Reflection
A utility class for working with reflection.
Method Summary | ||
---|---|---|
static void |
addOrRemoveProperty(java.lang.Object pBean,
java.lang.reflect.Method pMethod,
java.lang.Object pValue)
Method for adding or removing a property of a bean. |
|
static
|
cast(java.lang.Class<?> pClass)
Casts the given class into a matching class. |
|
static java.lang.Object |
evaluate(java.lang.String pProperty,
java.lang.Object pObject)
This method evaluates a property of a given object. |
|
static java.lang.reflect.Method |
getAdder(java.lang.Object pBean,
java.lang.String pProperty)
Returns the add method for a given property and bean. |
|
static
|
getAnnotatedMethods(java.lang.Class<?> pClass,
java.lang.Class<T> annotationType)
Retrieves methods with given annotation type by traversing over the given class and all the its interfaces. |
|
static java.lang.reflect.Field |
getField(java.lang.Class<?> pClass,
java.lang.String pFieldName)
Searches for a field named pFieldName in the given class, or its
superclass. |
|
static java.lang.reflect.Method |
getGetter(java.lang.Object pBean,
java.lang.String pProperty)
Returns a getter for the given property. |
|
static java.lang.reflect.Method |
getGetter(java.lang.String pProperty,
java.lang.Class<?> cl)
Returns a getter for the given property. |
|
static java.util.List<java.lang.reflect.Method> |
getGetters(java.lang.Class<?> beanType)
Returns the getter methods for the given bean type. |
|
static java.util.List<java.lang.reflect.Method> |
getGetters(java.lang.Object pBean)
Returns the given objects getters. |
|
static java.lang.Object |
getProperty(java.lang.Object pBean,
java.lang.reflect.Method pMethod)
Method for getting a property of a bean. |
|
static java.lang.Object |
getProperty(java.lang.Object pBean,
java.lang.String propertyName)
Method for getting a property of a bean. |
|
static java.lang.String |
getPropertyName(java.lang.reflect.Method pMethod)
Returns the property name represented by the given method. |
|
static java.lang.reflect.Method |
getRemover(java.lang.Object pBean,
java.lang.String pProperty)
Returns the remove method for a given property and bean. |
|
static java.lang.reflect.Method |
getSetter(java.lang.reflect.Method pGetter,
java.lang.Class<?> pClass)
Returns a setter for the given getter property. |
|
static java.lang.reflect.Method |
getSetter(java.lang.Object pBean,
java.lang.reflect.Method pGetter)
Returns a setter for the given getter property. |
|
static java.lang.reflect.Method |
getSetter(java.lang.Object pBean,
java.lang.String pProperty)
Returns the setter method for a give property and bean. |
|
static java.util.List<java.lang.reflect.Method> |
getSetters(java.lang.Object pBean)
Returns the given objects setters. |
|
static boolean |
isGetter(java.lang.reflect.Method method)
Determines if the given method is a getter method based on its name. |
|
static boolean |
isSetter(java.lang.reflect.Method method)
Determines if the given method is a setter method based on its name. |
|
static
|
loadClass(java.lang.ClassLoader pClassLoader,
java.lang.String pClassName)
Loads the class named pClassName via the given pClassLoader . |
|
static
|
newInstance(java.lang.Class<T> pClass)
Creates a new instance of the given class. |
|
static java.lang.Object |
newInstance(java.lang.reflect.Constructor<?> pConstructor,
java.lang.Object... pParameters)
Creates a new instance of the given class. |
|
static void |
setFieldValue(java.lang.Class<?> pClass,
java.lang.String pFieldName,
java.lang.Object pInstance,
java.lang.Object pValue)
Searches for a field named pFieldName in the given class, or its
superclass, and sets the fields value. |
|
static void |
setFieldValue(java.lang.reflect.Field pField,
java.lang.Object pInstance,
java.lang.Object pValue)
Sets the given fields value on the given instance. |
|
static void |
setProperty(java.lang.Object pBean,
java.lang.reflect.Method pSetter,
java.lang.Object pValue)
Method for setting a bean property. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static java.lang.reflect.Method getGetter(java.lang.Object pBean, java.lang.String pProperty) throws CSAppFrameworkException
CSAppFrameworkException
public static java.lang.reflect.Method getGetter(java.lang.String pProperty, java.lang.Class<?> cl) throws CSAppFrameworkException
CSAppFrameworkException
public static java.lang.reflect.Method getSetter(java.lang.Object pBean, java.lang.String pProperty)
pBean
- pProperty
-
Method
CSAppFrameworkException
public static java.lang.reflect.Method getSetter(java.lang.Object pBean, java.lang.reflect.Method pGetter) throws CSAppFrameworkException
CSAppFrameworkException
public static java.lang.reflect.Method getSetter(java.lang.reflect.Method pGetter, java.lang.Class<?> pClass) throws CSAppFrameworkException
CSAppFrameworkException
public static java.lang.String getPropertyName(java.lang.reflect.Method pMethod) throws CSAppFrameworkException
CSAppFrameworkException
public static java.util.List<java.lang.reflect.Method> getGetters(java.lang.Class<?> beanType)
public static java.util.List<java.lang.reflect.Method> getGetters(java.lang.Object pBean)
public static java.util.List<java.lang.reflect.Method> getSetters(java.lang.Object pBean)
public static java.lang.Object getProperty(java.lang.Object pBean, java.lang.reflect.Method pMethod)
public static java.lang.Object getProperty(java.lang.Object pBean, java.lang.String propertyName) throws CSAppFrameworkException
CSAppFrameworkException
public static void setProperty(java.lang.Object pBean, java.lang.reflect.Method pSetter, java.lang.Object pValue)
pBean
- The bean, on which the property is being set.pSetter
- The setter to invoke for setting the property.pValue
- The property value to set.public static <T> T newInstance(java.lang.Class<T> pClass) throws java.lang.RuntimeException
java.lang.RuntimeException
public static java.lang.Object newInstance(java.lang.reflect.Constructor<?> pConstructor, java.lang.Object... pParameters) throws java.lang.RuntimeException
java.lang.RuntimeException
public static java.lang.reflect.Field getField(java.lang.Class<?> pClass, java.lang.String pFieldName) throws java.lang.RuntimeException
pFieldName
in the given class, or its
superclass.
java.lang.RuntimeException
public static void setFieldValue(java.lang.reflect.Field pField, java.lang.Object pInstance, java.lang.Object pValue) throws java.lang.RuntimeException
java.lang.RuntimeException
public static void setFieldValue(java.lang.Class<?> pClass, java.lang.String pFieldName, java.lang.Object pInstance, java.lang.Object pValue) throws java.lang.RuntimeException
pFieldName
in the given class, or its
superclass, and sets the fields value.
java.lang.RuntimeException
public static <T> java.lang.Class<T> loadClass(java.lang.ClassLoader pClassLoader, java.lang.String pClassName) throws CSAppFrameworkException
pClassName
via the given pClassLoader
. The class cannot be a primitive class.
pClassLoader
- The class loader to use.pClassName
- The class name.
CSAppFrameworkException
public static <C> java.lang.Class<C> cast(java.lang.Class<?> pClass)
public static <T extends java.lang.annotation.Annotation> java.util.Collection<java.lang.reflect.Method> getAnnotatedMethods(java.lang.Class<?> pClass, java.lang.Class<T> annotationType)
public static java.lang.Object evaluate(java.lang.String pProperty, java.lang.Object pObject) throws CSAppFrameworkException
pProperty
- The property to evaluate. This may be a combined property in
the style "a.b[1].c", in which case it is evaluated as
getA().getB()[1].getC()
.pObject
- The object, on which the property is being evaluated.
CSAppFrameworkException
public static boolean isSetter(java.lang.reflect.Method method)
method
- public static boolean isGetter(java.lang.reflect.Method method)
method
- public static java.lang.reflect.Method getAdder(java.lang.Object pBean, java.lang.String pProperty) throws CSAppFrameworkException
pBean
- pProperty
-
Method
CSAppFrameworkException
public static java.lang.reflect.Method getRemover(java.lang.Object pBean, java.lang.String pProperty) throws CSAppFrameworkException
pBean
- pProperty
-
Method
CSAppFrameworkException
public static void addOrRemoveProperty(java.lang.Object pBean, java.lang.reflect.Method pMethod, java.lang.Object pValue)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |