Package org.apache.tomcat.util
Class IntrospectionUtils
java.lang.Object
org.apache.tomcat.util.IntrospectionUtils
Utils for introspection and reflection
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
static interface
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic Object
callMethod1
(Object target, String methodN, Object param1, String typeParam1, ClassLoader cl) static Object
callMethodN
(Object target, String methodN, Object[] params, Class<?>[] typeParams) static String
capitalize
(String name) Reverse of Introspector.decapitalize.static void
clear()
static Object
static Method
findMethod
(Class<?> c, String name, Class<?>[] params) static Method[]
findMethods
(Class<?> c) static Object
getProperty
(Object o, String name) static boolean
isInstance
(Class<?> clazz, String type) Checks to see if the specified class is an instance of or assignable from the specified type.static String
replaceProperties
(String value, Hashtable<Object, Object> staticProp, IntrospectionUtils.PropertySource[] dynamicProp) Deprecated.static String
replaceProperties
(String value, Hashtable<Object, Object> staticProp, IntrospectionUtils.PropertySource[] dynamicProp, ClassLoader classLoader) Replace ${NAME} with the property value.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).static boolean
setProperty
(Object o, String name, String value, boolean invokeSetProperty)
-
Constructor Details
-
IntrospectionUtils
public IntrospectionUtils()
-
-
Method Details
-
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).- Parameters:
o
- The object to set a property onname
- The property namevalue
- The property value- Returns:
true
if operation was successful
-
setProperty
-
getProperty
-
replaceProperties
@Deprecated public static String replaceProperties(String value, Hashtable<Object, Object> staticProp, IntrospectionUtils.PropertySource[] dynamicProp) Replaces ${NAME} in the value with the value of the property 'NAME'. Replaces ${NAME:DEFAULT} with the value of the property 'NAME:DEFAULT', if the property 'NAME:DEFAULT' is not set, the expression is replaced with the value of the property 'NAME', if the property 'NAME' is not set, the expression is replaced with 'DEFAULT'. If the property is not set and there is no default the value will be returned unmodified.- Parameters:
value
- The valuestaticProp
- Replacement propertiesdynamicProp
- Replacement properties- Returns:
- the replacement value
-
replaceProperties
public static String replaceProperties(String value, Hashtable<Object, Object> staticProp, IntrospectionUtils.PropertySource[] dynamicProp, ClassLoader classLoader) Replace ${NAME} with the property value.- Parameters:
value
- The valuestaticProp
- Replacement propertiesdynamicProp
- Replacement propertiesclassLoader
- Class loader associated with the code requesting the property- Returns:
- the replacement value
-
capitalize
Reverse of Introspector.decapitalize.- Parameters:
name
- The name- Returns:
- the capitalized string
-
clear
public static void clear() -
findMethods
-
findMethod
-
callMethod1
public static Object callMethod1(Object target, String methodN, Object param1, String typeParam1, ClassLoader cl) throws Exception - Throws:
Exception
-
callMethodN
public static Object callMethodN(Object target, String methodN, Object[] params, Class<?>[] typeParams) throws Exception - Throws:
Exception
-
convert
-
isInstance
Checks to see if the specified class is an instance of or assignable from the specified type. The classclazz
, all its superclasses, interfaces and those superinterfaces are tested for a match against the type nametype
. This is similar toinstanceof
orClass.isAssignableFrom(java.lang.Class<?>)
except that the target type will not be resolved into a Class object, which provides some security and memory benefits.- Parameters:
clazz
- The class to test for a match.type
- The name of the type thatclazz
must be.- Returns:
true
if theclazz
tested is an instance of the specifiedtype
,false
otherwise.
-
replaceProperties(String, Hashtable, PropertySource[], ClassLoader)