/* java.beans.FeatureDescriptor
- Copyright (C) 1998 Free Software Foundation, Inc.
+ Copyright (C) 1998, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
*
* @author John Keiser
* @since 1.1
- * @version 1.1.0, 31 May 1998
*/
public class FeatureDescriptor
/**
* Get the localized (display) name of this feature.
+ *
+ * @returns The localized display name of this feature or falls
+ * back to the programmatic name.
*/
public String getDisplayName()
{
- return displayName;
+ return (displayName == null) ? name : displayName;
}
/**
/**
* Get the localized short description for this feature.
+ *
+ * @returns A short localized description of this feature or
+ * what <code>getDisplayName</code> returns in case, that no short description
+ * is available.
*/
public String getShortDescription()
{
- return shortDescription;
+ return (shortDescription == null) ? getDisplayName() : shortDescription;
}
/**
public static void flushCaches()
{
beanInfoCache.clear();
+
+ // Clears all the intermediate ExplicitInfo instances which
+ // have been created.
+ // This makes sure we have to retrieve stuff like BeanDescriptors
+ // again. (Remember that FeatureDescriptor can be modified by the user.)
+ ExplicitInfo.flushCaches();
}
/**
public static BeanInfo getBeanInfo(Class beanClass, Class stopClass)
throws IntrospectionException
{
- ExplicitInfo explicit = new ExplicitInfo(beanClass,stopClass);
-
+ ExplicitInfo explicit = new ExplicitInfo(beanClass, stopClass);
+
IntrospectionIncubator ii = new IntrospectionIncubator();
ii.setPropertyStopClass(explicit.propertyStopClass);
ii.setEventStopClass(explicit.eventStopClass);
}
}
- if(explicit.explicitBeanDescriptor != null)
- {
- currentInfo.setBeanDescriptor(new BeanDescriptor(beanClass,explicit.explicitBeanDescriptor.getCustomizerClass()));
- }
- else
- {
- currentInfo.setBeanDescriptor(new BeanDescriptor(beanClass,null));
- }
-
+ // Sets the info's BeanDescriptor to the one we extracted from the
+ // explicit BeanInfo instance(s) if they contained one. Otherwise we
+ // create the BeanDescriptor from scratch.
+ // Note: We do not create a copy the retrieved BeanDescriptor which will allow
+ // the user to modify the instance while it is cached. However this is how
+ // the RI does it.
+ currentInfo.setBeanDescriptor(
+ (explicit.explicitBeanDescriptor == null ?
+ new BeanDescriptor(beanClass, null) :
+ explicit.explicitBeanDescriptor));
+
currentInfo.setAdditionalBeanInfo(explicit.explicitBeanInfo);
currentInfo.setIcons(explicit.im);
return null;
}
}
-
+
static BeanInfo copyBeanInfo(BeanInfo b)
{
java.awt.Image[] icons = new java.awt.Image[4];
{
icons[i-1] = b.getIcon(i);
}
+
return new ExplicitBeanInfo(b.getBeanDescriptor(),
b.getAdditionalBeanInfo(),
b.getPropertyDescriptors(),
b.getDefaultPropertyIndex(),
b.getEventSetDescriptors(),
b.getDefaultEventIndex(),
- b.getMethodDescriptors(),icons);
+ b.getMethodDescriptors(),
+ icons);
}
}
Class propertyStopClass;
Class eventStopClass;
Class methodStopClass;
-
+
+ static Hashtable explicitBeanInfos = new Hashtable();
+ static Vector emptyBeanInfos = new Vector();
+
ExplicitInfo(Class beanClass, Class stopClass)
{
while(beanClass != null && !beanClass.equals(stopClass))
{
+
BeanInfo explicit = findExplicitBeanInfo(beanClass);
+
+
if(explicit != null)
{
+
if(explicitBeanDescriptor == null)
{
explicitBeanDescriptor = explicit.getBeanDescriptor();
}
+
if(explicitBeanInfo == null)
{
explicitBeanInfo = explicit.getAdditionalBeanInfo();
}
+
if(explicitPropertyDescriptors == null)
{
if(explicit.getPropertyDescriptors() != null)
propertyStopClass = beanClass;
}
}
+
if(explicitEventSetDescriptors == null)
{
if(explicit.getEventSetDescriptors() != null)
eventStopClass = beanClass;
}
}
+
if(explicitMethodDescriptors == null)
{
if(explicit.getMethodDescriptors() != null)
methodStopClass = beanClass;
}
}
+
if(im[0] == null && im[1] == null
&& im[2] == null && im[3] == null)
{
}
beanClass = beanClass.getSuperclass();
}
+
if(propertyStopClass == null)
{
propertyStopClass = stopClass;
}
+
if(eventStopClass == null)
{
eventStopClass = stopClass;
}
+
if(methodStopClass == null)
{
methodStopClass = stopClass;
}
}
- static Hashtable explicitBeanInfos = new Hashtable();
- static Vector emptyBeanInfos = new Vector();
+ /** Throws away all cached data and makes sure we re-instantiate things
+ * like BeanDescriptors again.
+ */
+ static void flushCaches() {
+ explicitBeanInfos.clear();
+ emptyBeanInfos.clear();
+ }
static BeanInfo findExplicitBeanInfo(Class beanClass)
{
Introspector.beanInfoSearchPath[i] + "."
+ newName);
- if (beanInfo != null)
+ // Returns the beanInfo if it exists and the described class matches
+ // the one we searched.
+ if (beanInfo != null && beanInfo.getBeanDescriptor() != null &&
+ beanInfo.getBeanDescriptor().getBeanClass() == beanClass)
+
return beanInfo;
- }
+ }
}
return beanInfo;