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 int
addConstrcutors
(Class aClass, List<Member> list) Adds all Constructor (from Class.getConstructorCalls) to the liststatic int
Adds all Fields (from Class.getFields) to the liststatic int
addMethods
(Class aClass, List<Member> list) Adds all methods (from Class.getMethodCalls) to the liststatic StringBuilder
addParamsString
(StringBuilder call, Class[] params) Adds the class SimpleNames, comma sepearated and surrounded by paranthesis to the call StringBufferstatic int
addStaticFields
(Class aClass, List<Member> list) Adds all static Fields (from Class.getFields) to the liststatic int
addStaticMethods
(Class aClass, List<Member> list) Adds all static methods (from Class.getMethodCalls) to the liststatic boolean
callSetter
(Object obj, String property, Object value) Find a setter method for the give object's property and try to call it.static Class
Attempt 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 String
Convert the constructor to a Java Code String (arguments are replaced by the simple types)static String
getJavaCallString
(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 String
getParamsString
(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:
-