|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectclassUtils.reflection.ReflectUtil
public class ReflectUtil
ReflectUtil shows several examples of using reflection.
Constructor Summary | |
---|---|
ReflectUtil(java.lang.Object _o)
Instance the ReflectUtil with an Object. |
Method Summary | |
---|---|
static void |
addImmediateInterfaces(java.lang.Class c,
java.util.Vector v)
|
static java.lang.Class[] |
getAllInterfaces(java.lang.Class c)
|
java.lang.reflect.Method[] |
getAllMethods()
Obtain a list of all the methods. |
static java.lang.reflect.Method[] |
getAllMethods(java.lang.Object o)
|
java.lang.reflect.Method[] |
getAllMethodsNotInObjectClass(java.lang.reflect.Method[] m)
|
java.lang.reflect.Method[] |
getAllPublicMethods()
|
java.lang.reflect.Method[] |
getAllPublicStaticMethods()
|
static java.lang.String |
getBeanDescriptorString(java.beans.BeanInfo bi)
|
java.lang.String |
getBeanInfo()
|
java.lang.Class |
getC()
Get the containing class class instance. |
java.lang.Class[] |
getClasses()
getClasses is not implemented in the cutils.reflection API, yet. |
java.lang.String |
getClassName()
Get the name of the containing class. |
static javax.swing.JComponent |
getComponent(java.lang.Object ip,
java.lang.reflect.Method writeMethod)
|
java.lang.reflect.Constructor[] |
getConstructors()
Get a list of all the constructors in the containing class. |
static java.lang.String |
getDisplayName(java.lang.reflect.Method m)
|
static double |
getDouble(java.lang.Object obj)
|
static java.lang.Double |
getDoubleWrapper(java.lang.Object obj)
|
static java.beans.EventSetDescriptor[] |
getEventSetDescriptors(java.lang.Object o)
|
java.lang.reflect.Field[] |
getFields()
Get all but the inherited fields. |
static java.beans.PropertyDescriptor[] |
getIndexedPropertyDescriptors(java.lang.Object o)
|
java.lang.String |
getInfoString(java.lang.reflect.Method m)
|
java.lang.reflect.Method |
getMethod(java.lang.String s)
|
java.beans.MethodDescriptor[] |
getMethodDescriptors()
|
static java.beans.MethodDescriptor[] |
getMethodDescriptors(java.lang.Object o)
|
MethodList |
getMethodList()
|
java.lang.reflect.Method[] |
getMethods()
Get all but inherited methods. |
java.lang.reflect.Method[] |
getMethodsWithNArgs(int n)
|
static java.lang.reflect.Method[] |
getMethodsWithNoArguments(java.lang.Object o)
|
int |
getModifiers(java.lang.reflect.Method m)
|
java.lang.String |
getModifierString(java.lang.reflect.Method m)
|
java.lang.String |
getName(java.lang.reflect.Method m)
Get A string representation of the method. |
java.lang.Object |
getObject()
|
java.beans.PropertyDescriptor[] |
getPropertyDescriptors()
|
static java.beans.PropertyDescriptor[] |
getPropertyDescriptors(java.lang.Object o)
|
static LabeledItemPanel |
getPropertyEditor(java.lang.Object ip)
|
java.lang.Class[] |
getPublicClassMembers()
Get a list of public class members that are not inherited. |
java.lang.String[] |
getReadMethodNames()
|
java.lang.String[] |
getReadMethodNames(int n)
Get the method that have exactly n arguments |
java.lang.String[] |
getReadPublicMethodNames(int n)
Get the method that have exactly n arguments |
static java.lang.String |
getString(java.lang.String prompt)
|
java.lang.Class[] |
getSuperClasses()
|
static java.lang.Class[] |
getSuperInterfaces(java.lang.Class ci)
Get all the interfaces implemented by this class, in order of listing. |
java.lang.Class[] |
getSuperInterfaces(java.lang.Class[] ca)
|
java.lang.String[] |
getWriteMethodNames()
|
java.lang.String[] |
getWriteMethodNames(java.lang.reflect.Method[] m)
Filters all the methods on input and returns only the write methods |
static boolean |
hasMain(java.lang.Class classToBeExamined)
Returns true if the Class has
a public static void main(String
args[]) method in it. |
java.lang.Object |
invoke(java.lang.String methodName)
invoke a methodName string with no arguments. |
java.lang.Object |
invoke2(java.lang.String methodName)
invoke a methodName string with no arguments. |
boolean |
isContainedBy(java.lang.reflect.Method[] ma,
java.lang.reflect.Method m)
|
static boolean |
isNumeric(java.lang.Class obj)
|
static boolean |
isReadMethod(java.lang.reflect.Method method)
|
static boolean |
isWriteMethod(java.lang.reflect.Method method)
|
static void |
main(java.lang.String[] args)
Example of reflectUtil usage. |
void |
print()
|
static void |
print(java.beans.EventSetDescriptor[] esd)
|
static void |
print(java.beans.IndexedPropertyDescriptor[] ipd)
|
static void |
print(java.beans.MethodDescriptor[] md)
|
void |
print(java.lang.Object o)
|
void |
print(java.lang.Object[] o)
|
static void |
print(java.beans.PropertyDescriptor[] pd)
|
void |
printDeclaredMethods()
|
void |
printInfo()
print information about the containing instance to the console. |
void |
printInfo(java.lang.reflect.Method m)
|
static void |
printMethodNamesAndParameters(PrintStub printStub,
java.lang.reflect.Method[] ma)
|
void |
startCommandLineInterpreter()
starts a simple command line interpreter that takes in method names. |
static void |
testEventSetDescriptors()
|
static void |
testIndexedPropertyDescriptors()
|
static void |
testIntrospectionEditor()
|
static void |
testIntrospectUtil()
|
static void |
testMethodDescriptors()
|
static void |
testPropertyDescriptors()
|
static java.lang.String |
toString(java.lang.Object[] o)
Convert an array of Object
into a string. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ReflectUtil(java.lang.Object _o)
_o
- an instance of an object to be
inspectedMethod Detail |
---|
public java.lang.reflect.Constructor[] getConstructors()
public java.lang.reflect.Field[] getFields()
public java.lang.reflect.Method[] getMethods()
public java.lang.reflect.Method[] getAllPublicStaticMethods()
public void printDeclaredMethods()
public java.lang.reflect.Method[] getAllPublicMethods()
public java.lang.reflect.Method[] getAllMethods()
public static boolean hasMain(java.lang.Class classToBeExamined)
Class
has
a public static void main(String
args[])
method in it.
true
if and only if
class has a main.public java.lang.Class[] getSuperClasses()
public java.lang.Class[] getSuperInterfaces(java.lang.Class[] ca)
public static java.lang.Class[] getSuperInterfaces(java.lang.Class ci)
ci
- class instance to be inspected
public java.lang.Class[] getPublicClassMembers()
public static java.lang.Class[] getAllInterfaces(java.lang.Class c)
public static void addImmediateInterfaces(java.lang.Class c, java.util.Vector v)
public java.lang.String[] getReadMethodNames()
public java.lang.String[] getReadPublicMethodNames(int n)
n
- a number that start affineTransform 0
public java.lang.String[] getReadMethodNames(int n)
n
- a number that start affineTransform 0
public java.lang.String[] getWriteMethodNames()
public java.lang.String[] getWriteMethodNames(java.lang.reflect.Method[] m)
m
-
public java.lang.reflect.Method getMethod(java.lang.String s)
s
- a method name
public java.lang.Object invoke(java.lang.String methodName)
public int getModifiers(java.lang.reflect.Method m)
m
- a method to be inspected
public java.lang.String getModifierString(java.lang.reflect.Method m)
m
- method
public static java.lang.String toString(java.lang.Object[] o)
Object
into a string.
o
- an array of string in
public void printInfo()
public java.lang.String getClassName()
public java.lang.reflect.Method[] getMethodsWithNArgs(int n)
public java.lang.String getName(java.lang.reflect.Method m)
m
- method name
public java.lang.String getInfoString(java.lang.reflect.Method m)
public void printInfo(java.lang.reflect.Method m)
public static void main(java.lang.String[] args)
args
- ignored.public void startCommandLineInterpreter()
public static java.lang.String getString(java.lang.String prompt)
public java.lang.Class getC()
public static java.lang.reflect.Method[] getAllMethods(java.lang.Object o)
public static java.lang.reflect.Method[] getMethodsWithNoArguments(java.lang.Object o)
public java.lang.Object invoke2(java.lang.String methodName)
public static void printMethodNamesAndParameters(PrintStub printStub, java.lang.reflect.Method[] ma)
public java.lang.Class[] getClasses()
public boolean isContainedBy(java.lang.reflect.Method[] ma, java.lang.reflect.Method m)
public java.lang.reflect.Method[] getAllMethodsNotInObjectClass(java.lang.reflect.Method[] m)
public static void testIndexedPropertyDescriptors() throws java.beans.IntrospectionException
java.beans.IntrospectionException
public static java.beans.PropertyDescriptor[] getIndexedPropertyDescriptors(java.lang.Object o) throws java.beans.IntrospectionException
java.beans.IntrospectionException
public static void print(java.beans.PropertyDescriptor[] pd)
public static void print(java.beans.IndexedPropertyDescriptor[] ipd)
public java.lang.String getBeanInfo()
public static java.lang.String getBeanDescriptorString(java.beans.BeanInfo bi)
public void print()
public void print(java.lang.Object o)
public static void testPropertyDescriptors() throws java.beans.IntrospectionException
java.beans.IntrospectionException
public static java.beans.PropertyDescriptor[] getPropertyDescriptors(java.lang.Object o) throws java.beans.IntrospectionException
java.beans.IntrospectionException
public static void testMethodDescriptors() throws java.beans.IntrospectionException
java.beans.IntrospectionException
public static void print(java.beans.MethodDescriptor[] md)
public static java.beans.MethodDescriptor[] getMethodDescriptors(java.lang.Object o) throws java.beans.IntrospectionException
java.beans.IntrospectionException
public static void testEventSetDescriptors() throws java.beans.IntrospectionException
java.beans.IntrospectionException
public static java.beans.EventSetDescriptor[] getEventSetDescriptors(java.lang.Object o) throws java.beans.IntrospectionException
java.beans.IntrospectionException
public static void print(java.beans.EventSetDescriptor[] esd)
public void print(java.lang.Object[] o)
public static void testIntrospectUtil()
public java.lang.Object getObject()
public MethodList getMethodList()
public java.beans.PropertyDescriptor[] getPropertyDescriptors()
public java.beans.MethodDescriptor[] getMethodDescriptors()
public static java.lang.String getDisplayName(java.lang.reflect.Method m)
public static double getDouble(java.lang.Object obj)
public static java.lang.Double getDoubleWrapper(java.lang.Object obj)
public static boolean isNumeric(java.lang.Class obj)
obj
- any object to be tested
public static void testIntrospectionEditor()
public static LabeledItemPanel getPropertyEditor(java.lang.Object ip)
public static javax.swing.JComponent getComponent(java.lang.Object ip, java.lang.reflect.Method writeMethod)
public static boolean isReadMethod(java.lang.reflect.Method method)
public static boolean isWriteMethod(java.lang.reflect.Method method)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |