Package jsyntaxpane.util
Class ReflectUtils
java.lang.Object
jsyntaxpane.util.ReflectUtils
Reflection Utility methods
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intaddConstrcutors(Class aClass, List<Member> list) Adds all Constructor (from Class.getConstructorCalls) to the liststatic intAdds all Fields (from Class.getFields) to the liststatic intaddMethods(Class aClass, List<Member> list) Adds all methods (from Class.getMethodCalls) to the liststatic StringBuilderaddParamsString(StringBuilder call, Class[] params) Adds the class SimpleNames, comma sepearated and surrounded by paranthesis to the call StringBufferstatic intaddStaticFields(Class aClass, List<Member> list) Adds all static Fields (from Class.getFields) to the liststatic intaddStaticMethods(Class aClass, List<Member> list) Adds all static methods (from Class.getMethodCalls) to the liststatic booleancallSetter(Object obj, String property, Object value) Find a setter method for the give object's property and try to call it.static ClassAttempt to find the given className within any of the packages.static String[]getConstructorCalls(Class aClass) Gets an array of all Constructor calls for the given classstatic StringConvert the constructor to a Java Code String (arguments are replaced by the simple types)static StringgetJavaCallString(Method method) Convert the Method to a Java Code String (arguments are replaced by the simple types)static String[]getMethodCalls(Class aClass) Gets a String array of all method calls for the given classstatic StringgetParamsString(Class[] params) Return a paranthesis enclosed, comma sepearated String of all SimpleClass names in params.
-
Field Details
-
DEFAULT_PACKAGES
-
-
Constructor Details
-
ReflectUtils
public ReflectUtils()
-
-
Method Details
-
addMethods
Adds all methods (from Class.getMethodCalls) to the list- Parameters:
aClass-list-- Returns:
- number of methods added
-
addStaticMethods
Adds all static methods (from Class.getMethodCalls) to the list- Parameters:
aClass-list-- Returns:
- number of methods added
-
addStaticFields
Adds all static Fields (from Class.getFields) to the list- Parameters:
aClass-list-- Returns:
- number of fields added
-
addFields
Adds all Fields (from Class.getFields) to the list- Parameters:
aClass-list-- Returns:
- number of fields added
-
addConstrcutors
Adds all Constructor (from Class.getConstructorCalls) to the list- Parameters:
aClass-list-- Returns:
- number of constructors added
-
getJavaCallString
Convert the constructor to a Java Code String (arguments are replaced by the simple types)- Parameters:
c- Constructor- Returns:
-
getJavaCallString
Convert the Method to a Java Code String (arguments are replaced by the simple types)- Parameters:
method- Method- Returns:
-
addParamsString
Adds the class SimpleNames, comma sepearated and surrounded by paranthesis to the call StringBuffer- Parameters:
call-params-- Returns:
-
getMethodCalls
Gets a String array of all method calls for the given class- Parameters:
aClass-- Returns:
-
getConstructorCalls
Gets an array of all Constructor calls for the given class- Parameters:
aClass-- Returns:
-
getParamsString
Return a paranthesis enclosed, comma sepearated String of all SimpleClass names in params.- Parameters:
params-- Returns:
-
findClass
Attempt to find the given className within any of the packages. If the class is not found, then null is returned- Parameters:
className- Fully or partially qualified classname within any of the packagespackages- List of packages for search- Returns:
- CLass object or null if not found.
-
callSetter
Find a setter method for the give object's property and try to call it. No exceptions are thrown. You typically call this method because either you are sure no exceptions will be thrown, or to silently ignore any that may be thrown. This will also find a setter that accepts an interface that the value implements. This is still not very effcient and should only be called if performance is not of an issue. You can check the return value to see if the call was seuccessful or not.- Parameters:
obj- Object to receive the callproperty- property name (without set. First letter will be capitalized)value- Value of the property.- Returns:
-