Top Description Inners Fields Constructors Methods
org.apache.tomcat.util

public final Class IntrospectionUtils

extends Object
Class Inheritance
Imports
java.lang.reflect.InvocationTargetException, .Method, java.net.InetAddress, .UnknownHostException, java.util.Hashtable, .Map, java.util.concurrent.ConcurrentHashMap, org.apache.juli.logging.Log, .LogFactory, org.apache.tomcat.util.res.StringManager, org.apache.tomcat.util.security.PermissionCheck

Utils for introspection and reflection

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
public static interface

Field Summary

Modifier and TypeField and Description
private static final Log
private static final Map<Class<?>, Method[]>
private static final StringManager

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static Object
callMethod1(Object target, String methodN, Object param1, String typeParam1, ClassLoader cl)

public static Object
callMethodN(Object target, String methodN, Object[] params, Class<?>[] typeParams)

public static String

Returns:

the capitalized string
capitalize
(String
The name
name
)

Reverse of Introspector.decapitalize.

public static void
public static Object
convert(String object, Class<?> paramType)

public static String

Returns:

escaped string, per Java rule
escape
(String
the input string
s
)

public static Method
findMethod(Class<?> c, String name, Class<?>[] params)

public static Method[]
public static Object
private static String
getProperty(String name, Hashtable<Object, Object> staticProp, IntrospectionUtils.PropertySource[] dynamicProp, ClassLoader classLoader)

public static boolean

Returns:

true if the clazz tested is an instance of the specified type, false otherwise.
isInstance
(Class<?>
The class to test for a match.
clazz
,
String
The name of the type that clazz must be.
type
)

Checks to see if the specified class is an instance of or assignable from the specified type.

public static String

Returns:

the replacement value
replaceProperties
(String
The value
value
,
Hashtable<Object, Object>
Replacement properties
staticProp
,
IntrospectionUtils.PropertySource[]
Replacement properties
dynamicProp
,
ClassLoader
Class loader associated with the code requesting the property
classLoader
)

Replaces ${NAME} in the value with the value of the property 'NAME'.

private static String
replaceProperties(String value, Hashtable<Object, Object> staticProp, IntrospectionUtils.PropertySource[] dynamicProp, ClassLoader classLoader, int iterationCount)

public static boolean

Returns:

true if operation was successful
setProperty
(Object
The object to set a property on
o
,
String
The property name
name
,
String
The property value
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).

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

public static boolean
setProperty(Object o, String name, String value, boolean invokeSetProperty, StringBuilder actualMethod)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

logback to summary
private static final Log log
objectMethodsback to summary
private static final Map<Class<?>, Method[]> objectMethods
smback to summary
private static final StringManager sm

Constructor Detail

IntrospectionUtilsback to summary
public IntrospectionUtils()

Method Detail

callMethod1back to summary
public static Object callMethod1(Object target, String methodN, Object param1, String typeParam1, ClassLoader cl) throws Exception
callMethodNback to summary
public static Object callMethodN(Object target, String methodN, Object[] params, Class<?>[] typeParams) throws Exception
capitalizeback to summary
public static String capitalize(String name)

Reverse of Introspector.decapitalize.

Parameters
name:String

The name

Returns:String

the capitalized string

clearback to summary
public static void clear()
convertback to summary
public static Object convert(String object, Class<?> paramType)
escapeback to summary
public static String escape(String s)
Parameters
s:String

the input string

Returns:String

escaped string, per Java rule

findMethodback to summary
public static Method findMethod(Class<?> c, String name, Class<?>[] params)
findMethodsback to summary
public static Method[] findMethods(Class<?> c)
getPropertyback to summary
public static Object getProperty(Object o, String name)
getPropertyback to summary
private static String getProperty(String name, Hashtable<Object, Object> staticProp, IntrospectionUtils.PropertySource[] dynamicProp, ClassLoader classLoader)
isInstanceback to summary
public static boolean isInstance(Class<?> clazz, String type)

Checks to see if the specified class is an instance of or assignable from the specified type. The class clazz, all its superclasses, interfaces and those superinterfaces are tested for a match against the type name type. This is similar to instanceof or Class#isAssignableFrom except that the target type will not be resolved into a Class object, which provides some security and memory benefits.

Parameters
clazz:Class<?>

The class to test for a match.

type:String

The name of the type that clazz must be.

Returns:boolean

true if the clazz tested is an instance of the specified type, false otherwise.

replacePropertiesback to summary
public static String replaceProperties(String value, Hashtable<Object, Object> staticProp, IntrospectionUtils.PropertySource[] dynamicProp, ClassLoader classLoader)

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:String

The value

staticProp:Hashtable<Object, Object>

Replacement properties

dynamicProp:IntrospectionUtils.PropertySource[]

Replacement properties

classLoader:ClassLoader

Class loader associated with the code requesting the property

Returns:String

the replacement value

replacePropertiesback to summary
private static String replaceProperties(String value, Hashtable<Object, Object> staticProp, IntrospectionUtils.PropertySource[] dynamicProp, ClassLoader classLoader, int iterationCount)
setPropertyback to summary
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).

Parameters
o:Object

The object to set a property on

name:String

The property name

value:String

The property value

Returns:boolean

true if operation was successful

setPropertyback to summary
public static boolean setProperty(Object o, String name, String value, boolean invokeSetProperty)
setPropertyback to summary
public static boolean setProperty(Object o, String name, String value, boolean invokeSetProperty, StringBuilder actualMethod)
Annotations
@SuppressWarnings:null
org.apache.tomcat.util back to summary

public Interface IntrospectionUtils.PropertySource

Known Direct Subinterfaces
org.apache.tomcat.util.IntrospectionUtils.SecurePropertySource

Method Summary

Modifier and TypeMethod and Description
public String

Method Detail

getPropertyback to summary
public String getProperty(String key)
org.apache.tomcat.util back to summary

public Interface IntrospectionUtils.SecurePropertySource

extends PropertySource
Known Direct Implementers
org.apache.tomcat.util.digester.EnvironmentPropertySource, org.apache.tomcat.util.digester.ServiceBindingPropertySource, org.apache.tomcat.util.digester.SystemPropertySource

Method Summary

Modifier and TypeMethod and Description
public String

Returns:

The property value or null if it could not be found or if PermissionCheck#check(java.security.Permission) fails
getProperty
(String
The key of the requested property
key
,
ClassLoader
The class loader associated with the code that trigger the property lookup
classLoader
)

Obtain a property value, checking that code associated with the provided class loader has permission to access the property.

Inherited from org.apache.tomcat.util.IntrospectionUtils.PropertySource:
getProperty

Method Detail

getPropertyback to summary
public String getProperty(String key, ClassLoader classLoader)

Obtain a property value, checking that code associated with the provided class loader has permission to access the property. If the classLoader is null or if classLoader does not implement PermissionCheck then the property value will be looked up without a call to PermissionCheck#check(java.security.Permission)

Parameters
key:String

The key of the requested property

classLoader:ClassLoader

The class loader associated with the code that trigger the property lookup

Returns:String

The property value or null if it could not be found or if PermissionCheck#check(java.security.Permission) fails