From: Godmar Back (gback@cs.utah.edu)
Date: Thu Feb 04 1999 - 13:58:35 EST
Tim, have you been working on this?
Does anybody know where this is speced out?
I changed it such that it would include the names (as pointed out by Mo)
and that it would include a property only if it has a set and get method.
Is this what "editable" means? Or such I look for a write method only?
Consider this test:
// Start file PropertyDescriptorBug.java
import java.lang.reflect.*;
import java.beans.*;
import java.util.*;
public class PropertyDescriptorBug {
public static void main(String[] argv) throws Exception {
Class cls = java.awt.Button.class;
BeanInfo beanInfo = Introspector.getBeanInfo(cls);
PropertyDescriptor descriptors[] = beanInfo.getPropertyDescriptors();
for (int i = 0; i < descriptors.length; i++) {
if (descriptors[i] == null) {
throw new NullPointerException("descriptor is null");
}
if (descriptors[i].getName() == null) {
throw new NullPointerException("descriptor.getName() is null");
}
System.out.println(descriptors[i].getClass().getName()
+ " name is " + descriptors[i].getName());
}
}
}
// End file PropertyDescriptorBug.java
With Sun's JDK:
/usr/local/jdk1.1.7/bin/java PropertyDescriptorBug
java.beans.PropertyDescriptor name is enabled
java.beans.PropertyDescriptor name is actionCommand
java.beans.PropertyDescriptor name is foreground
java.beans.PropertyDescriptor name is label
java.beans.PropertyDescriptor name is visible
java.beans.PropertyDescriptor name is background
java.beans.PropertyDescriptor name is font
java.beans.PropertyDescriptor name is name
With Kaffe + classpath's java.beans:
java.beans.PropertyDescriptor name is visible
java.beans.PropertyDescriptor name is background
java.beans.PropertyDescriptor name is enabled
java.beans.PropertyDescriptor name is foreground
java.beans.PropertyDescriptor name is actionCommand
java.beans.PropertyDescriptor name is label
java.beans.PropertyDescriptor name is name
java.beans.PropertyDescriptor name is font
With Kaffe only (after my latest checkins)
java.beans.PropertyDescriptor name is enabled
java.beans.PropertyDescriptor name is foreground
java.beans.PropertyDescriptor name is bounds
java.beans.PropertyDescriptor name is visible
java.beans.PropertyDescriptor name is actionCommand
java.beans.PropertyDescriptor name is label
java.beans.PropertyDescriptor name is name
java.beans.PropertyDescriptor name is font
java.beans.PropertyDescriptor name is cursor
java.beans.PropertyDescriptor name is background
java.beans.IndexedPropertyDescriptor name is size
java.beans.IndexedPropertyDescriptor name is location
java.beans.PropertyDescriptor name is locale
Why don't they include "locale"? It has a
"public void setLocale(Locale)" and a "public Locale getLocale()"
Btw, I found this in classpath's java/beans/ implementation:
** <STRONG>Properties:</STRONG><P>
**
** <OL>
** <LI>If there is a <CODE>public boolean isXXX()</CODE>
** method, then XXX is a read-only boolean property.
** <CODE>boolean getXXX()</CODE> 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
** <CODE>public void setXXX(boolean)</CODE> method,
** it is part of this group and makes it a read-write
** property.</LI>
** <LI>If there is a
** <CODE>public <type> getXXX(int)</CODE>
** method, then XXX is a read-only indexed property of
** type <type>. If there is a
** <CODE>public void setXXX(int,<type>)</CODE>
** method, then it is a read-write indexed property of
** type <type>. There may also be a
** <CODE>public <type>[] getXXX()</CODE> and a
** <CODE>public void setXXX(<type>)</CODE>
** method as well.</CODE></LI>
** <LI>If there is a
** <CODE>public void setXXX(int,<type>)</CODE>
** method, then it is a write-only indexed property of
** type <type>. There may also be a
** <CODE>public <type>[] getXXX()</CODE> and a
** <CODE>public void setXXX(<type>)</CODE>
** method as well.</CODE></LI>
** <LI>If there is a
** <CODE>public <type> getXXX()</CODE> method,
** then XXX is a read-only property of type
** <type>. If there is a
** <CODE>public void setXXX(<type>)</CODE>
** method, then it will be used for the property and
** the property will be considered read-write.</LI>
** <LI>If there is a
** <CODE>public void setXXX(<type>)</CODE>
** 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>.</LI>
** <LI>In all of the above cases, if the setXXX() method
** throws <CODE>PropertyVetoException</CODE>, then the
** property in question is assumed to be constrained.
** No properties are ever assumed to be bound
** (<STRONG>Spec Note:</STRONG> this is not in the
** spec, it just makes sense). See PropertyDescriptor
** for a description of bound and constrained
** properties.</LI>
** </OL>
- Godmar
This archive was generated by hypermail 2b29 : Sat Sep 23 2000 - 19:57:57 EDT