|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.openjpa.enhance.Reflection
public class Reflection
Reflection utilities used to support and augment enhancement. Used both at enhancement time and at runtime.
Constructor Summary | |
---|---|
Reflection()
|
Method Summary | ||
---|---|---|
(package private) static boolean |
canReflect(Field field)
Affirms if the original declaration the given field is annotated for reflection. |
|
(package private) static boolean |
canReflect(Method method)
Affirms if the original declaration the given method is annotated for reflection. |
|
(package private) static boolean |
canReflect(Reflectable cls,
Reflectable member)
Affirms if the given member is selected for reflection. |
|
static Field |
findField(Class cls,
String name,
boolean mustExist)
Return the field with the given name, optionally throwing an exception if none. |
|
static Method |
findGetter(Class cls,
String prop,
boolean mustExist)
Return the getter method matching the given property name, optionally throwing an exception if none. |
|
static Method |
findSetter(Class cls,
String prop,
boolean mustExist)
Return the setter method matching the given property name, optionally throwing an exception if none. |
|
static Method |
findSetter(Class cls,
String prop,
Class param,
boolean mustExist)
Return the setter method matching the given property name, optionally throwing an exception if none. |
|
static Object |
get(Object target,
Field field)
Return the value of the given field in the given object. |
|
static Object |
get(Object target,
Method getter)
Return the return value of the given getter in the given object. |
|
static Set<String> |
getBeanStylePropertyNames(Class<?> c)
Gets all bean-style property names of the given Class or its superclass. |
|
static boolean |
getBoolean(Object target,
Field field)
Return the value of the given field in the given object. |
|
static boolean |
getBoolean(Object target,
Method getter)
Return the return value of the given getter in the given object. |
|
static byte |
getByte(Object target,
Field field)
Return the value of the given field in the given object. |
|
static byte |
getByte(Object target,
Method getter)
Return the return value of the given getter in the given object. |
|
static char |
getChar(Object target,
Field field)
Return the value of the given field in the given object. |
|
static char |
getChar(Object target,
Method getter)
Return the return value of the given getter in the given object. |
|
(package private) static Method |
getDeclaredMethod(Class cls,
String name,
Class param)
Invokes cls.getDeclaredMethods() , and returns the method
that matches the name and param arguments. |
|
static Class |
getDeclaringClass(Method m)
Gets the declaring class of the given method signature but also checks if the method is declared in an interface. |
|
static Method |
getDeclaringMethod(Class c,
Method m)
Gets the method in the given class that has the same signature of the given method, if exists. |
|
static double |
getDouble(Object target,
Field field)
Return the value of the given field in the given object. |
|
static double |
getDouble(Object target,
Method getter)
Return the return value of the given getter in the given object. |
|
static
|
getFieldValues(Class c,
int mods,
Class<T> t)
Gets values of all field f the given class such that f exactly match the given modifiers and are of given type (Object implies any type) unless f is annotated as Reflectable . |
|
static float |
getFloat(Object target,
Field field)
Return the value of the given field in the given object. |
|
static float |
getFloat(Object target,
Method getter)
Return the return value of the given getter in the given object. |
|
static int |
getInt(Object target,
Field field)
Return the value of the given field in the given object. |
|
static int |
getInt(Object target,
Method getter)
Return the return value of the given getter in the given object. |
|
static long |
getLong(Object target,
Field field)
Return the value of the given field in the given object. |
|
static long |
getLong(Object target,
Method getter)
Return the return value of the given getter in the given object. |
|
static Set<String> |
getPublicFieldNames(Class c)
Gets all public field names of the given Class. |
|
static short |
getShort(Object target,
Field field)
Return the value of the given field in the given object. |
|
static short |
getShort(Object target,
Method getter)
Return the return value of the given getter in the given object. |
|
static Object |
getValue(Object obj,
String prop,
boolean mustExist)
Get the value of the given named field or a corresponding getter method. |
|
(package private) static Method |
mostDerived(Method meth1,
Method meth2)
|
|
static void |
set(Object target,
boolean value,
Field field)
Set the value of the given field in the given object. |
|
static void |
set(Object target,
byte value,
Field field)
Set the value of the given field in the given object. |
|
static void |
set(Object target,
char value,
Field field)
Set the value of the given field in the given object. |
|
static void |
set(Object target,
double value,
Field field)
Set the value of the given field in the given object. |
|
static void |
set(Object target,
Field field,
boolean value)
Set the value of the given field in the given object. |
|
static void |
set(Object target,
Field field,
byte value)
Set the value of the given field in the given object. |
|
static void |
set(Object target,
Field field,
char value)
Set the value of the given field in the given object. |
|
static void |
set(Object target,
Field field,
double value)
Set the value of the given field in the given object. |
|
static void |
set(Object target,
Field field,
float value)
Set the value of the given field in the given object. |
|
static void |
set(Object target,
Field field,
int value)
Set the value of the given field in the given object. |
|
static void |
set(Object target,
Field field,
long value)
Set the value of the given field in the given object. |
|
static void |
set(Object target,
Field field,
Object value)
Set the value of the given field in the given object. |
|
static void |
set(Object target,
Field field,
short value)
Set the value of the given field in the given object. |
|
static void |
set(Object target,
float value,
Field field)
Set the value of the given field in the given object. |
|
static void |
set(Object target,
int value,
Field field)
Set the value of the given field in the given object. |
|
static void |
set(Object target,
long value,
Field field)
Set the value of the given field in the given object. |
|
static void |
set(Object target,
Method setter,
boolean value)
Invoke the given setter on the given object. |
|
static void |
set(Object target,
Method setter,
byte value)
Invoke the given setter on the given object. |
|
static void |
set(Object target,
Method setter,
char value)
Invoke the given setter on the given object. |
|
static void |
set(Object target,
Method setter,
double value)
Invoke the given setter on the given object. |
|
static void |
set(Object target,
Method setter,
float value)
Invoke the given setter on the given object. |
|
static void |
set(Object target,
Method setter,
int value)
Invoke the given setter on the given object. |
|
static void |
set(Object target,
Method setter,
long value)
Invoke the given setter on the given object. |
|
static void |
set(Object target,
Method setter,
Object value)
Invoke the given setter on the given object. |
|
static void |
set(Object target,
Method setter,
short value)
Invoke the given setter on the given object. |
|
static void |
set(Object target,
Object value,
Field field)
Set the value of the given field in the given object. |
|
static void |
set(Object target,
short value,
Field field)
Set the value of the given field in the given object. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Reflection()
Method Detail |
---|
public static Method findGetter(Class cls, String prop, boolean mustExist)
public static Method findSetter(Class cls, String prop, boolean mustExist)
public static Method findSetter(Class cls, String prop, Class param, boolean mustExist)
static Method getDeclaredMethod(Class cls, String name, Class param)
cls.getDeclaredMethods()
, and returns the method
that matches the name
and param
arguments.
Avoids the exception thrown by Class.getDeclaredMethod()
for performance reasons. param
may be null. Additionally,
if there are multiple methods with different return types, this will
return the method defined in the least-derived class.
static Method mostDerived(Method meth1, Method meth2)
public static Field findField(Class cls, String name, boolean mustExist)
public static Object get(Object target, Field field)
public static Object getValue(Object obj, String prop, boolean mustExist)
UserException
- if mustExist is true and the field or getter
method is non-existentpublic static boolean getBoolean(Object target, Field field)
public static byte getByte(Object target, Field field)
public static char getChar(Object target, Field field)
public static double getDouble(Object target, Field field)
public static float getFloat(Object target, Field field)
public static int getInt(Object target, Field field)
public static long getLong(Object target, Field field)
public static short getShort(Object target, Field field)
public static Object get(Object target, Method getter)
public static boolean getBoolean(Object target, Method getter)
public static byte getByte(Object target, Method getter)
public static char getChar(Object target, Method getter)
public static double getDouble(Object target, Method getter)
public static float getFloat(Object target, Method getter)
public static int getInt(Object target, Method getter)
public static long getLong(Object target, Method getter)
public static short getShort(Object target, Method getter)
public static void set(Object target, Field field, Object value)
public static void set(Object target, Field field, boolean value)
public static void set(Object target, Field field, byte value)
public static void set(Object target, Field field, char value)
public static void set(Object target, Field field, double value)
public static void set(Object target, Field field, float value)
public static void set(Object target, Field field, int value)
public static void set(Object target, Field field, long value)
public static void set(Object target, Field field, short value)
public static void set(Object target, Object value, Field field)
public static void set(Object target, boolean value, Field field)
public static void set(Object target, byte value, Field field)
public static void set(Object target, char value, Field field)
public static void set(Object target, double value, Field field)
public static void set(Object target, float value, Field field)
public static void set(Object target, int value, Field field)
public static void set(Object target, long value, Field field)
public static void set(Object target, short value, Field field)
public static void set(Object target, Method setter, Object value)
public static void set(Object target, Method setter, boolean value)
public static void set(Object target, Method setter, byte value)
public static void set(Object target, Method setter, char value)
public static void set(Object target, Method setter, double value)
public static void set(Object target, Method setter, float value)
public static void set(Object target, Method setter, int value)
public static void set(Object target, Method setter, long value)
public static void set(Object target, Method setter, short value)
public static Set<String> getBeanStylePropertyNames(Class<?> c)
Reflectable
, then
it is ignored.
public static Set<String> getPublicFieldNames(Class c)
public static <T> Set<T> getFieldValues(Class c, int mods, Class<T> t)
Reflectable
.
static boolean canReflect(Reflectable cls, Reflectable member)
static boolean canReflect(Field field)
static boolean canReflect(Method method)
public static Class getDeclaringClass(Method m)
public static Method getDeclaringMethod(Class c, Method m)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |