Class IntrospectionUtils


  • public final class IntrospectionUtils
    extends Object
    Utils for introspection and reflection
    • Field Detail

      • PATH_SEPARATOR

        public static final String PATH_SEPARATOR
    • Constructor Detail

      • IntrospectionUtils

        public IntrospectionUtils()
    • Method Detail

      • execute

        public static void execute​(Object proxy,
                                   String method)
                            throws Exception
        Call execute() - any ant-like task should work
        Throws:
        Exception
      • getURLClassLoader

        public static ClassLoader getURLClassLoader​(URL[] urls,
                                                    ClassLoader parent)
        Construct a URLClassLoader. Will compile and work in JDK1.1 too.
      • guessInstall

        public static String guessInstall​(String installSysProp,
                                          String homeSysProp,
                                          String jarName,
                                          String classFile)
        Guess a product install/home by analyzing the class path. It works for product using the pattern: lib/executable.jar or if executable.jar is included in classpath by a shell script. ( java -jar also works ) Insures both "install" and "home" System properties are set. If either or both System properties are unset, "install" and "home" will be set to the same value. This value will be the other System property that is set, or the guessed value if neither is set.
      • displayClassPath

        public static void displayClassPath​(String msg,
                                            URL[] cp)
        Debug method, display the classpath
      • classPathAdd

        public static String classPathAdd​(URL[] urls,
                                          String cp)
        Adds classpath entries from a vector of URL's to the "tc_path_add" System property. This System property lists the classpath entries common to web applications. This System property is currently used by Jasper when its JSP servlet compiles the Java file for a JSP.
      • setProperty

        public static boolean setProperty​(Object o,
                                          String name,
                                          String value)
        Find a method with the right name If found, call the method ( if param is int or boolean we'll convert value to the right type before) - that means you can have setDebug(1).
      • setProperty

        public static boolean setProperty​(Object o,
                                          String name,
                                          String value,
                                          boolean invokeSetProperty)
      • setProperty

        public static void setProperty​(Object o,
                                       String name)
      • capitalize

        public static String capitalize​(String name)
        Reverse of Introspector.decapitalize
      • unCapitalize

        public static String unCapitalize​(String name)
      • addToClassPath

        public static void addToClassPath​(Vector<URL> cpV,
                                          String dir)
        Add all the jar files in a dir to the classpath, represented as a Vector of URLs.
      • getFilesByExt

        public static String[] getFilesByExt​(String ld,
                                             String ext)
        Return all files with a given extension in a dir
      • getURL

        public static URL getURL​(String base,
                                 String file)
        Construct a file url from a file, using a base dir
      • addJarsFromClassPath

        public static void addJarsFromClassPath​(Vector<URL> jars,
                                                String cp)
                                         throws IOException,
                                                MalformedURLException
        Add elements from the classpath cp to a Vector jars as file URLs (We use Vector for JDK 1.1 compat).

        Parameters:
        jars - The jar list
        cp - a String classpath of directory or jar file elements separated by path.separator delimiters.
        Throws:
        IOException - If an I/O error occurs
        MalformedURLException - Doh ;)
      • getClassPath

        public static URL[] getClassPath​(Vector<URL> v)
        Return a URL[] that can be used to construct a class loader
      • clear

        public static void clear()
      • findMethods

        public static Method[] findMethods​(Class<?> c)
        This method may return an array of length, but not null.
      • hasHook

        public static boolean hasHook​(Object obj,
                                      String methodN)
        Test if the object implements a particular method