Commit c9be3825 by Mark Wielaard

[multiple changes]

2002-03-24  Eric Blake  <ebb9@email.byu.edu>

        * java/beans/IntrospectionException.java: Update to 1.4.
        * java/beans/PropertyVetoException.java: Ditto.

2002-03-24  Eric Blake  <ebb9@email.byu.edu>

        * gnu/java/beans/BeanInfoEmbryo.java (hasMethod): Use
        Arrays.equals instead of ArrayHelper.equalsArray.

2002-03-24  C. Brian Jones <cbj@gnu.org>

        * 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 <cbj@gnu.org>

        * java/beans/Introspector.java: reformatting

2002-03-24  C. Brian Jones <cbj@gnu.org>

        * 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  <mark@klomp.org>

        Thanks to Orp developers
        * gnu/java/beans/editors/NativeBooleanEditor.java (setAsText(String)):
        switch TRUE and FALSE return values.

From-SVN: r51273
parent 3ddbb8a9
2002-03-24 Eric Blake <ebb9@email.byu.edu>
* java/beans/IntrospectionException.java: Update to 1.4.
* java/beans/PropertyVetoException.java: Ditto.
2002-03-24 Eric Blake <ebb9@email.byu.edu>
* gnu/java/beans/BeanInfoEmbryo.java (hasMethod): Use
Arrays.equals instead of ArrayHelper.equalsArray.
2002-03-24 C. Brian Jones <cbj@gnu.org>
* 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 <cbj@gnu.org>
* java/beans/Introspector.java: reformatting
2002-03-24 C. Brian Jones <cbj@gnu.org>
* 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 <mark@klomp.org>
Thanks to Orp developers
* gnu/java/beans/editors/NativeBooleanEditor.java (setAsText(String)):
switch TRUE and FALSE return values.
2002-03-23 Tom Tromey <tromey@redhat.com> 2002-03-23 Tom Tromey <tromey@redhat.com>
* include/name-finder.h (_Jv_name_finder::myclose): New method. * include/name-finder.h (_Jv_name_finder::myclose): New method.
......
/* gnu.java.beans.BeanInfoEmbryo /* 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. This file is part of GNU Classpath.
...@@ -133,7 +133,8 @@ public class BeanInfoEmbryo { ...@@ -133,7 +133,8 @@ public class BeanInfoEmbryo {
for(int i=0;i<methods.size();i++) { for(int i=0;i<methods.size();i++) {
Method thisMethod = ((MethodDescriptor)methods.elementAt(i)).getMethod(); Method thisMethod = ((MethodDescriptor)methods.elementAt(i)).getMethod();
if(m.getMethod().getName().equals(thisMethod.getName()) if(m.getMethod().getName().equals(thisMethod.getName())
&& ArrayHelper.equalsArray(m.getMethod().getParameterTypes(), thisMethod.getParameterTypes())) { && Arrays.equals(m.getMethod().getParameterTypes(),
thisMethod.getParameterTypes())) {
return true; return true;
} }
} }
......
/* gnu.java.beans.editors.NativeBooleanEditor /* gnu.java.beans.editors.NativeBooleanEditor
Copyright (C) 1998 Free Software Foundation, Inc. Copyright (C) 1998, 2002 Free Software Foundation, Inc.
This file is part of GNU Classpath. This file is part of GNU Classpath.
...@@ -54,12 +54,15 @@ import java.beans.*; ...@@ -54,12 +54,15 @@ import java.beans.*;
public class NativeBooleanEditor extends PropertyEditorSupport { public class NativeBooleanEditor extends PropertyEditorSupport {
String[] tags = {"true","false"}; String[] tags = {"true","false"};
/** setAsText for boolean checks for true or false or t or f. "" also means false. **/ /**
* setAsText for boolean checks for true or false or t or f.
* "" also means false.
**/
public void setAsText(String val) throws IllegalArgumentException { public void setAsText(String val) throws IllegalArgumentException {
if(val.equalsIgnoreCase("true") || val.equalsIgnoreCase("t")) { if(val.equalsIgnoreCase("true") || val.equalsIgnoreCase("t")) {
setValue(Boolean.FALSE);
} else if(val.equalsIgnoreCase("false") || val.equalsIgnoreCase("f") || val.equals("")) {
setValue(Boolean.TRUE); setValue(Boolean.TRUE);
} else if(val.equalsIgnoreCase("false") || val.equalsIgnoreCase("f") || val.equals("")) {
setValue(Boolean.FALSE);
} else { } else {
throw new IllegalArgumentException("Value must be true, false, t, f or empty."); throw new IllegalArgumentException("Value must be true, false, t, f or empty.");
} }
......
/* java.beans.IntrospectionException /* IntrospectionException -- thrown when an exception occurs in introspection
Copyright (C) 1998 Free Software Foundation, Inc. Copyright (C) 1998, 2002 Free Software Foundation, Inc.
This file is part of GNU Classpath. This file is part of GNU Classpath.
...@@ -39,19 +39,29 @@ exception statement from your version. */ ...@@ -39,19 +39,29 @@ exception statement from your version. */
package java.beans; package java.beans;
/** /**
** IntrospectionException is thrown when the Introspector fails. Surprise, surprise. * IntrospectionException is thrown when the Introspector fails. Typical
** * causes are the inability to map a name to its Class, or specifying a
** @author John Keiser * wrong type signature.
** @since JDK1.1 *
** @version 1.1.0, 31 May 1998 * @author John Keiser
** @see java.beans.Introspector * @see Introspector
**/ * @since 1.1
* @status updated to 1.4
public class IntrospectionException extends Exception { */
/** Instantiate this exception with the given message. public class IntrospectionException extends Exception
** @param msg the message for the exception. {
**/ /**
public IntrospectionException(String msg) { * Compatible with JDK 1.1+.
*/
private static final long serialVersionUID = -3728150539969542619L;
/**
* Instantiate this exception with the given message.
*
* @param msg the message for the exception
*/
public IntrospectionException(String msg)
{
super(msg); super(msg);
} }
} }
...@@ -44,154 +44,163 @@ import java.lang.reflect.*; ...@@ -44,154 +44,163 @@ import java.lang.reflect.*;
import gnu.java.lang.*; import gnu.java.lang.*;
/** /**
** Introspector is the class that does the bulk of the * Introspector is the class that does the bulk of the
** design-time work in Java Beans. Every class must have * design-time work in Java Beans. Every class must have
** a BeanInfo in order for an RAD tool to use it; but, as * a BeanInfo in order for an RAD tool to use it; but, as
** promised, you don't have to write the BeanInfo class * promised, you don't have to write the BeanInfo class
** yourself if you don't want to. All you have to do is * yourself if you don't want to. All you have to do is
** call getBeanInfo() in the Introspector and it will use * call getBeanInfo() in the Introspector and it will use
** standard JavaBeans-defined method signatures to * standard JavaBeans-defined method signatures to
** determine the information about your class.<P> * determine the information about your class.<P>
** *
** Don't worry about it too much, though: you can provide * Don't worry about it too much, though: you can provide
** JavaBeans with as much customized information as you * JavaBeans with as much customized information as you
** want, or as little as you want, using the BeanInfo * want, or as little as you want, using the BeanInfo
** interface (see BeanInfo for details).<P> * interface (see BeanInfo for details).<P>
** *
** <STRONG>Order of Operations</STRONG><P> * <STRONG>Order of Operations</STRONG><P>
** *
** When you call getBeanInfo(class c), the Introspector * When you call getBeanInfo(class c), the Introspector
** first searches for BeanInfo class to see if you * first searches for BeanInfo class to see if you
** provided any explicit information. It searches for a * provided any explicit information. It searches for a
** class named <bean class name>BeanInfo in different * class named <bean class name>BeanInfo in different
** packages, first searching the bean class's package * packages, first searching the bean class's package
** and then moving on to search the beanInfoSearchPath.<P> * and then moving on to search the beanInfoSearchPath.<P>
** *
** If it does not find a BeanInfo class, it acts as though * If it does not find a BeanInfo class, it acts as though
** it had found a BeanInfo class returning null from all * it had found a BeanInfo class returning null from all
** methods (meaning it should discover everything through * methods (meaning it should discover everything through
** Introspection). If it does, then it takes the * Introspection). If it does, then it takes the
** information it finds in the BeanInfo class to be * information it finds in the BeanInfo class to be
** canonical (that is, the information speaks for its * canonical (that is, the information speaks for its
** class as well as all superclasses).<P> * class as well as all superclasses).<P>
** *
** When it has introspected the class, calls * When it has introspected the class, calls
** getBeanInfo(c.getSuperclass) and adds that information * getBeanInfo(c.getSuperclass) and adds that information
** to the information it has, not adding to any information * to the information it has, not adding to any information
** it already has that is canonical.<P> * it already has that is canonical.<P>
** *
** <STRONG>Introspection Design Patterns</STRONG><P> * <STRONG>Introspection Design Patterns</STRONG><P>
** *
** When the Introspector goes in to read the class, it * When the Introspector goes in to read the class, it
** follows a well-defined order in order to not leave any * follows a well-defined order in order to not leave any
** methods unaccounted for. Its job is to step over all * methods unaccounted for. Its job is to step over all
** of the public methods in a class and determine whether * of the public methods in a class and determine whether
** they are part of a property, an event, or a method (in * they are part of a property, an event, or a method (in
** that order). * that order).
** *
** *
** <STRONG>Properties:</STRONG><P> * <STRONG>Properties:</STRONG><P>
** *
** <OL> * <OL>
** <LI>If there is a <CODE>public boolean isXXX()</CODE> * <LI>If there is a <CODE>public boolean isXXX()</CODE>
** method, then XXX is a read-only boolean property. * method, then XXX is a read-only boolean property.
** <CODE>boolean getXXX()</CODE> may be supplied in * <CODE>boolean getXXX()</CODE> may be supplied in
** addition to this method, although isXXX() is the * addition to this method, although isXXX() is the
** one that will be used in this case and getXXX() * one that will be used in this case and getXXX()
** will be ignored. If there is a * will be ignored. If there is a
** <CODE>public void setXXX(boolean)</CODE> method, * <CODE>public void setXXX(boolean)</CODE> method,
** it is part of this group and makes it a read-write * it is part of this group and makes it a read-write
** property.</LI> * property.</LI>
** <LI>If there is a * <LI>If there is a
** <CODE>public &lt;type&gt; getXXX(int)</CODE> * <CODE>public &lt;type&gt; getXXX(int)</CODE>
** method, then XXX is a read-only indexed property of * method, then XXX is a read-only indexed property of
** type &lt;type&gt;. If there is a * type &lt;type&gt;. If there is a
** <CODE>public void setXXX(int,&lt;type&gt;)</CODE> * <CODE>public void setXXX(int,&lt;type&gt;)</CODE>
** method, then it is a read-write indexed property of * method, then it is a read-write indexed property of
** type &lt;type&gt;. There may also be a * type &lt;type&gt;. There may also be a
** <CODE>public &lt;type&gt;[] getXXX()</CODE> and a * <CODE>public &lt;type&gt;[] getXXX()</CODE> and a
** <CODE>public void setXXX(&lt;type&gt;)</CODE> * <CODE>public void setXXX(&lt;type&gt;)</CODE>
** method as well.</CODE></LI> * method as well.</CODE></LI>
** <LI>If there is a * <LI>If there is a
** <CODE>public void setXXX(int,&lt;type&gt;)</CODE> * <CODE>public void setXXX(int,&lt;type&gt;)</CODE>
** method, then it is a write-only indexed property of * method, then it is a write-only indexed property of
** type &lt;type&gt;. There may also be a * type &lt;type&gt;. There may also be a
** <CODE>public &lt;type&gt;[] getXXX()</CODE> and a * <CODE>public &lt;type&gt;[] getXXX()</CODE> and a
** <CODE>public void setXXX(&lt;type&gt;)</CODE> * <CODE>public void setXXX(&lt;type&gt;)</CODE>
** method as well.</CODE></LI> * method as well.</CODE></LI>
** <LI>If there is a * <LI>If there is a
** <CODE>public &lt;type&gt; getXXX()</CODE> method, * <CODE>public &lt;type&gt; getXXX()</CODE> method,
** then XXX is a read-only property of type * then XXX is a read-only property of type
** &lt;type&gt;. If there is a * &lt;type&gt;. If there is a
** <CODE>public void setXXX(&lt;type&gt;)</CODE> * <CODE>public void setXXX(&lt;type&gt;)</CODE>
** method, then it will be used for the property and * method, then it will be used for the property and
** the property will be considered read-write.</LI> * the property will be considered read-write.</LI>
** <LI>If there is a * <LI>If there is a
** <CODE>public void setXXX(&lt;type&gt;)</CODE> * <CODE>public void setXXX(&lt;type&gt;)</CODE>
** method, then as long as XXX is not already used as * method, then as long as XXX is not already used as
** the name of a property, XXX is assumed to be a * the name of a property, XXX is assumed to be a
** write-only property of type &lt;type&gt;.</LI> * write-only property of type &lt;type&gt;.</LI>
** <LI>In all of the above cases, if the setXXX() method * <LI>In all of the above cases, if the setXXX() method
** throws <CODE>PropertyVetoException</CODE>, then the * throws <CODE>PropertyVetoException</CODE>, then the
** property in question is assumed to be constrained. * property in question is assumed to be constrained.
** No properties are ever assumed to be bound * No properties are ever assumed to be bound
** (<STRONG>Spec Note:</STRONG> this is not in the * (<STRONG>Spec Note:</STRONG> this is not in the
** spec, it just makes sense). See PropertyDescriptor * spec, it just makes sense). See PropertyDescriptor
** for a description of bound and constrained * for a description of bound and constrained
** properties.</LI> * properties.</LI>
** </OL> * </OL>
** *
** <STRONG>Events:</STRONG><P> * <STRONG>Events:</STRONG><P>
** *
** If there is a pair of methods, * If there is a pair of methods,
** <CODE>public void addXXX(&lt;type&gt;)</CODE> and * <CODE>public void addXXX(&lt;type&gt;)</CODE> and
** <CODE>public void removeXXX(&lt;type&gt;)</CODE>, where * <CODE>public void removeXXX(&lt;type&gt;)</CODE>, where
** &lt;type&gt; is a descendant of * &lt;type&gt; is a descendant of
** <CODE>java.util.EventListener</CODE>, then the pair of * <CODE>java.util.EventListener</CODE>, then the pair of
** methods imply that this Bean will fire events to * methods imply that this Bean will fire events to
** listeners of type &lt;type&gt;.<P> * listeners of type &lt;type&gt;.<P>
** *
** If the addXXX() method throws * If the addXXX() method throws
** <CODE>java.util.TooManyListenersException</CODE>, then * <CODE>java.util.TooManyListenersException</CODE>, then
** the event set is assumed to be <EM>unicast</EM>. See * the event set is assumed to be <EM>unicast</EM>. See
** EventSetDescriptor for a discussion of unicast event * EventSetDescriptor for a discussion of unicast event
** sets.<P> * sets.<P>
** *
** <STRONG>Spec Note:</STRONG> the spec seems to say that * <STRONG>Spec Note:</STRONG> the spec seems to say that
** the listener type's classname must be equal to the XXX * the listener type's classname must be equal to the XXX
** part of addXXX() and removeXXX(), but that is not the * part of addXXX() and removeXXX(), but that is not the
** case in Sun's implementation, so I am assuming it is * case in Sun's implementation, so I am assuming it is
** not the case in general.<P> * not the case in general.<P>
** *
** <STRONG>Methods:</STRONG><P> * <STRONG>Methods:</STRONG><P>
** *
** Any public methods (including those which were used * Any public methods (including those which were used
** for Properties or Events) are used as Methods. * for Properties or Events) are used as Methods.
** *
** @author John Keiser * @author John Keiser
** @since JDK1.1 * @since JDK1.1
** @version 1.1.0, 29 Jul 1998 * @see java.beans.BeanInfo
** @see java.beans.BeanInfo */
**/
public class Introspector { public class Introspector {
static String[] beanInfoSearchPath = {"gnu.java.beans.info", "sun.beans.infos"};
public static final int USE_ALL_BEANINFO = 1;
public static final int IGNORE_IMMEDIATE_BEANINFO = 2;
public static final int IGNORE_ALL_BEANINFO = 3;
static String[] beanInfoSearchPath = {"gnu.java.beans.info"};
static Hashtable beanInfoCache = new Hashtable(); static Hashtable beanInfoCache = new Hashtable();
private Introspector() {} private Introspector() {}
/** Get the BeanInfo for class <CODE>beanClass</CODE>, /**
** first by looking for explicit information, next by * Get the BeanInfo for class <CODE>beanClass</CODE>,
** using standard design patterns to determine * first by looking for explicit information, next by
** information about the class. * using standard design patterns to determine
** @param beanClass the class to get BeanInfo about. * information about the class.
** @return the BeanInfo object representing the class. *
**/ * @param beanClass the class to get BeanInfo about.
public static BeanInfo getBeanInfo(Class beanClass) throws IntrospectionException { * @return the BeanInfo object representing the class.
*/
public static BeanInfo getBeanInfo(Class beanClass)
throws IntrospectionException
{
BeanInfo cachedInfo; BeanInfo cachedInfo;
synchronized(beanClass) { synchronized(beanClass)
{
cachedInfo = (BeanInfo)beanInfoCache.get(beanClass); cachedInfo = (BeanInfo)beanInfoCache.get(beanClass);
if(cachedInfo != null) { if(cachedInfo != null)
{
return cachedInfo; return cachedInfo;
} }
cachedInfo = getBeanInfo(beanClass,null); cachedInfo = getBeanInfo(beanClass,null);
...@@ -200,16 +209,20 @@ public class Introspector { ...@@ -200,16 +209,20 @@ public class Introspector {
} }
} }
/** Get the BeanInfo for class <CODE>beanClass</CODE>, /**
** first by looking for explicit information, next by * Get the BeanInfo for class <CODE>beanClass</CODE>,
** using standard design patterns to determine * first by looking for explicit information, next by
** information about the class. It crawls up the * using standard design patterns to determine
** inheritance tree until it hits <CODE>topClass</CODE>. * information about the class. It crawls up the
** @param beanClass the Bean class. * inheritance tree until it hits <CODE>topClass</CODE>.
** @param stopClass the class to stop at. *
** @return the BeanInfo object representing the class. * @param beanClass the Bean class.
**/ * @param stopClass the class to stop at.
public static BeanInfo getBeanInfo(Class beanClass, Class stopClass) throws IntrospectionException { * @return the BeanInfo object representing the class.
*/
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(); IntrospectionIncubator ii = new IntrospectionIncubator();
...@@ -220,39 +233,53 @@ public class Introspector { ...@@ -220,39 +233,53 @@ public class Introspector {
BeanInfoEmbryo currentInfo = ii.getBeanInfoEmbryo(); BeanInfoEmbryo currentInfo = ii.getBeanInfoEmbryo();
PropertyDescriptor[] p = explicit.explicitPropertyDescriptors; PropertyDescriptor[] p = explicit.explicitPropertyDescriptors;
if(p!=null) { if(p!=null)
for(int i=0;i<p.length;i++) { {
if(!currentInfo.hasProperty(p[i])) { for(int i=0;i<p.length;i++)
{
if(!currentInfo.hasProperty(p[i]))
{
currentInfo.addProperty(p[i]); currentInfo.addProperty(p[i]);
} }
} }
if(explicit.defaultProperty != -1) { if(explicit.defaultProperty != -1)
{
currentInfo.setDefaultPropertyName(p[explicit.defaultProperty].getName()); currentInfo.setDefaultPropertyName(p[explicit.defaultProperty].getName());
} }
} }
EventSetDescriptor[] e = explicit.explicitEventSetDescriptors; EventSetDescriptor[] e = explicit.explicitEventSetDescriptors;
if(e!=null) { if(e!=null)
for(int i=0;i<e.length;i++) { {
if(!currentInfo.hasEvent(e[i])) { for(int i=0;i<e.length;i++)
{
if(!currentInfo.hasEvent(e[i]))
{
currentInfo.addEvent(e[i]); currentInfo.addEvent(e[i]);
} }
} }
if(explicit.defaultEvent != -1) { if(explicit.defaultEvent != -1)
{
currentInfo.setDefaultEventName(e[explicit.defaultEvent].getName()); currentInfo.setDefaultEventName(e[explicit.defaultEvent].getName());
} }
} }
MethodDescriptor[] m = explicit.explicitMethodDescriptors; MethodDescriptor[] m = explicit.explicitMethodDescriptors;
if(m!=null) { if(m!=null)
for(int i=0;i<m.length;i++) { {
if(!currentInfo.hasMethod(m[i])) { for(int i=0;i<m.length;i++)
{
if(!currentInfo.hasMethod(m[i]))
{
currentInfo.addMethod(m[i]); currentInfo.addMethod(m[i]);
} }
} }
} }
if(explicit.explicitBeanDescriptor != null) { if(explicit.explicitBeanDescriptor != null)
{
currentInfo.setBeanDescriptor(new BeanDescriptor(beanClass,explicit.explicitBeanDescriptor.getCustomizerClass())); currentInfo.setBeanDescriptor(new BeanDescriptor(beanClass,explicit.explicitBeanDescriptor.getCustomizerClass()));
} else { }
else
{
currentInfo.setBeanDescriptor(new BeanDescriptor(beanClass,null)); currentInfo.setBeanDescriptor(new BeanDescriptor(beanClass,null));
} }
...@@ -262,68 +289,96 @@ public class Introspector { ...@@ -262,68 +289,96 @@ public class Introspector {
return currentInfo.getBeanInfo(); return currentInfo.getBeanInfo();
} }
/** Get the search path for BeanInfo classes. /**
** @return the BeanInfo search path. * Get the search path for BeanInfo classes.
**/ *
public static String[] getBeanInfoSearchPath() { * @return the BeanInfo search path.
*/
public static String[] getBeanInfoSearchPath()
{
return beanInfoSearchPath; return beanInfoSearchPath;
} }
/** Set the search path for BeanInfo classes. /**
** @param beanInfoSearchPath the new BeanInfo search * Set the search path for BeanInfo classes.
** path. * @param beanInfoSearchPath the new BeanInfo search
**/ * path.
public static void setBeanInfoSearchPath(String[] beanInfoSearchPath) { */
public static void setBeanInfoSearchPath(String[] beanInfoSearchPath)
{
Introspector.beanInfoSearchPath = beanInfoSearchPath; Introspector.beanInfoSearchPath = beanInfoSearchPath;
} }
/** A helper method to convert a name to standard Java /**
** naming conventions: anything with two capitals as the * A helper method to convert a name to standard Java
** first two letters remains the same, otherwise the * naming conventions: anything with two capitals as the
** first letter is decapitalized. URL = URL, I = i, * first two letters remains the same, otherwise the
** MyMethod = myMethod. * first letter is decapitalized. URL = URL, I = i,
** @param name the name to decapitalize. * MyMethod = myMethod.
** @return the decapitalized name. *
**/ * @param name the name to decapitalize.
public static String decapitalize(String name) { * @return the decapitalized name.
try { */
if(!Character.isUpperCase(name.charAt(0))) { public static String decapitalize(String name)
{
try
{
if(!Character.isUpperCase(name.charAt(0)))
{
return name; return name;
} else { }
try { else
if(Character.isUpperCase(name.charAt(1))) { {
try
{
if(Character.isUpperCase(name.charAt(1)))
{
return name; return name;
} else { }
else
{
char[] c = name.toCharArray(); char[] c = name.toCharArray();
c[0] = Character.toLowerCase(c[0]); c[0] = Character.toLowerCase(c[0]);
return new String(c); return new String(c);
} }
} catch(StringIndexOutOfBoundsException E) { }
catch(StringIndexOutOfBoundsException E)
{
char[] c = new char[1]; char[] c = new char[1];
c[0] = Character.toLowerCase(name.charAt(0)); c[0] = Character.toLowerCase(name.charAt(0));
return new String(c); return new String(c);
} }
} }
} catch(StringIndexOutOfBoundsException E) { }
catch(StringIndexOutOfBoundsException E)
{
return name; return name;
} catch(NullPointerException E) { }
catch(NullPointerException E)
{
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];
for(int i=1;i<=4;i++) { for(int i=1;i<=4;i++)
{
icons[i-1] = b.getIcon(i); icons[i-1] = b.getIcon(i);
} }
return new ExplicitBeanInfo(b.getBeanDescriptor(),b.getAdditionalBeanInfo(), return new ExplicitBeanInfo(b.getBeanDescriptor(),
b.getPropertyDescriptors(),b.getDefaultPropertyIndex(), b.getAdditionalBeanInfo(),
b.getEventSetDescriptors(),b.getDefaultEventIndex(), b.getPropertyDescriptors(),
b.getDefaultPropertyIndex(),
b.getEventSetDescriptors(),
b.getDefaultEventIndex(),
b.getMethodDescriptors(),icons); b.getMethodDescriptors(),icons);
} }
} }
class ExplicitInfo { class ExplicitInfo
{
BeanDescriptor explicitBeanDescriptor; BeanDescriptor explicitBeanDescriptor;
BeanInfo[] explicitBeanInfo; BeanInfo[] explicitBeanInfo;
...@@ -340,40 +395,50 @@ class ExplicitInfo { ...@@ -340,40 +395,50 @@ class ExplicitInfo {
Class eventStopClass; Class eventStopClass;
Class methodStopClass; Class methodStopClass;
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)
{
explicitPropertyDescriptors = explicit.getPropertyDescriptors(); explicitPropertyDescriptors = explicit.getPropertyDescriptors();
defaultProperty = explicit.getDefaultPropertyIndex(); defaultProperty = explicit.getDefaultPropertyIndex();
propertyStopClass = beanClass; propertyStopClass = beanClass;
} }
} }
if(explicitEventSetDescriptors == null) { if(explicitEventSetDescriptors == null)
if(explicit.getEventSetDescriptors() != null) { {
if(explicit.getEventSetDescriptors() != null)
{
explicitEventSetDescriptors = explicit.getEventSetDescriptors(); explicitEventSetDescriptors = explicit.getEventSetDescriptors();
defaultEvent = explicit.getDefaultEventIndex(); defaultEvent = explicit.getDefaultEventIndex();
eventStopClass = beanClass; eventStopClass = beanClass;
} }
} }
if(explicitMethodDescriptors == null) { if(explicitMethodDescriptors == null)
if(explicit.getMethodDescriptors() != null) { {
if(explicit.getMethodDescriptors() != null)
{
explicitMethodDescriptors = explicit.getMethodDescriptors(); explicitMethodDescriptors = explicit.getMethodDescriptors();
methodStopClass = beanClass; methodStopClass = beanClass;
} }
} }
if(im[0] == null if(im[0] == null && im[1] == null
&& im[1] == null && im[2] == null && im[3] == null)
&& im[2] == null {
&& im[3] == null) {
im[0] = explicit.getIcon(0); im[0] = explicit.getIcon(0);
im[1] = explicit.getIcon(1); im[1] = explicit.getIcon(1);
im[2] = explicit.getIcon(2); im[2] = explicit.getIcon(2);
...@@ -382,13 +447,16 @@ class ExplicitInfo { ...@@ -382,13 +447,16 @@ 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;
} }
} }
...@@ -396,42 +464,67 @@ class ExplicitInfo { ...@@ -396,42 +464,67 @@ class ExplicitInfo {
static Hashtable explicitBeanInfos = new Hashtable(); static Hashtable explicitBeanInfos = new Hashtable();
static Vector emptyBeanInfos = new Vector(); static Vector emptyBeanInfos = new Vector();
static BeanInfo findExplicitBeanInfo(Class beanClass) { static BeanInfo findExplicitBeanInfo(Class beanClass)
{
BeanInfo retval = (BeanInfo)explicitBeanInfos.get(beanClass); BeanInfo retval = (BeanInfo)explicitBeanInfos.get(beanClass);
if(retval != null) { if(retval != null)
{
return retval; return retval;
} else if(emptyBeanInfos.indexOf(beanClass) != -1) { }
else if(emptyBeanInfos.indexOf(beanClass) != -1)
{
return null; return null;
} else { }
else
{
retval = reallyFindExplicitBeanInfo(beanClass); retval = reallyFindExplicitBeanInfo(beanClass);
if(retval != null) { if(retval != null)
{
explicitBeanInfos.put(beanClass,retval); explicitBeanInfos.put(beanClass,retval);
} else { }
else
{
emptyBeanInfos.addElement(beanClass); emptyBeanInfos.addElement(beanClass);
} }
return retval; return retval;
} }
} }
static BeanInfo reallyFindExplicitBeanInfo(Class beanClass) { static BeanInfo reallyFindExplicitBeanInfo(Class beanClass)
try { {
try { try
{
try
{
return (BeanInfo)Class.forName(beanClass.getName()+"BeanInfo").newInstance(); return (BeanInfo)Class.forName(beanClass.getName()+"BeanInfo").newInstance();
} catch(ClassNotFoundException E) { }
catch(ClassNotFoundException E)
{
} }
String newName = ClassHelper.getTruncatedClassName(beanClass) + "BeanInfo"; String newName = ClassHelper.getTruncatedClassName(beanClass) + "BeanInfo";
for(int i=0;i<Introspector.beanInfoSearchPath.length;i++) { for(int i=0;i<Introspector.beanInfoSearchPath.length;i++)
try { {
if(Introspector.beanInfoSearchPath[i].equals("")) { try
{
if(Introspector.beanInfoSearchPath[i].equals(""))
{
return (BeanInfo)Class.forName(newName).newInstance(); return (BeanInfo)Class.forName(newName).newInstance();
} else { }
else
{
return (BeanInfo)Class.forName(Introspector.beanInfoSearchPath[i] + "." + newName).newInstance(); return (BeanInfo)Class.forName(Introspector.beanInfoSearchPath[i] + "." + newName).newInstance();
} }
} catch(ClassNotFoundException E) {
} }
catch(ClassNotFoundException E)
{
}
}
}
catch(IllegalAccessException E)
{
} }
} catch(IllegalAccessException E) { catch(InstantiationException E)
} catch(InstantiationException E) { {
} }
return null; return null;
} }
......
/* java.beans.PropertyVetoException /* PropertyVetoException.java -- thrown to veto a proposed property change
Copyright (C) 1998, 2000 Free Software Foundation, Inc. Copyright (C) 1998, 2000, 2002 Free Software Foundation, Inc.
This file is part of GNU Classpath. This file is part of GNU Classpath.
...@@ -39,30 +39,47 @@ exception statement from your version. */ ...@@ -39,30 +39,47 @@ exception statement from your version. */
package java.beans; package java.beans;
/** /**
** PropertyVetoException is thrown when a VetoableChangeListener doesn't like the proposed change. * PropertyVetoException is thrown when a VetoableChangeListener doesn't
** * like the proposed change.
** @author John Keiser *
** @since JDK1.1 * @author John Keiser
** @version 1.1.0, 31 May 1998 * @see VetoableChangeListener
** @see java.beans.VetoableChangeListener * @since 1.1
**/ * @status updated to 1.4
*/
public class PropertyVetoException extends Exception { public class PropertyVetoException extends Exception
PropertyChangeEvent evt; {
/**
* Compatible with JDK 1.1+.
*/
private static final long serialVersionUID = 129596057694162164L; private static final long serialVersionUID = 129596057694162164L;
/** Instantiate this exception with the given message and property change. /**
** @param msg the reason for the veto. * The vetoed change.
** @param changeEvent the PropertyChangeEvent that was thrown. *
**/ * @serial the event that was vetoed
public PropertyVetoException(String msg, PropertyChangeEvent changeEvent) { */
private final PropertyChangeEvent evt;
/**
* Instantiate this exception with the given message and property change.
*
* @param msg the reason for the veto
* @param changeEvent the PropertyChangeEvent that was thrown
*/
public PropertyVetoException(String msg, PropertyChangeEvent changeEvent)
{
super(msg); super(msg);
evt = changeEvent; evt = changeEvent;
} }
/** Get the PropertyChange event that was vetoed. **/ /**
public PropertyChangeEvent getPropertyChangeEvent() { * Get the PropertyChange event that was vetoed.
*
* @return the vetoed change
*/
public PropertyChangeEvent getPropertyChangeEvent()
{
return evt; return evt;
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment