public class Introspection
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
static java.lang.reflect.Field |
getField(java.lang.Class<?> c,
java.lang.String name)
This is like
getField,
except that it can return non-public fields. |
static java.lang.String |
getFieldName(java.lang.Object val)
Returns the field name corresponding to the value of
an enumerated type val.
|
static java.lang.reflect.Field[] |
getFields(java.lang.Class<?> c)
Returns all the fields declared and inherited
by a class.
|
static java.lang.reflect.Method |
getMethod(java.lang.Class<?> c,
java.lang.String name,
java.lang.Class[] pt)
This is like
getMethod, except that it can return non-public methods. |
static java.lang.reflect.Method[] |
getMethods(java.lang.Class<?> c)
Returns all the methods declared and inherited
by a class.
|
static boolean |
sameSignature(java.lang.reflect.Method m1,
java.lang.reflect.Method m2)
Determines if two methods m1 and m2
share the same signature.
|
static <T> T |
valueOf(java.lang.Class<T> cls,
java.lang.String name)
Returns the field of class cls corresponding to
the name name.
|
static <T> T |
valueOfIgnoreCase(java.lang.Class<T> cls,
java.lang.String name)
Similar to
valueOf (cls, name),
with case insensitive field name look-up. |
public static java.lang.reflect.Method[] getMethods(java.lang.Class<?> c)
getMethods
except that it enumerates non-public methods as well as public ones.
This method uses getDeclaredMethods
to get the declared methods of c.
It also gets the declared methods of superclasses.
If a method is defined in a superclass and overriden
in a subclass, only the overriden method will be
in the returned array.
Note that since this method uses
getDeclaredMethods,
it can throw a SecurityException if
a security manager is present.
c - the class being processed.public static boolean sameSignature(java.lang.reflect.Method m1,
java.lang.reflect.Method m2)
m1 - the first method.m2 - the second method.public static java.lang.reflect.Field[] getFields(java.lang.Class<?> c)
getFields
except that it enumerates non-public fields as well as public ones.
This method uses getDeclaredFields
to get the declared fields of c.
It also gets the declared fields of superclasses and implemented
interfaces.
Note that since this method uses
getDeclaredFields,
it can throw a SecurityException if
a security manager is present.
c - the class being processed.public static java.lang.reflect.Method getMethod(java.lang.Class<?> c,
java.lang.String name,
java.lang.Class[] pt)
throws java.lang.NoSuchMethodException
getMethod, except that it can return non-public methods.c - the class being processed.name - the name of the method.pt - the parameter types.java.lang.NoSuchMethodException - if the method cannot be found.public static java.lang.reflect.Field getField(java.lang.Class<?> c,
java.lang.String name)
throws java.lang.NoSuchFieldException
getField,
except that it can return non-public fields.
Note that since this method uses
getDeclaredField,
it can throw a SecurityException if
a security manager is present.
c - the class being processed.name - the name of the method.java.lang.NoSuchFieldException - if the field cannot be found.public static java.lang.String getFieldName(java.lang.Object val)
val - the value of the enumerated type.public static <T> T valueOf(java.lang.Class<T> cls,
java.lang.String name)
IllegalArgumentException is thrown.cls - the class to look for a field in.name - the name of field.java.lang.IllegalArgumentException - if name does
not correspond to a valid field name.public static <T> T valueOfIgnoreCase(java.lang.Class<T> cls,
java.lang.String name)
valueOf (cls, name),
with case insensitive field name look-up.
If cls defines several fields with the same case insensitive
name name, an IllegalArgumentException is thrown.cls - the class to look for a field in.name - the name of field.java.lang.IllegalArgumentException - if name does
not correspond to a valid field name, or if
the class defines several fields with the same name.To submit a bug or ask questions, send an e-mail to Pierre L'Ecuyer.