java.beans
Class Introspector

java.lang.Object sample code for java.lang.Object definition code for java.lang.Object 
  extended by java.beans.Introspector

public class Introspector
extends Object sample code for java.lang.Object definition code for java.lang.Object

The Introspector class provides a standard way for tools to learn about the properties, events, and methods supported by a target Java Bean.

For each of those three kinds of information, the Introspector will separately analyze the bean's class and superclasses looking for either explicit or implicit information and use that information to build a BeanInfo object that comprehensively describes the target bean.

For each class "Foo", explicit information may be available if there exists a corresponding "FooBeanInfo" class that provides a non-null value when queried for the information. We first look for the BeanInfo class by taking the full package-qualified name of the target bean class and appending "BeanInfo" to form a new class name. If this fails, then we take the final classname component of this name, and look for that class in each of the packages specified in the BeanInfo package search path.

Thus for a class such as "sun.xyz.OurButton" we would first look for a BeanInfo class called "sun.xyz.OurButtonBeanInfo" and if that failed we'd look in each package in the BeanInfo search path for an OurButtonBeanInfo class. With the default search path, this would mean looking for "sun.beans.infos.OurButtonBeanInfo".

If a class provides explicit BeanInfo about itself then we add that to the BeanInfo information we obtained from analyzing any derived classes, but we regard the explicit information as being definitive for the current class and its base classes, and do not proceed any further up the superclass chain.

If we don't find explicit BeanInfo on a class, we use low-level reflection to study the methods of the class and apply standard design patterns to identify property accessors, event sources, or public methods. We then proceed to analyze the class's superclass and add in the information from it (and possibly on up the superclass chain).

Because the Introspector caches BeanInfo classes for better performance, take care if you use it in an application that uses multiple class loaders. In general, when you destroy a ClassLoader that has been used to introspect classes, you should use the Introspector.flushCaches sample code for java.beans.Introspector.flushCaches() definition code for java.beans.Introspector.flushCaches() or Introspector.flushFromCaches sample code for java.beans.Introspector.flushFromCaches(java.lang.Class) definition code for java.beans.Introspector.flushFromCaches(java.lang.Class) method to flush all of the introspected classes out of the cache.

For more information about introspection and design patterns, please consult the JavaBeans specification.


Field Summary
static int IGNORE_ALL_BEANINFO sample code for java.beans.Introspector.IGNORE_ALL_BEANINFO definition code for java.beans.Introspector.IGNORE_ALL_BEANINFO
           
static int IGNORE_IMMEDIATE_BEANINFO sample code for java.beans.Introspector.IGNORE_IMMEDIATE_BEANINFO definition code for java.beans.Introspector.IGNORE_IMMEDIATE_BEANINFO
           
static int USE_ALL_BEANINFO sample code for java.beans.Introspector.USE_ALL_BEANINFO definition code for java.beans.Introspector.USE_ALL_BEANINFO
           
 
Method Summary
static String sample code for java.lang.String definition code for java.lang.String decapitalize sample code for java.beans.Introspector.decapitalize(java.lang.String) definition code for java.beans.Introspector.decapitalize(java.lang.String) (String sample code for java.lang.String definition code for java.lang.String  name)
          Utility method to take a string and convert it to normal Java variable name capitalization.
static void flushCaches sample code for java.beans.Introspector.flushCaches() definition code for java.beans.Introspector.flushCaches() ()
          Flush all of the Introspector's internal caches.
static void flushFromCaches sample code for java.beans.Introspector.flushFromCaches(java.lang.Class) definition code for java.beans.Introspector.flushFromCaches(java.lang.Class) (Class sample code for java.lang.Class definition code for java.lang.Class <?> clz)
          Flush the Introspector's internal cached information for a given class.
static BeanInfo sample code for java.beans.BeanInfo definition code for java.beans.BeanInfo getBeanInfo sample code for java.beans.Introspector.getBeanInfo(java.lang.Class) definition code for java.beans.Introspector.getBeanInfo(java.lang.Class) (Class sample code for java.lang.Class definition code for java.lang.Class <?> beanClass)
          Introspect on a Java Bean and learn about all its properties, exposed methods, and events.
static BeanInfo sample code for java.beans.BeanInfo definition code for java.beans.BeanInfo getBeanInfo sample code for java.beans.Introspector.getBeanInfo(java.lang.Class, java.lang.Class) definition code for java.beans.Introspector.getBeanInfo(java.lang.Class, java.lang.Class) (Class sample code for java.lang.Class definition code for java.lang.Class <?> beanClass, Class sample code for java.lang.Class definition code for java.lang.Class <?> stopClass)
          Introspect on a Java bean and learn all about its properties, exposed methods, below a given "stop" point.
static BeanInfo sample code for java.beans.BeanInfo definition code for java.beans.BeanInfo getBeanInfo sample code for java.beans.Introspector.getBeanInfo(java.lang.Class, int) definition code for java.beans.Introspector.getBeanInfo(java.lang.Class, int) (Class sample code for java.lang.Class definition code for java.lang.Class <?> beanClass, int flags)
          Introspect on a Java bean and learn about all its properties, exposed methods, and events, subject to some control flags.
static String sample code for java.lang.String definition code for java.lang.String [] getBeanInfoSearchPath sample code for java.beans.Introspector.getBeanInfoSearchPath() definition code for java.beans.Introspector.getBeanInfoSearchPath() ()
          Gets the list of package names that will be used for finding BeanInfo classes.
static void setBeanInfoSearchPath sample code for java.beans.Introspector.setBeanInfoSearchPath(java.lang.String[]) definition code for java.beans.Introspector.setBeanInfoSearchPath(java.lang.String[]) (String sample code for java.lang.String definition code for java.lang.String [] path)
          Change the list of package names that will be used for finding BeanInfo classes.
 
Methods inherited from class java.lang.Object sample code for java.lang.Object definition code for java.lang.Object
clone sample code for java.lang.Object.clone() definition code for java.lang.Object.clone() , equals sample code for java.lang.Object.equals(java.lang.Object) definition code for java.lang.Object.equals(java.lang.Object) , finalize sample code for java.lang.Object.finalize() definition code for java.lang.Object.finalize() , getClass sample code for java.lang.Object.getClass() definition code for java.lang.Object.getClass() , hashCode sample code for java.lang.Object.hashCode() definition code for java.lang.Object.hashCode() , notify sample code for java.lang.Object.notify() definition code for java.lang.Object.notify() , notifyAll sample code for java.lang.Object.notifyAll() definition code for java.lang.Object.notifyAll() , toString sample code for java.lang.Object.toString() definition code for java.lang.Object.toString() , wait sample code for java.lang.Object.wait() definition code for java.lang.Object.wait() , wait sample code for java.lang.Object.wait(long) definition code for java.lang.Object.wait(long) , wait sample code for java.lang.Object.wait(long, int) definition code for java.lang.Object.wait(long, int)
 

Field Detail

USE_ALL_BEANINFO sample code for java.beans.Introspector.USE_ALL_BEANINFO

public static final int USE_ALL_BEANINFO
See Also:
Constant Field Values

IGNORE_IMMEDIATE_BEANINFO sample code for java.beans.Introspector.IGNORE_IMMEDIATE_BEANINFO

public static final int IGNORE_IMMEDIATE_BEANINFO
See Also:
Constant Field Values

IGNORE_ALL_BEANINFO sample code for java.beans.Introspector.IGNORE_ALL_BEANINFO

public static final int IGNORE_ALL_BEANINFO
See Also:
Constant Field Values
Method Detail

getBeanInfo sample code for java.beans.Introspector.getBeanInfo(java.lang.Class<?>) definition code for java.beans.Introspector.getBeanInfo(java.lang.Class<?>)

public static BeanInfo sample code for java.beans.BeanInfo definition code for java.beans.BeanInfo  getBeanInfo(Class sample code for java.lang.Class definition code for java.lang.Class <?> beanClass)
                            throws IntrospectionException sample code for java.beans.IntrospectionException definition code for java.beans.IntrospectionException 
Introspect on a Java Bean and learn about all its properties, exposed methods, and events.

If the BeanInfo class for a Java Bean has been previously Introspected then the BeanInfo class is retrieved from the BeanInfo cache.

Parameters:
beanClass - The bean class to be analyzed.
Returns:
A BeanInfo object describing the target bean.
Throws:
IntrospectionException sample code for java.beans.IntrospectionException definition code for java.beans.IntrospectionException - if an exception occurs during introspection.
See Also:
flushCaches() sample code for java.beans.Introspector.flushCaches() definition code for java.beans.Introspector.flushCaches() , flushFromCaches(java.lang.Class) sample code for java.beans.Introspector.flushFromCaches(java.lang.Class) definition code for java.beans.Introspector.flushFromCaches(java.lang.Class)

getBeanInfo sample code for java.beans.Introspector.getBeanInfo(java.lang.Class<?>, int) definition code for java.beans.Introspector.getBeanInfo(java.lang.Class<?>, int)

public static BeanInfo sample code for java.beans.BeanInfo definition code for java.beans.BeanInfo  getBeanInfo(Class sample code for java.lang.Class definition code for java.lang.Class <?> beanClass,
                                   int flags)
                            throws IntrospectionException sample code for java.beans.IntrospectionException definition code for java.beans.IntrospectionException 
Introspect on a Java bean and learn about all its properties, exposed methods, and events, subject to some control flags.

If the BeanInfo class for a Java Bean has been previously Introspected based on the same arguments then the BeanInfo class is retrieved from the BeanInfo cache.

Parameters:
beanClass - The bean class to be analyzed.
flags - Flags to control the introspection. If flags == USE_ALL_BEANINFO then we use all of the BeanInfo classes we can discover. If flags == IGNORE_IMMEDIATE_BEANINFO then we ignore any BeanInfo associated with the specified beanClass. If flags == IGNORE_ALL_BEANINFO then we ignore all BeanInfo associated with the specified beanClass or any of its parent classes.
Returns:
A BeanInfo object describing the target bean.
Throws:
IntrospectionException sample code for java.beans.IntrospectionException definition code for java.beans.IntrospectionException - if an exception occurs during introspection.

getBeanInfo sample code for java.beans.Introspector.getBeanInfo(java.lang.Class<?>, java.lang.Class<?>) definition code for java.beans.Introspector.getBeanInfo(java.lang.Class<?>, java.lang.Class<?>)

public static BeanInfo sample code for java.beans.BeanInfo definition code for java.beans.BeanInfo  getBeanInfo(Class sample code for java.lang.Class definition code for java.lang.Class <?> beanClass,
                                   Class sample code for java.lang.Class definition code for java.lang.Class <?> stopClass)
                            throws IntrospectionException sample code for java.beans.IntrospectionException definition code for java.beans.IntrospectionException 
Introspect on a Java bean and learn all about its properties, exposed methods, below a given "stop" point.

If the BeanInfo class for a Java Bean has been previously Introspected based on the same arguments, then the BeanInfo class is retrieved from the BeanInfo cache.

Parameters:
beanClass - The bean class to be analyzed.
stopClass - The baseclass at which to stop the analysis. Any methods/properties/events in the stopClass or in its baseclasses will be ignored in the analysis.
Throws:
IntrospectionException sample code for java.beans.IntrospectionException definition code for java.beans.IntrospectionException - if an exception occurs during introspection.

decapitalize sample code for java.beans.Introspector.decapitalize(java.lang.String) definition code for java.beans.Introspector.decapitalize(java.lang.String)

public static String sample code for java.lang.String definition code for java.lang.String  decapitalize(String sample code for java.lang.String definition code for java.lang.String  name)
Utility method to take a string and convert it to normal Java variable name capitalization. This normally means converting the first character from upper case to lower case, but in the (unusual) special case when there is more than one character and both the first and second characters are upper case, we leave it alone.

Thus "FooBah" becomes "fooBah" and "X" becomes "x", but "URL" stays as "URL".

Parameters:
name - The string to be decapitalized.
Returns:
The decapitalized version of the string.

getBeanInfoSearchPath sample code for java.beans.Introspector.getBeanInfoSearchPath() definition code for java.beans.Introspector.getBeanInfoSearchPath()

public static String sample code for java.lang.String definition code for java.lang.String [] getBeanInfoSearchPath()
Gets the list of package names that will be used for finding BeanInfo classes.

Returns:
The array of package names that will be searched in order to find BeanInfo classes. The default value for this array is implementation-dependent; e.g. Sun implementation initially sets to {"sun.beans.infos"}.

setBeanInfoSearchPath sample code for java.beans.Introspector.setBeanInfoSearchPath(java.lang.String[]) definition code for java.beans.Introspector.setBeanInfoSearchPath(java.lang.String[])

public static void setBeanInfoSearchPath(String sample code for java.lang.String definition code for java.lang.String [] path)
Change the list of package names that will be used for finding BeanInfo classes. The behaviour of this method is undefined if parameter path is null.

First, if there is a security manager, its checkPropertiesAccess method is called. This could result in a SecurityException.

Parameters:
path - Array of package names.
Throws:
SecurityException sample code for java.lang.SecurityException definition code for java.lang.SecurityException - if a security manager exists and its checkPropertiesAccess method doesn't allow setting of system properties.
See Also:
SecurityManager.checkPropertiesAccess() sample code for java.lang.SecurityManager.checkPropertiesAccess() definition code for java.lang.SecurityManager.checkPropertiesAccess()

flushCaches sample code for java.beans.Introspector.flushCaches() definition code for java.beans.Introspector.flushCaches()

public static void flushCaches()
Flush all of the Introspector's internal caches. This method is not normally required. It is normally only needed by advanced tools that update existing "Class" objects in-place and need to make the Introspector re-analyze existing Class objects.


flushFromCaches sample code for java.beans.Introspector.flushFromCaches(java.lang.Class<?>) definition code for java.beans.Introspector.flushFromCaches(java.lang.Class<?>)

public static void flushFromCaches(Class sample code for java.lang.Class definition code for java.lang.Class <?> clz)
Flush the Introspector's internal cached information for a given class. This method is not normally required. It is normally only needed by advanced tools that update existing "Class" objects in-place and need to make the Introspector re-analyze an existing Class object. Note that only the direct state associated with the target Class object is flushed. We do not flush state for other Class objects with the same name, nor do we flush state for any related Class objects (such as subclasses), even though their state may include information indirectly obtained from the target Class object.

Parameters:
clz - Class object to be flushed.
Throws:
NullPointerException sample code for java.lang.NullPointerException definition code for java.lang.NullPointerException - If the Class object is null.