Class ReflectUtils

java.lang.Object
jsyntaxpane.util.ReflectUtils

public class ReflectUtils extends Object
Reflection Utility methods
  • Field Details

    • DEFAULT_PACKAGES

      public static final List<String> DEFAULT_PACKAGES
  • Constructor Details

    • ReflectUtils

      public ReflectUtils()
  • Method Details

    • addMethods

      public static int addMethods(Class aClass, List<Member> list)
      Adds all methods (from Class.getMethodCalls) to the list
      Parameters:
      aClass -
      list -
      Returns:
      number of methods added
    • addStaticMethods

      public static int addStaticMethods(Class aClass, List<Member> list)
      Adds all static methods (from Class.getMethodCalls) to the list
      Parameters:
      aClass -
      list -
      Returns:
      number of methods added
    • addStaticFields

      public static int addStaticFields(Class aClass, List<Member> list)
      Adds all static Fields (from Class.getFields) to the list
      Parameters:
      aClass -
      list -
      Returns:
      number of fields added
    • addFields

      public static int addFields(Class aClass, List<Member> list)
      Adds all Fields (from Class.getFields) to the list
      Parameters:
      aClass -
      list -
      Returns:
      number of fields added
    • addConstrcutors

      public static int addConstrcutors(Class aClass, List<Member> list)
      Adds all Constructor (from Class.getConstructorCalls) to the list
      Parameters:
      aClass -
      list -
      Returns:
      number of constructors added
    • getJavaCallString

      public static String getJavaCallString(Constructor c)
      Convert the constructor to a Java Code String (arguments are replaced by the simple types)
      Parameters:
      c - Constructor
      Returns:
    • getJavaCallString

      public static String getJavaCallString(Method method)
      Convert the Method to a Java Code String (arguments are replaced by the simple types)
      Parameters:
      method - Method
      Returns:
    • addParamsString

      public static StringBuilder addParamsString(StringBuilder call, Class[] params)
      Adds the class SimpleNames, comma sepearated and surrounded by paranthesis to the call StringBuffer
      Parameters:
      call -
      params -
      Returns:
    • getMethodCalls

      public static String[] getMethodCalls(Class aClass)
      Gets a String array of all method calls for the given class
      Parameters:
      aClass -
      Returns:
    • getConstructorCalls

      public static String[] getConstructorCalls(Class aClass)
      Gets an array of all Constructor calls for the given class
      Parameters:
      aClass -
      Returns:
    • getParamsString

      public static String getParamsString(Class[] params)
      Return a paranthesis enclosed, comma sepearated String of all SimpleClass names in params.
      Parameters:
      params -
      Returns:
    • findClass

      public static Class findClass(String className, List<String> packages)
      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 packages
      packages - List of packages for search
      Returns:
      CLass object or null if not found.
    • callSetter

      public static boolean callSetter(Object obj, String property, Object value)
      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 call
      property - property name (without set. First letter will be capitalized)
      value - Value of the property.
      Returns: