public class Introspector
extends java.lang.Object
Introspector
is a utility for developers to figure out
which properties, events, and methods a JavaBean supports.
Introspector class walks over the class/superclass chain
of the target bean class. At each level it checks if there is a matching
BeanInfo
class which provides explicit information about the
bean, and if so uses that explicit information. Otherwise it uses the low
level reflection APIs to study the target class and uses design patterns to
analyze its behaviour and then proceeds to continue the introspection with
its baseclass.
sun.beans.infos
). If it
finds a "BeanInfo" class and the "BeanInfo" class returns non-null value when
queried for explicit information, use the explicit information
Modifier and Type | Field and Description |
---|---|
static int |
IGNORE_ALL_BEANINFO
Constant values to indicate that the
Introspector will
ignore all BeanInfo class. |
static int |
IGNORE_IMMEDIATE_BEANINFO
Constant values to indicate that the
Introspector will
ignore the BeanInfo class of the current bean class. |
static int |
USE_ALL_BEANINFO
Constant values to indicate that the
Introspector will use
all BeanInfo class which have been found. |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
decapitalize(java.lang.String name)
Decapitalizes a given string according to the rule:
|
static void |
flushCaches()
Flushes all
BeanInfo caches. |
static void |
flushFromCaches(java.lang.Class<?> clazz)
Flushes the
BeanInfo caches of the specified bean class |
static BeanInfo |
getBeanInfo(java.lang.Class<?> beanClass)
Gets the
BeanInfo object which contains the information of
the properties, events and methods of the specified bean class. |
static BeanInfo |
getBeanInfo(java.lang.Class<?> beanClass,
java.lang.Class<?> stopClass)
Gets the
BeanInfo object which contains the information of
the properties, events and methods of the specified bean class. |
static BeanInfo |
getBeanInfo(java.lang.Class<?> beanClass,
int flags)
Gets the
BeanInfo object which contains the information of
the properties, events and methods of the specified bean class. |
static java.lang.String[] |
getBeanInfoSearchPath()
Gets an array of search packages.
|
static void |
setBeanInfoSearchPath(java.lang.String[] path)
Sets the search packages.
|
public static final int IGNORE_ALL_BEANINFO
Introspector
will
ignore all BeanInfo
class.public static final int IGNORE_IMMEDIATE_BEANINFO
Introspector
will
ignore the BeanInfo
class of the current bean class.public static final int USE_ALL_BEANINFO
Introspector
will use
all BeanInfo
class which have been found. This is the default one.public static java.lang.String decapitalize(java.lang.String name)
name
- -
the String to decapitalizepublic static void flushCaches()
BeanInfo
caches.public static void flushFromCaches(java.lang.Class<?> clazz)
BeanInfo
caches of the specified bean classclazz
- the specified bean classpublic static BeanInfo getBeanInfo(java.lang.Class<?> beanClass) throws IntrospectionException
BeanInfo
object which contains the information of
the properties, events and methods of the specified bean class.
Introspector will cache the BeanInfo
object. Subsequent calls to this method will be answered with the cached
data.
beanClass
- the specified bean class.BeanInfo
of the bean class.IntrospectionException
public static BeanInfo getBeanInfo(java.lang.Class<?> beanClass, java.lang.Class<?> stopClass) throws IntrospectionException
BeanInfo
object which contains the information of
the properties, events and methods of the specified bean class. It will
not introspect the "stopclass" and its super class.
Introspector will cache the BeanInfo
object. Subsequent calls to this method will be answered with the cached
data.
beanClass
- the specified beanClass.stopClass
- the sopt class which should be super class of the bean class.
May be null.BeanInfo
of the bean class.IntrospectionException
public static BeanInfo getBeanInfo(java.lang.Class<?> beanClass, int flags) throws IntrospectionException
BeanInfo
object which contains the information of
the properties, events and methods of the specified bean class.
Introspector
will ignore all BeanInfo
class.flag==IGNORE_IMMEDIATE_BEANINFO, the
Introspector
will ignore the BeanInfo
class
of the current bean class.flag==USE_ALL_BEANINFO, the
Introspector
will use all BeanInfo
class
which have been found.Introspector will cache the BeanInfo
object. Subsequent calls to this method will be answered with the cached
data.
beanClass
- the specified bean class.flags
- the flag to control the usage of the explicit
BeanInfo
class.BeanInfo
of the bean class.IntrospectionException
public static java.lang.String[] getBeanInfoSearchPath()
public static void setBeanInfoSearchPath(java.lang.String[] path)
path
- the new search packages to be set.