org.apache.commons.modeler.util
Class IntrospectionUtils

java.lang.Object
  |
  +--org.apache.commons.modeler.util.IntrospectionUtils

public final class IntrospectionUtils
extends java.lang.Object

Utils for introspection and reflection Source: jakarta-tomcat-connector/util


Nested Class Summary
static interface IntrospectionUtils.AttributeHolder
           
static interface IntrospectionUtils.PropertySource
           
 
Field Summary
(package private) static int dbg
           
(package private) static java.lang.Object[] emptyArray
           
(package private) static java.lang.Class[] NO_PARAMS
           
(package private) static java.util.Hashtable objectMethods
           
static java.lang.String PATH_SEPARATOR
           
(package private) static java.lang.Class[] STRING_OBJ_PARAM
           
(package private) static java.lang.Class[] STRING_PARAM
           
 
Constructor Summary
IntrospectionUtils()
           
 
Method Summary
static void addJarsFromClassPath(java.util.Vector jars, java.lang.String cp)
          add elements from the classpath cp to a Vector jars as file URLs (We use Vector for JDK 1.1 compat).
static void addToClassPath(java.util.Vector cpV, java.lang.String dir)
          Add all the jar files in a dir to the classpath, represented as a Vector of URLs.
static void addToolsJar(java.util.Vector v)
           
static void callMain(java.lang.Class c, java.lang.String[] args)
           
static java.lang.Object callMethod0(java.lang.Object target, java.lang.String methodN)
           
static java.lang.Object callMethod1(java.lang.Object target, java.lang.String methodN, java.lang.Object param1, java.lang.String typeParam1, java.lang.ClassLoader cl)
           
static java.lang.Object callMethodN(java.lang.Object target, java.lang.String methodN, java.lang.Object[] params, java.lang.Class[] typeParams)
           
static java.lang.String capitalize(java.lang.String name)
          Reverse of Introspector.decapitalize
static java.lang.String classPathAdd(java.net.URL[] urls, java.lang.String cp)
          Adds classpath entries from a vector of URL's to the "tc_path_add" System property.
(package private) static void d(java.lang.String s)
           
static void displayClassPath(java.lang.String msg, java.net.URL[] cp)
          Debug method, display the classpath
static void execute(java.lang.Object proxy, java.lang.String method)
          Execute a no-param method.
static java.lang.String[] findBooleanSetters(java.lang.Class c)
           
static java.lang.reflect.Method findMethod(java.lang.Class c, java.lang.String name, java.lang.Class[] params)
           
static java.lang.reflect.Method[] findMethods(java.lang.Class c)
           
static java.lang.String[] findVoidSetters(java.lang.Class c)
           
static java.lang.Object getAttribute(java.lang.Object proxy, java.lang.String n)
          Call void getAttribute( String )
static java.net.URL[] getClassPath(java.lang.String dir, java.lang.String cpath, java.lang.String cpathProp, boolean addTools)
          Construct a URL classpath from files in a directory, a cpath property, and tools.jar.
static java.net.URL[] getClassPath(java.util.Vector v)
          Return a URL[] that can be used to construct a class loader
static java.lang.String[] getFilesByExt(java.lang.String ld, java.lang.String ext)
          Return all files with a given extension in a dir
static java.lang.Object getProperty(java.lang.Object o, java.lang.String name)
           
static java.net.URL getURL(java.lang.String base, java.lang.String file)
          Construct a file url from a file, using a base dir
static java.lang.ClassLoader getURLClassLoader(java.net.URL[] urls, java.lang.ClassLoader parent)
          Construct a URLClassLoader.
static java.lang.String guessInstall(java.lang.String installSysProp, java.lang.String homeSysProp, java.lang.String jarName)
           
static java.lang.String guessInstall(java.lang.String installSysProp, java.lang.String homeSysProp, java.lang.String jarName, java.lang.String classFile)
          Guess a product install/home by analyzing the class path.
static boolean hasHook(java.lang.Object obj, java.lang.String methodN)
          Test if the object implements a particular method
static boolean processArgs(java.lang.Object proxy, java.lang.String[] args)
           
static boolean processArgs(java.lang.Object proxy, java.lang.String[] args, java.lang.String[] args0, java.lang.String[] args1, java.util.Hashtable aliases)
           
static java.lang.String replaceProperties(java.lang.String value, java.util.Hashtable staticProp, IntrospectionUtils.PropertySource[] dynamicProp)
          Replace ${NAME} with the property value
static java.lang.String replaceProperties(java.lang.String value, java.lang.Object getter)
          Deprecated. Use the explicit method
static void setAttribute(java.lang.Object proxy, java.lang.String n, java.lang.Object v)
          Call void setAttribute( String ,Object )
static void setProperty(java.lang.Object o, java.lang.String name)
           
static void setProperty(java.lang.Object o, java.lang.String name, java.lang.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).
static java.lang.String unCapitalize(java.lang.String name)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NO_PARAMS

static final java.lang.Class[] NO_PARAMS

STRING_OBJ_PARAM

static final java.lang.Class[] STRING_OBJ_PARAM

STRING_PARAM

static final java.lang.Class[] STRING_PARAM

PATH_SEPARATOR

public static java.lang.String PATH_SEPARATOR

objectMethods

static java.util.Hashtable objectMethods

emptyArray

static java.lang.Object[] emptyArray

dbg

static final int dbg
See Also:
Constant Field Values
Constructor Detail

IntrospectionUtils

public IntrospectionUtils()
Method Detail

execute

public static void execute(java.lang.Object proxy,
                           java.lang.String method)
                    throws java.lang.Exception
Execute a no-param method.

java.lang.Exception

setAttribute

public static void setAttribute(java.lang.Object proxy,
                                java.lang.String n,
                                java.lang.Object v)
                         throws java.lang.Exception
Call void setAttribute( String ,Object )

java.lang.Exception

getAttribute

public static java.lang.Object getAttribute(java.lang.Object proxy,
                                            java.lang.String n)
                                     throws java.lang.Exception
Call void getAttribute( String )

java.lang.Exception

getURLClassLoader

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


guessInstall

public static java.lang.String guessInstall(java.lang.String installSysProp,
                                            java.lang.String homeSysProp,
                                            java.lang.String jarName)

guessInstall

public static java.lang.String guessInstall(java.lang.String installSysProp,
                                            java.lang.String homeSysProp,
                                            java.lang.String jarName,
                                            java.lang.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(java.lang.String msg,
                                    java.net.URL[] cp)
Debug method, display the classpath


classPathAdd

public static java.lang.String classPathAdd(java.net.URL[] urls,
                                            java.lang.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 void setProperty(java.lang.Object o,
                               java.lang.String name,
                               java.lang.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).


getProperty

public static java.lang.Object getProperty(java.lang.Object o,
                                           java.lang.String name)

setProperty

public static void setProperty(java.lang.Object o,
                               java.lang.String name)

replaceProperties

public static java.lang.String replaceProperties(java.lang.String value,
                                                 java.lang.Object getter)
Deprecated. Use the explicit method

Replace ${NAME} with the property value


replaceProperties

public static java.lang.String replaceProperties(java.lang.String value,
                                                 java.util.Hashtable staticProp,
                                                 IntrospectionUtils.PropertySource[] dynamicProp)
Replace ${NAME} with the property value


capitalize

public static java.lang.String capitalize(java.lang.String name)
Reverse of Introspector.decapitalize


unCapitalize

public static java.lang.String unCapitalize(java.lang.String name)

addToClassPath

public static void addToClassPath(java.util.Vector cpV,
                                  java.lang.String dir)
Add all the jar files in a dir to the classpath, represented as a Vector of URLs.


addToolsJar

public static void addToolsJar(java.util.Vector v)

getFilesByExt

public static java.lang.String[] getFilesByExt(java.lang.String ld,
                                               java.lang.String ext)
Return all files with a given extension in a dir


getURL

public static java.net.URL getURL(java.lang.String base,
                                  java.lang.String file)
Construct a file url from a file, using a base dir


addJarsFromClassPath

public static void addJarsFromClassPath(java.util.Vector jars,
                                        java.lang.String cp)
                                 throws java.io.IOException,
                                        java.net.MalformedURLException
add elements from the classpath cp to a Vector jars as file URLs (We use Vector for JDK 1.1 compat).

Parameters:
jars - A vector of URLs
cp - a String classpath of directory or jar file elements separated by path.separator delimiters.
java.io.IOException
java.net.MalformedURLException

getClassPath

public static java.net.URL[] getClassPath(java.util.Vector v)
Return a URL[] that can be used to construct a class loader


getClassPath

public static java.net.URL[] getClassPath(java.lang.String dir,
                                          java.lang.String cpath,
                                          java.lang.String cpathProp,
                                          boolean addTools)
                                   throws java.io.IOException,
                                          java.net.MalformedURLException
Construct a URL classpath from files in a directory, a cpath property, and tools.jar.

java.io.IOException
java.net.MalformedURLException

processArgs

public static boolean processArgs(java.lang.Object proxy,
                                  java.lang.String[] args)
                           throws java.lang.Exception
java.lang.Exception

processArgs

public static boolean processArgs(java.lang.Object proxy,
                                  java.lang.String[] args,
                                  java.lang.String[] args0,
                                  java.lang.String[] args1,
                                  java.util.Hashtable aliases)
                           throws java.lang.Exception
java.lang.Exception

findVoidSetters

public static java.lang.String[] findVoidSetters(java.lang.Class c)

findBooleanSetters

public static java.lang.String[] findBooleanSetters(java.lang.Class c)

findMethods

public static java.lang.reflect.Method[] findMethods(java.lang.Class c)

findMethod

public static java.lang.reflect.Method findMethod(java.lang.Class c,
                                                  java.lang.String name,
                                                  java.lang.Class[] params)

hasHook

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


callMain

public static void callMain(java.lang.Class c,
                            java.lang.String[] args)
                     throws java.lang.Exception
java.lang.Exception

callMethod1

public static java.lang.Object callMethod1(java.lang.Object target,
                                           java.lang.String methodN,
                                           java.lang.Object param1,
                                           java.lang.String typeParam1,
                                           java.lang.ClassLoader cl)
                                    throws java.lang.Exception
java.lang.Exception

callMethod0

public static java.lang.Object callMethod0(java.lang.Object target,
                                           java.lang.String methodN)
                                    throws java.lang.Exception
java.lang.Exception

callMethodN

public static java.lang.Object callMethodN(java.lang.Object target,
                                           java.lang.String methodN,
                                           java.lang.Object[] params,
                                           java.lang.Class[] typeParams)
                                    throws java.lang.Exception
java.lang.Exception

d

static void d(java.lang.String s)


Copyright (c) 2001-2003 - Apache Software Foundation