Home » openjdk-7 » java » beans » [javadoc | source]
java.beans
public class: Introspector [javadoc | source]
java.lang.Object
   java.beans.Introspector
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).

For more information about introspection and design patterns, please consult the JavaBeans™ specification.
Field Summary
public static final  int USE_ALL_BEANINFO     
public static final  int IGNORE_IMMEDIATE_BEANINFO     
public static final  int IGNORE_ALL_BEANINFO     
static final  String ADD_PREFIX     
static final  String REMOVE_PREFIX     
static final  String GET_PREFIX     
static final  String SET_PREFIX     
static final  String IS_PREFIX     
Method from java.beans.Introspector Summary:
decapitalize,   findMethod,   findMethod,   flushCaches,   flushFromCaches,   getBeanInfo,   getBeanInfo,   getBeanInfo,   getBeanInfo,   getBeanInfoSearchPath,   instantiate,   isSubclass,   setBeanInfoSearchPath
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from java.beans.Introspector Detail:
 public static String decapitalize(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".

 static Method findMethod(Class cls,
    String methodName,
    int argCount) 
    Find a target methodName on a given class.
 static Method findMethod(Class cls,
    String methodName,
    int argCount,
    Class[] args) 
    Find a target methodName with specific parameter list on a given class.

    Used in the contructors of the EventSetDescriptor, PropertyDescriptor and the IndexedPropertyDescriptor.

 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.
 public static  void flushFromCaches(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.
 public static BeanInfo getBeanInfo(Class<?> beanClass) throws 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.

 public static BeanInfo getBeanInfo(Class<?> beanClass,
    int flags) throws 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.

 public static BeanInfo getBeanInfo(Class<?> beanClass,
    Class<?> stopClass) throws 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.

 public static BeanInfo getBeanInfo(Class<?> beanClass,
    Class<?> stopClass,
    int flags) throws IntrospectionException 
    Introspect on a Java Bean and learn about all its properties, exposed methods and events, below a given {@code stopClass} point subject to some control {@code flags}.
    USE_ALL_BEANINFO
    Any BeanInfo that can be discovered will be used.
    IGNORE_IMMEDIATE_BEANINFO
    Any BeanInfo associated with the specified {@code beanClass} will be ignored.
    IGNORE_ALL_BEANINFO
    Any BeanInfo associated with the specified {@code beanClass} or any of its parent classes will be ignored.
    Any methods/properties/events in the {@code stopClass} or in its parent classes will be ignored in the analysis.

    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.

 public static String[] getBeanInfoSearchPath() 
    Gets the list of package names that will be used for finding BeanInfo classes.
 static Object instantiate(Class sibling,
    String className) throws InstantiationException, IllegalAccessException, ClassNotFoundException 
    Try to create an instance of a named class. First try the classloader of "sibling", then try the system classloader then the class loader of the current Thread.
 static boolean isSubclass(Class a,
    Class b) 
    Return true if class a is either equivalent to class b, or if class a is a subclass of class b, i.e. if a either "extends" or "implements" b. Note tht either or both "Class" objects may represent interfaces.
 public static  void setBeanInfoSearchPath(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.