diff --git a/libjava/ChangeLog b/libjava/ChangeLog index 6b585479dd2..aec5a291469 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,3 +1,35 @@ +2002-03-24 Eric Blake + + * java/beans/IntrospectionException.java: Update to 1.4. + * java/beans/PropertyVetoException.java: Ditto. + +2002-03-24 Eric Blake + + * gnu/java/beans/BeanInfoEmbryo.java (hasMethod): Use + Arrays.equals instead of ArrayHelper.equalsArray. + +2002-03-24 C. Brian Jones + + * java/beans/Introspector.java: added new static final fields + introduced in 1.2, lots of other updates remain to be done + +2002-03-24 C. Brian Jones + + * java/beans/Introspector.java: reformatting + +2002-03-24 C. Brian Jones + + * java/beans/Introspector.java: default beanInfoSearchPath will + not include sun.beans.infos given we provide no such package and + the API doesn't really require it; gnu.java.beans.info is the + default. + +2002-03-24 Mark Wielaard + + Thanks to Orp developers + * gnu/java/beans/editors/NativeBooleanEditor.java (setAsText(String)): + switch TRUE and FALSE return values. + 2002-03-23 Tom Tromey * include/name-finder.h (_Jv_name_finder::myclose): New method. diff --git a/libjava/gnu/java/beans/BeanInfoEmbryo.java b/libjava/gnu/java/beans/BeanInfoEmbryo.java index 4aed20b9f86..473aa790cba 100644 --- a/libjava/gnu/java/beans/BeanInfoEmbryo.java +++ b/libjava/gnu/java/beans/BeanInfoEmbryo.java @@ -1,5 +1,5 @@ /* gnu.java.beans.BeanInfoEmbryo - Copyright (C) 1998 Free Software Foundation, Inc. + Copyright (C) 1998, 2002 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -130,14 +130,15 @@ public class BeanInfoEmbryo { } public boolean hasMethod(MethodDescriptor m) { - for(int i=0;i - ** - ** Don't worry about it too much, though: you can provide - ** JavaBeans with as much customized information as you - ** want, or as little as you want, using the BeanInfo - ** interface (see BeanInfo for details).

- ** - ** Order of Operations

- ** - ** When you call getBeanInfo(class c), the Introspector - ** first searches for BeanInfo class to see if you - ** provided any explicit information. It searches for a - ** class named BeanInfo in different - ** packages, first searching the bean class's package - ** and then moving on to search the beanInfoSearchPath.

- ** - ** If it does not find a BeanInfo class, it acts as though - ** it had found a BeanInfo class returning null from all - ** methods (meaning it should discover everything through - ** Introspection). If it does, then it takes the - ** information it finds in the BeanInfo class to be - ** canonical (that is, the information speaks for its - ** class as well as all superclasses).

- ** - ** When it has introspected the class, calls - ** getBeanInfo(c.getSuperclass) and adds that information - ** to the information it has, not adding to any information - ** it already has that is canonical.

- ** - ** Introspection Design Patterns

- ** - ** When the Introspector goes in to read the class, it - ** follows a well-defined order in order to not leave any - ** methods unaccounted for. Its job is to step over all - ** of the public methods in a class and determine whether - ** they are part of a property, an event, or a method (in - ** that order). - ** - ** - ** Properties:

- ** - **

    - **
  1. If there is a public boolean isXXX() - ** method, then XXX is a read-only boolean property. - ** boolean getXXX() may be supplied in - ** addition to this method, although isXXX() is the - ** one that will be used in this case and getXXX() - ** will be ignored. If there is a - ** public void setXXX(boolean) method, - ** it is part of this group and makes it a read-write - ** property.
  2. - **
  3. If there is a - ** public <type> getXXX(int) - ** method, then XXX is a read-only indexed property of - ** type <type>. If there is a - ** public void setXXX(int,<type>) - ** method, then it is a read-write indexed property of - ** type <type>. There may also be a - ** public <type>[] getXXX() and a - ** public void setXXX(<type>) - ** method as well.
  4. - **
  5. If there is a - ** public void setXXX(int,<type>) - ** method, then it is a write-only indexed property of - ** type <type>. There may also be a - ** public <type>[] getXXX() and a - ** public void setXXX(<type>) - ** method as well.
  6. - **
  7. If there is a - ** public <type> getXXX() method, - ** then XXX is a read-only property of type - ** <type>. If there is a - ** public void setXXX(<type>) - ** method, then it will be used for the property and - ** the property will be considered read-write.
  8. - **
  9. If there is a - ** public void setXXX(<type>) - ** method, then as long as XXX is not already used as - ** the name of a property, XXX is assumed to be a - ** write-only property of type <type>.
  10. - **
  11. In all of the above cases, if the setXXX() method - ** throws PropertyVetoException, then the - ** property in question is assumed to be constrained. - ** No properties are ever assumed to be bound - ** (Spec Note: this is not in the - ** spec, it just makes sense). See PropertyDescriptor - ** for a description of bound and constrained - ** properties.
  12. - **
- ** - ** Events:

- ** - ** If there is a pair of methods, - ** public void addXXX(<type>) and - ** public void removeXXX(<type>), where - ** <type> is a descendant of - ** java.util.EventListener, then the pair of - ** methods imply that this Bean will fire events to - ** listeners of type <type>.

- ** - ** If the addXXX() method throws - ** java.util.TooManyListenersException, then - ** the event set is assumed to be unicast. See - ** EventSetDescriptor for a discussion of unicast event - ** sets.

- ** - ** Spec Note: the spec seems to say that - ** the listener type's classname must be equal to the XXX - ** part of addXXX() and removeXXX(), but that is not the - ** case in Sun's implementation, so I am assuming it is - ** not the case in general.

- ** - ** Methods:

- ** - ** Any public methods (including those which were used - ** for Properties or Events) are used as Methods. - ** - ** @author John Keiser - ** @since JDK1.1 - ** @version 1.1.0, 29 Jul 1998 - ** @see java.beans.BeanInfo - **/ - + * Introspector is the class that does the bulk of the + * design-time work in Java Beans. Every class must have + * a BeanInfo in order for an RAD tool to use it; but, as + * promised, you don't have to write the BeanInfo class + * yourself if you don't want to. All you have to do is + * call getBeanInfo() in the Introspector and it will use + * standard JavaBeans-defined method signatures to + * determine the information about your class.

+ * + * Don't worry about it too much, though: you can provide + * JavaBeans with as much customized information as you + * want, or as little as you want, using the BeanInfo + * interface (see BeanInfo for details).

+ * + * Order of Operations

+ * + * When you call getBeanInfo(class c), the Introspector + * first searches for BeanInfo class to see if you + * provided any explicit information. It searches for a + * class named BeanInfo in different + * packages, first searching the bean class's package + * and then moving on to search the beanInfoSearchPath.

+ * + * If it does not find a BeanInfo class, it acts as though + * it had found a BeanInfo class returning null from all + * methods (meaning it should discover everything through + * Introspection). If it does, then it takes the + * information it finds in the BeanInfo class to be + * canonical (that is, the information speaks for its + * class as well as all superclasses).

+ * + * When it has introspected the class, calls + * getBeanInfo(c.getSuperclass) and adds that information + * to the information it has, not adding to any information + * it already has that is canonical.

+ * + * Introspection Design Patterns

+ * + * When the Introspector goes in to read the class, it + * follows a well-defined order in order to not leave any + * methods unaccounted for. Its job is to step over all + * of the public methods in a class and determine whether + * they are part of a property, an event, or a method (in + * that order). + * + * + * Properties:

+ * + *

    + *
  1. If there is a public boolean isXXX() + * method, then XXX is a read-only boolean property. + * boolean getXXX() may be supplied in + * addition to this method, although isXXX() is the + * one that will be used in this case and getXXX() + * will be ignored. If there is a + * public void setXXX(boolean) method, + * it is part of this group and makes it a read-write + * property.
  2. + *
  3. If there is a + * public <type> getXXX(int) + * method, then XXX is a read-only indexed property of + * type <type>. If there is a + * public void setXXX(int,<type>) + * method, then it is a read-write indexed property of + * type <type>. There may also be a + * public <type>[] getXXX() and a + * public void setXXX(<type>) + * method as well.
  4. + *
  5. If there is a + * public void setXXX(int,<type>) + * method, then it is a write-only indexed property of + * type <type>. There may also be a + * public <type>[] getXXX() and a + * public void setXXX(<type>) + * method as well.
  6. + *
  7. If there is a + * public <type> getXXX() method, + * then XXX is a read-only property of type + * <type>. If there is a + * public void setXXX(<type>) + * method, then it will be used for the property and + * the property will be considered read-write.
  8. + *
  9. If there is a + * public void setXXX(<type>) + * method, then as long as XXX is not already used as + * the name of a property, XXX is assumed to be a + * write-only property of type <type>.
  10. + *
  11. In all of the above cases, if the setXXX() method + * throws PropertyVetoException, then the + * property in question is assumed to be constrained. + * No properties are ever assumed to be bound + * (Spec Note: this is not in the + * spec, it just makes sense). See PropertyDescriptor + * for a description of bound and constrained + * properties.
  12. + *
+ * + * Events:

+ * + * If there is a pair of methods, + * public void addXXX(<type>) and + * public void removeXXX(<type>), where + * <type> is a descendant of + * java.util.EventListener, then the pair of + * methods imply that this Bean will fire events to + * listeners of type <type>.

+ * + * If the addXXX() method throws + * java.util.TooManyListenersException, then + * the event set is assumed to be unicast. See + * EventSetDescriptor for a discussion of unicast event + * sets.

+ * + * Spec Note: the spec seems to say that + * the listener type's classname must be equal to the XXX + * part of addXXX() and removeXXX(), but that is not the + * case in Sun's implementation, so I am assuming it is + * not the case in general.

+ * + * Methods:

+ * + * Any public methods (including those which were used + * for Properties or Events) are used as Methods. + * + * @author John Keiser + * @since JDK1.1 + * @see java.beans.BeanInfo + */ public class Introspector { - static String[] beanInfoSearchPath = {"gnu.java.beans.info", "sun.beans.infos"}; - static Hashtable beanInfoCache = new Hashtable(); + + public static final int USE_ALL_BEANINFO = 1; + public static final int IGNORE_IMMEDIATE_BEANINFO = 2; + public static final int IGNORE_ALL_BEANINFO = 3; - private Introspector() {} + static String[] beanInfoSearchPath = {"gnu.java.beans.info"}; + static Hashtable beanInfoCache = new Hashtable(); + + private Introspector() {} + + /** + * Get the BeanInfo for class beanClass, + * first by looking for explicit information, next by + * using standard design patterns to determine + * information about the class. + * + * @param beanClass the class to get BeanInfo about. + * @return the BeanInfo object representing the class. + */ + public static BeanInfo getBeanInfo(Class beanClass) + throws IntrospectionException + { + BeanInfo cachedInfo; + synchronized(beanClass) + { + cachedInfo = (BeanInfo)beanInfoCache.get(beanClass); + if(cachedInfo != null) + { + return cachedInfo; + } + cachedInfo = getBeanInfo(beanClass,null); + beanInfoCache.put(beanClass,cachedInfo); + return cachedInfo; + } + } - /** Get the BeanInfo for class beanClass, - ** first by looking for explicit information, next by - ** using standard design patterns to determine - ** information about the class. - ** @param beanClass the class to get BeanInfo about. - ** @return the BeanInfo object representing the class. - **/ - public static BeanInfo getBeanInfo(Class beanClass) throws IntrospectionException { - BeanInfo cachedInfo; - synchronized(beanClass) { - cachedInfo = (BeanInfo)beanInfoCache.get(beanClass); - if(cachedInfo != null) { - return cachedInfo; - } - cachedInfo = getBeanInfo(beanClass,null); - beanInfoCache.put(beanClass,cachedInfo); - return cachedInfo; - } - } - - /** Get the BeanInfo for class beanClass, - ** first by looking for explicit information, next by - ** using standard design patterns to determine - ** information about the class. It crawls up the - ** inheritance tree until it hits topClass. - ** @param beanClass the Bean class. - ** @param stopClass the class to stop at. - ** @return the BeanInfo object representing the class. - **/ - public static BeanInfo getBeanInfo(Class beanClass, Class stopClass) throws IntrospectionException { - ExplicitInfo explicit = new ExplicitInfo(beanClass,stopClass); - - IntrospectionIncubator ii = new IntrospectionIncubator(); - ii.setPropertyStopClass(explicit.propertyStopClass); - ii.setEventStopClass(explicit.eventStopClass); - ii.setMethodStopClass(explicit.methodStopClass); - ii.addMethods(beanClass.getMethods()); - - BeanInfoEmbryo currentInfo = ii.getBeanInfoEmbryo(); - PropertyDescriptor[] p = explicit.explicitPropertyDescriptors; - if(p!=null) { - for(int i=0;ibeanClass, + * first by looking for explicit information, next by + * using standard design patterns to determine + * information about the class. It crawls up the + * inheritance tree until it hits topClass. + * + * @param beanClass the Bean class. + * @param stopClass the class to stop at. + * @return the BeanInfo object representing the class. + */ + public static BeanInfo getBeanInfo(Class beanClass, Class stopClass) + throws IntrospectionException + { + ExplicitInfo explicit = new ExplicitInfo(beanClass,stopClass); + + IntrospectionIncubator ii = new IntrospectionIncubator(); + ii.setPropertyStopClass(explicit.propertyStopClass); + ii.setEventStopClass(explicit.eventStopClass); + ii.setMethodStopClass(explicit.methodStopClass); + ii.addMethods(beanClass.getMethods()); + + BeanInfoEmbryo currentInfo = ii.getBeanInfoEmbryo(); + PropertyDescriptor[] p = explicit.explicitPropertyDescriptors; + if(p!=null) + { + for(int i=0;i