2005-04-29 Robert Schuster <thebohemian@gmx.net>
* java/beans/FeatureDescriptor.java: (getShortDescription): Implemented fallback mechanism and fixed documentation (fixes bug #12637). (getDisplayName): Dito. 2005-04-29 Robert Schuster <thebohemian@gmx.net> * java/beans/Introspector.java: Fixed bug #12624, BeanDescriptors will now be set correctly. (flushCaches): Now flushes all cached intermediate data. From-SVN: r98975
This commit is contained in:
parent
1a7bfcc32d
commit
7789e4818a
3 changed files with 75 additions and 22 deletions
|
@ -1,3 +1,16 @@
|
||||||
|
2005-04-29 Robert Schuster <thebohemian@gmx.net>
|
||||||
|
|
||||||
|
* java/beans/FeatureDescriptor.java:
|
||||||
|
(getShortDescription): Implemented fallback mechanism and fixed
|
||||||
|
documentation (fixes bug #12637).
|
||||||
|
(getDisplayName): Dito.
|
||||||
|
|
||||||
|
2005-04-29 Robert Schuster <thebohemian@gmx.net>
|
||||||
|
|
||||||
|
* java/beans/Introspector.java: Fixed bug #12624, BeanDescriptors
|
||||||
|
will now be set correctly.
|
||||||
|
(flushCaches): Now flushes all cached intermediate data.
|
||||||
|
|
||||||
2005-04-28 Michael Koch <konqueror@gmx.de>
|
2005-04-28 Michael Koch <konqueror@gmx.de>
|
||||||
|
|
||||||
* java/net/InetAddress.java
|
* java/net/InetAddress.java
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/* java.beans.FeatureDescriptor
|
/* 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.
|
This file is part of GNU Classpath.
|
||||||
|
|
||||||
|
@ -57,7 +57,6 @@ import java.util.Hashtable;
|
||||||
*
|
*
|
||||||
* @author John Keiser
|
* @author John Keiser
|
||||||
* @since 1.1
|
* @since 1.1
|
||||||
* @version 1.1.0, 31 May 1998
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class FeatureDescriptor
|
public class FeatureDescriptor
|
||||||
|
@ -99,10 +98,13 @@ public class FeatureDescriptor
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the localized (display) name of this feature.
|
* 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()
|
public String getDisplayName()
|
||||||
{
|
{
|
||||||
return displayName;
|
return (displayName == null) ? name : displayName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -117,10 +119,14 @@ public class FeatureDescriptor
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the localized short description for this feature.
|
* 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()
|
public String getShortDescription()
|
||||||
{
|
{
|
||||||
return shortDescription;
|
return (shortDescription == null) ? getDisplayName() : shortDescription;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -220,6 +220,12 @@ public class Introspector {
|
||||||
public static void flushCaches()
|
public static void flushCaches()
|
||||||
{
|
{
|
||||||
beanInfoCache.clear();
|
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();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -252,8 +258,8 @@ public class Introspector {
|
||||||
public static BeanInfo getBeanInfo(Class beanClass, Class stopClass)
|
public static BeanInfo getBeanInfo(Class beanClass, Class stopClass)
|
||||||
throws IntrospectionException
|
throws IntrospectionException
|
||||||
{
|
{
|
||||||
ExplicitInfo explicit = new ExplicitInfo(beanClass,stopClass);
|
ExplicitInfo explicit = new ExplicitInfo(beanClass, stopClass);
|
||||||
|
|
||||||
IntrospectionIncubator ii = new IntrospectionIncubator();
|
IntrospectionIncubator ii = new IntrospectionIncubator();
|
||||||
ii.setPropertyStopClass(explicit.propertyStopClass);
|
ii.setPropertyStopClass(explicit.propertyStopClass);
|
||||||
ii.setEventStopClass(explicit.eventStopClass);
|
ii.setEventStopClass(explicit.eventStopClass);
|
||||||
|
@ -303,15 +309,17 @@ public class Introspector {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(explicit.explicitBeanDescriptor != null)
|
// Sets the info's BeanDescriptor to the one we extracted from the
|
||||||
{
|
// explicit BeanInfo instance(s) if they contained one. Otherwise we
|
||||||
currentInfo.setBeanDescriptor(new BeanDescriptor(beanClass,explicit.explicitBeanDescriptor.getCustomizerClass()));
|
// create the BeanDescriptor from scratch.
|
||||||
}
|
// Note: We do not create a copy the retrieved BeanDescriptor which will allow
|
||||||
else
|
// the user to modify the instance while it is cached. However this is how
|
||||||
{
|
// the RI does it.
|
||||||
currentInfo.setBeanDescriptor(new BeanDescriptor(beanClass,null));
|
currentInfo.setBeanDescriptor(
|
||||||
}
|
(explicit.explicitBeanDescriptor == null ?
|
||||||
|
new BeanDescriptor(beanClass, null) :
|
||||||
|
explicit.explicitBeanDescriptor));
|
||||||
|
|
||||||
currentInfo.setAdditionalBeanInfo(explicit.explicitBeanInfo);
|
currentInfo.setAdditionalBeanInfo(explicit.explicitBeanInfo);
|
||||||
currentInfo.setIcons(explicit.im);
|
currentInfo.setIcons(explicit.im);
|
||||||
|
|
||||||
|
@ -388,7 +396,7 @@ public class Introspector {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static BeanInfo copyBeanInfo(BeanInfo b)
|
static BeanInfo copyBeanInfo(BeanInfo b)
|
||||||
{
|
{
|
||||||
java.awt.Image[] icons = new java.awt.Image[4];
|
java.awt.Image[] icons = new java.awt.Image[4];
|
||||||
|
@ -396,13 +404,15 @@ public class Introspector {
|
||||||
{
|
{
|
||||||
icons[i-1] = b.getIcon(i);
|
icons[i-1] = b.getIcon(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ExplicitBeanInfo(b.getBeanDescriptor(),
|
return new ExplicitBeanInfo(b.getBeanDescriptor(),
|
||||||
b.getAdditionalBeanInfo(),
|
b.getAdditionalBeanInfo(),
|
||||||
b.getPropertyDescriptors(),
|
b.getPropertyDescriptors(),
|
||||||
b.getDefaultPropertyIndex(),
|
b.getDefaultPropertyIndex(),
|
||||||
b.getEventSetDescriptors(),
|
b.getEventSetDescriptors(),
|
||||||
b.getDefaultEventIndex(),
|
b.getDefaultEventIndex(),
|
||||||
b.getMethodDescriptors(),icons);
|
b.getMethodDescriptors(),
|
||||||
|
icons);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -423,22 +433,31 @@ class ExplicitInfo
|
||||||
Class propertyStopClass;
|
Class propertyStopClass;
|
||||||
Class eventStopClass;
|
Class eventStopClass;
|
||||||
Class methodStopClass;
|
Class methodStopClass;
|
||||||
|
|
||||||
|
static Hashtable explicitBeanInfos = new Hashtable();
|
||||||
|
static Vector emptyBeanInfos = new Vector();
|
||||||
|
|
||||||
ExplicitInfo(Class beanClass, Class stopClass)
|
ExplicitInfo(Class beanClass, Class stopClass)
|
||||||
{
|
{
|
||||||
while(beanClass != null && !beanClass.equals(stopClass))
|
while(beanClass != null && !beanClass.equals(stopClass))
|
||||||
{
|
{
|
||||||
|
|
||||||
BeanInfo explicit = findExplicitBeanInfo(beanClass);
|
BeanInfo explicit = findExplicitBeanInfo(beanClass);
|
||||||
|
|
||||||
|
|
||||||
if(explicit != null)
|
if(explicit != null)
|
||||||
{
|
{
|
||||||
|
|
||||||
if(explicitBeanDescriptor == null)
|
if(explicitBeanDescriptor == null)
|
||||||
{
|
{
|
||||||
explicitBeanDescriptor = explicit.getBeanDescriptor();
|
explicitBeanDescriptor = explicit.getBeanDescriptor();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(explicitBeanInfo == null)
|
if(explicitBeanInfo == null)
|
||||||
{
|
{
|
||||||
explicitBeanInfo = explicit.getAdditionalBeanInfo();
|
explicitBeanInfo = explicit.getAdditionalBeanInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(explicitPropertyDescriptors == null)
|
if(explicitPropertyDescriptors == null)
|
||||||
{
|
{
|
||||||
if(explicit.getPropertyDescriptors() != null)
|
if(explicit.getPropertyDescriptors() != null)
|
||||||
|
@ -448,6 +467,7 @@ class ExplicitInfo
|
||||||
propertyStopClass = beanClass;
|
propertyStopClass = beanClass;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(explicitEventSetDescriptors == null)
|
if(explicitEventSetDescriptors == null)
|
||||||
{
|
{
|
||||||
if(explicit.getEventSetDescriptors() != null)
|
if(explicit.getEventSetDescriptors() != null)
|
||||||
|
@ -457,6 +477,7 @@ class ExplicitInfo
|
||||||
eventStopClass = beanClass;
|
eventStopClass = beanClass;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(explicitMethodDescriptors == null)
|
if(explicitMethodDescriptors == null)
|
||||||
{
|
{
|
||||||
if(explicit.getMethodDescriptors() != null)
|
if(explicit.getMethodDescriptors() != null)
|
||||||
|
@ -465,6 +486,7 @@ class ExplicitInfo
|
||||||
methodStopClass = beanClass;
|
methodStopClass = beanClass;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(im[0] == null && im[1] == null
|
if(im[0] == null && im[1] == null
|
||||||
&& im[2] == null && im[3] == null)
|
&& im[2] == null && im[3] == null)
|
||||||
{
|
{
|
||||||
|
@ -476,22 +498,30 @@ class ExplicitInfo
|
||||||
}
|
}
|
||||||
beanClass = beanClass.getSuperclass();
|
beanClass = beanClass.getSuperclass();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(propertyStopClass == null)
|
if(propertyStopClass == null)
|
||||||
{
|
{
|
||||||
propertyStopClass = stopClass;
|
propertyStopClass = stopClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(eventStopClass == null)
|
if(eventStopClass == null)
|
||||||
{
|
{
|
||||||
eventStopClass = stopClass;
|
eventStopClass = stopClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(methodStopClass == null)
|
if(methodStopClass == null)
|
||||||
{
|
{
|
||||||
methodStopClass = stopClass;
|
methodStopClass = stopClass;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static Hashtable explicitBeanInfos = new Hashtable();
|
/** Throws away all cached data and makes sure we re-instantiate things
|
||||||
static Vector emptyBeanInfos = new Vector();
|
* like BeanDescriptors again.
|
||||||
|
*/
|
||||||
|
static void flushCaches() {
|
||||||
|
explicitBeanInfos.clear();
|
||||||
|
emptyBeanInfos.clear();
|
||||||
|
}
|
||||||
|
|
||||||
static BeanInfo findExplicitBeanInfo(Class beanClass)
|
static BeanInfo findExplicitBeanInfo(Class beanClass)
|
||||||
{
|
{
|
||||||
|
@ -539,9 +569,13 @@ class ExplicitInfo
|
||||||
Introspector.beanInfoSearchPath[i] + "."
|
Introspector.beanInfoSearchPath[i] + "."
|
||||||
+ newName);
|
+ 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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return beanInfo;
|
return beanInfo;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue