/[classpath]/classpath/java/beans/Introspector.java
ViewVC logotype

Diff of /classpath/java/beans/Introspector.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.17.2.1 by gnu_andrew, Sat Jan 15 17:01:50 2005 UTC revision 1.17.2.2 by gnu_andrew, Thu Apr 28 23:00:12 2005 UTC
# Line 220  public class Introspector { Line 220  public class Introspector {
220    public static void flushCaches()    public static void flushCaches()
221    {    {
222      beanInfoCache.clear();      beanInfoCache.clear();
223    
224            // Clears all the intermediate ExplicitInfo instances which
225            // have been created.
226            // This makes sure we have to retrieve stuff like BeanDescriptors
227            // again. (Remember that FeatureDescriptor can be modified by the user.)
228            ExplicitInfo.flushCaches();
229    }    }
230    
231    /**    /**
# Line 252  public class Introspector { Line 258  public class Introspector {
258    public static BeanInfo getBeanInfo(Class beanClass, Class stopClass)    public static BeanInfo getBeanInfo(Class beanClass, Class stopClass)
259      throws IntrospectionException      throws IntrospectionException
260    {    {
261      ExplicitInfo explicit = new ExplicitInfo(beanClass,stopClass);      ExplicitInfo explicit = new ExplicitInfo(beanClass, stopClass);
262        
263      IntrospectionIncubator ii = new IntrospectionIncubator();      IntrospectionIncubator ii = new IntrospectionIncubator();
264      ii.setPropertyStopClass(explicit.propertyStopClass);      ii.setPropertyStopClass(explicit.propertyStopClass);
265      ii.setEventStopClass(explicit.eventStopClass);      ii.setEventStopClass(explicit.eventStopClass);
# Line 303  public class Introspector { Line 309  public class Introspector {
309            }            }
310        }        }
311            
312      if(explicit.explicitBeanDescriptor != null)          // Sets the info's BeanDescriptor to the one we extracted from the
313        {          // explicit BeanInfo instance(s) if they contained one. Otherwise we
314          currentInfo.setBeanDescriptor(new BeanDescriptor(beanClass,explicit.explicitBeanDescriptor.getCustomizerClass()));          // create the BeanDescriptor from scratch.
315        }          // Note: We do not create a copy the retrieved BeanDescriptor which will allow
316      else          // the user to modify the instance while it is cached. However this is how
317        {          // the RI does it.
318          currentInfo.setBeanDescriptor(new BeanDescriptor(beanClass,null));          currentInfo.setBeanDescriptor(
319        }                  (explicit.explicitBeanDescriptor == null ?
320                                new BeanDescriptor(beanClass, null) :
321                            explicit.explicitBeanDescriptor));
322    
323      currentInfo.setAdditionalBeanInfo(explicit.explicitBeanInfo);      currentInfo.setAdditionalBeanInfo(explicit.explicitBeanInfo);
324      currentInfo.setIcons(explicit.im);      currentInfo.setIcons(explicit.im);
325            
# Line 388  public class Introspector { Line 396  public class Introspector {
396          return null;          return null;
397        }        }
398    }    }
399      
400    static BeanInfo copyBeanInfo(BeanInfo b)    static BeanInfo copyBeanInfo(BeanInfo b)
401    {    {
402      java.awt.Image[] icons = new java.awt.Image[4];      java.awt.Image[] icons = new java.awt.Image[4];
# Line 396  public class Introspector { Line 404  public class Introspector {
404        {        {
405          icons[i-1] = b.getIcon(i);          icons[i-1] = b.getIcon(i);
406        }        }
407    
408      return new ExplicitBeanInfo(b.getBeanDescriptor(),      return new ExplicitBeanInfo(b.getBeanDescriptor(),
409                                  b.getAdditionalBeanInfo(),                                  b.getAdditionalBeanInfo(),
410                                  b.getPropertyDescriptors(),                                  b.getPropertyDescriptors(),
411                                  b.getDefaultPropertyIndex(),                                  b.getDefaultPropertyIndex(),
412                                  b.getEventSetDescriptors(),                                  b.getEventSetDescriptors(),
413                                  b.getDefaultEventIndex(),                                  b.getDefaultEventIndex(),
414                                  b.getMethodDescriptors(),icons);                                  b.getMethodDescriptors(),
415                                    icons);
416    }    }
417  }  }
418    
# Line 423  class ExplicitInfo Line 433  class ExplicitInfo
433    Class propertyStopClass;    Class propertyStopClass;
434    Class eventStopClass;    Class eventStopClass;
435    Class methodStopClass;    Class methodStopClass;
436      
437      static Hashtable explicitBeanInfos = new Hashtable();
438      static Vector emptyBeanInfos = new Vector();
439    
440    ExplicitInfo(Class beanClass, Class stopClass)    ExplicitInfo(Class beanClass, Class stopClass)
441    {    {
442      while(beanClass != null && !beanClass.equals(stopClass))      while(beanClass != null && !beanClass.equals(stopClass))
443        {        {
444    
445          BeanInfo explicit = findExplicitBeanInfo(beanClass);          BeanInfo explicit = findExplicitBeanInfo(beanClass);
446            
447    
448          if(explicit != null)          if(explicit != null)
449            {            {
450    
451              if(explicitBeanDescriptor == null)              if(explicitBeanDescriptor == null)
452                {                {
453                  explicitBeanDescriptor = explicit.getBeanDescriptor();                  explicitBeanDescriptor = explicit.getBeanDescriptor();
454                }                }
455    
456              if(explicitBeanInfo == null)              if(explicitBeanInfo == null)
457                {                {
458                  explicitBeanInfo = explicit.getAdditionalBeanInfo();                  explicitBeanInfo = explicit.getAdditionalBeanInfo();
459                }                }
460    
461              if(explicitPropertyDescriptors == null)              if(explicitPropertyDescriptors == null)
462                {                {
463                  if(explicit.getPropertyDescriptors() != null)                  if(explicit.getPropertyDescriptors() != null)
# Line 448  class ExplicitInfo Line 467  class ExplicitInfo
467                      propertyStopClass = beanClass;                      propertyStopClass = beanClass;
468                    }                    }
469                }                }
470    
471              if(explicitEventSetDescriptors == null)              if(explicitEventSetDescriptors == null)
472                {                {
473                  if(explicit.getEventSetDescriptors() != null)                  if(explicit.getEventSetDescriptors() != null)
# Line 457  class ExplicitInfo Line 477  class ExplicitInfo
477                      eventStopClass = beanClass;                      eventStopClass = beanClass;
478                    }                    }
479                }                }
480    
481              if(explicitMethodDescriptors == null)              if(explicitMethodDescriptors == null)
482                {                {
483                  if(explicit.getMethodDescriptors() != null)                  if(explicit.getMethodDescriptors() != null)
# Line 465  class ExplicitInfo Line 486  class ExplicitInfo
486                      methodStopClass = beanClass;                      methodStopClass = beanClass;
487                    }                    }
488                }                }
489    
490              if(im[0] == null && im[1] == null              if(im[0] == null && im[1] == null
491                 && im[2] == null && im[3] == null)                 && im[2] == null && im[3] == null)
492                {                {
# Line 476  class ExplicitInfo Line 498  class ExplicitInfo
498            }            }
499          beanClass = beanClass.getSuperclass();          beanClass = beanClass.getSuperclass();
500        }        }
501    
502      if(propertyStopClass == null)      if(propertyStopClass == null)
503        {        {
504          propertyStopClass = stopClass;          propertyStopClass = stopClass;
505        }        }
506    
507      if(eventStopClass == null)      if(eventStopClass == null)
508        {        {
509          eventStopClass = stopClass;          eventStopClass = stopClass;
510        }        }
511    
512      if(methodStopClass == null)      if(methodStopClass == null)
513        {        {
514          methodStopClass = stopClass;          methodStopClass = stopClass;
515        }        }
516    }    }
517        
518    static Hashtable explicitBeanInfos = new Hashtable();    /** Throws away all cached data and makes sure we re-instantiate things
519    static Vector emptyBeanInfos = new Vector();      * like BeanDescriptors again.
520        */
521      static void flushCaches() {
522            explicitBeanInfos.clear();
523            emptyBeanInfos.clear();
524      }
525        
526    static BeanInfo findExplicitBeanInfo(Class beanClass)    static BeanInfo findExplicitBeanInfo(Class beanClass)
527    {    {
# Line 539  class ExplicitInfo Line 569  class ExplicitInfo
569                                       Introspector.beanInfoSearchPath[i] + "."                                       Introspector.beanInfoSearchPath[i] + "."
570                                       + newName);                                       + newName);
571    
572              if (beanInfo != null)                  // Returns the beanInfo if it exists and the described class matches
573                    // the one we searched.
574                if (beanInfo != null && beanInfo.getBeanDescriptor() != null &&
575                            beanInfo.getBeanDescriptor().getBeanClass() == beanClass)
576    
577                return beanInfo;                return beanInfo;
578            }            }
579        }        }
580    
581      return beanInfo;      return beanInfo;

Legend:
Removed from v.1.17.2.1  
changed lines
  Added in v.1.17.2.2

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26