Package org.atmosphere.util
Class IntrospectionUtils
java.lang.Object
org.atmosphere.util.IntrospectionUtils
Utils for introspection and reflection
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfacestatic interface -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddJarsFromClassPath(Vector<URL> jars, String cp) Add elements from the classpath cp to a Vector jars as file URLs (We use Vector for JDK 1.1 compat).static final booleanaddProperty(Object o, String name, String value) static voidaddToClassPath(Vector<URL> cpV, String dir) Add all the jar files in a dir to the classpath, represented as a Vector of URLs.static voidaddToolsJar(Vector<URL> v) static voidstatic ObjectcallMethod0(Object target, String methodN) static ObjectcallMethod1(Object target, String methodN, Object param1, String typeParam1, ClassLoader cl) static ObjectcallMethodN(Object target, String methodN, Object[] params, Class<?>[] typeParams) static Stringcapitalize(String name) Reverse of Introspector.decapitalizestatic voidclear()static Objectstatic voidCall execute() - any ant-like task should workstatic String[]findBooleanSetters(Class<?> c) static MethodfindMethod(Class<?> c, String name, Class<?>[] params) static Method[]findMethods(Class<?> c) static String[]findVoidSetters(Class<?> c) static ObjectgetAttribute(Object proxy, String name) Call void getAttribute( String )static URL[]getClassPath(String dir, String cpath, String cpathProp, boolean addTools) Construct a URL classpath from files in a directory, a cpath property, and tools.jar.static URL[]getClassPath(Vector<URL> v) Return a URL[] that can be used to construct a class loaderstatic String[]getFilesByExt(String ld, String ext) Return all files with a given extension in a dirstatic ObjectgetProperty(Object object, String name) static URLConstruct a file url from a file, using a base dirstatic booleanTest if the object implements a particular methodstatic final booleaninvokeProperty(Object object, String setter, String name, String value) static booleanprocessArgs(Object proxy, String[] args) static booleanprocessArgs(Object proxy, String[] args, String[] args0, String[] args1, Hashtable<String, String> aliases) static StringreplaceProperties(String value, Hashtable<String, String> staticProp, IntrospectionUtils.PropertySource[] dynamicProp) Replace ${NAME} with the property valuestatic voidsetAttribute(Object proxy, String name, Object value) Call void setAttribute( String ,Object )static voidsetProperty(Object object, String name) static final booleansetProperty(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).static StringunCapitalize(String name)
-
Constructor Details
-
IntrospectionUtils
public IntrospectionUtils()
-
-
Method Details
-
execute
Call execute() - any ant-like task should work- Throws:
Exception
-
setAttribute
Call void setAttribute( String ,Object )- Throws:
Exception
-
getAttribute
Call void getAttribute( String )- Throws:
Exception
-
setProperty
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). -
addProperty
-
invokeProperty
-
getProperty
-
setProperty
-
replaceProperties
public static String replaceProperties(String value, Hashtable<String, String> staticProp, IntrospectionUtils.PropertySource[] dynamicProp) Replace ${NAME} with the property value -
capitalize
Reverse of Introspector.decapitalize -
unCapitalize
-
addToClassPath
Add all the jar files in a dir to the classpath, represented as a Vector of URLs. -
addToolsJar
-
getFilesByExt
Return all files with a given extension in a dir -
getURL
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 listcp- a String classpath of directory or jar file elements separated by path.separator delimiters.- Throws:
IOException- If an I/O error occursMalformedURLException- Doh ;)
-
getClassPath
Return a URL[] that can be used to construct a class loader -
getClassPath
public static URL[] getClassPath(String dir, String cpath, String cpathProp, boolean addTools) throws IOException, MalformedURLException Construct a URL classpath from files in a directory, a cpath property, and tools.jar.- Throws:
IOExceptionMalformedURLException
-
processArgs
- Throws:
Exception
-
processArgs
public static boolean processArgs(Object proxy, String[] args, String[] args0, String[] args1, Hashtable<String, String> aliases) throws Exception- Throws:
Exception
-
clear
public static void clear() -
findVoidSetters
-
findBooleanSetters
-
findMethods
-
findMethod
-
hasHook
Test if the object implements a particular method -
callMain
- Throws:
Exception
-
callMethod1
public static Object callMethod1(Object target, String methodN, Object param1, String typeParam1, ClassLoader cl) throws Exception - Throws:
Exception
-
callMethod0
- Throws:
Exception
-
callMethodN
public static Object callMethodN(Object target, String methodN, Object[] params, Class<?>[] typeParams) throws Exception - Throws:
Exception
-
convert
-