diff --git a/libjava/ChangeLog b/libjava/ChangeLog index 5153b6c45151..fa71bbc26702 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,3 +1,13 @@ +2004-11-18 Robert Schuster
+ + Complete 1.4 support + * java/beans/PropertyDescriptor.java: + (setReadMethod): New method + (setWriteMethod): New method + (equals): Implemented (1.4) + (checkMethods): operates on arguments now (private) + + 2004-11-18 Mattias Rehnbergget<name>()
- ** (or, optionally, if the property is boolean,
- ** is<name>()
) and
- ** set<name>()
in class
- ** <beanClass>
, where <name> has its
- ** first letter capitalized by the constructor.- ** - ** Implementation note: If there is both are both isXXX and - ** getXXX methods, the former is used in preference to the latter. - ** We do not check that an isXXX method returns a boolean. In both - ** cases, this matches the behaviour of JDK 1.4
- ** - ** @param name the programmatic name of the property, usually - ** starting with a lowercase letter (e.g. fooManChu - ** instead of FooManChu). - ** @param beanClass the class the get and set methods live in. - ** @exception IntrospectionException if the methods are not found - ** or invalid. - **/ - public PropertyDescriptor(String name, Class beanClass) - throws IntrospectionException - { - setName(name); - if (name.length() == 0) { - throw new IntrospectionException("empty property name"); - } - String caps = Character.toUpperCase(name.charAt(0)) + name.substring(1); - findMethods(beanClass, "is" + caps, "get" + caps, "set" + caps); - if (getMethod == null) { - throw new IntrospectionException("Cannot find an is" + caps + - " or get" + caps + " method"); - } - if (setMethod == null) { - throw new IntrospectionException("Cannot find a " + caps + " method"); - } - checkMethods(); - } - - /** Create a new PropertyDescriptor by introspection. - ** This form of constructor allows you to specify the - ** names of the get and set methods to search for.
- ** - ** Implementation note: If there is a get method (or - ** boolean isXXX() method), then the return type of that method - ** is used to find the set method. If there is no get method, - ** then the set method is searched for exhaustively.
- ** - ** Spec note: - ** If there is no get method and multiple set methods with - ** the same name and a single parameter (different type of course), - ** then an IntrospectionException is thrown. While Sun's spec - ** does not state this, it can make Bean behavior different on - ** different systems (since method order is not guaranteed) and as - ** such, can be treated as a bug in the spec. I am not aware of - ** whether Sun's implementation catches this. - ** - ** @param name the programmatic name of the property, usually - ** starting with a lowercase letter (e.g. fooManChu - ** instead of FooManChu). - ** @param beanClass the class the get and set methods live in. - ** @param getMethodName the name of the get method. - ** @param setMethodName the name of the set method. - ** @exception IntrospectionException if the methods are not found - ** or invalid. - **/ - public PropertyDescriptor(String name, Class beanClass, - String getMethodName, String setMethodName) - throws IntrospectionException - { - setName(name); - findMethods(beanClass, getMethodName, null, setMethodName); - if (getMethod == null && getMethodName != null) { - throw new IntrospectionException("Cannot find a getter method called " + - getMethodName); - } - if (setMethod == null && setMethodName != null) { - throw new IntrospectionException("Cannot find a setter method called " + - setMethodName); - } - checkMethods(); - } - - /** Create a new PropertyDescriptor using explicit Methods. - ** Note that the methods will be checked for conformance to standard - ** Property method rules, as described above at the top of this class. - ** - ** @param name the programmatic name of the property, usually - ** starting with a lowercase letter (e.g. fooManChu - ** instead of FooManChu). - ** @param getMethod the get method. - ** @param setMethod the set method. - ** @exception IntrospectionException if the methods are not found - ** or invalid. - **/ - public PropertyDescriptor(String name, Method getMethod, Method setMethod) - throws IntrospectionException - { - setName(name); - this.getMethod = getMethod; - this.setMethod = setMethod; - if (getMethod != null) { - this.propertyType = getMethod.getReturnType(); - } - else if (setMethod != null) { - this.propertyType = setMethod.getParameterTypes()[0]; - } - checkMethods(); - } - - /** Get the property type. - ** This is the type the get method returns and the set method - ** takes in. - **/ - public Class getPropertyType() { - return propertyType; - } - - /** Get the get method. Why they call it readMethod here and - ** get everywhere else is beyond me. - **/ - public Method getReadMethod() { - return getMethod; - } - - /** Get the set method. Why they call it writeMethod here and - ** set everywhere else is beyond me. - **/ - public Method getWriteMethod() { - return setMethod; - } - - /** Get whether the property is bound. Defaults to false. **/ - public boolean isBound() { - return bound; - } - - /** Set whether the property is bound. - ** As long as the the bean implements addPropertyChangeListener() and - ** removePropertyChangeListener(), setBound(true) may safely be called.
- ** If these things are not true, then the behavior of the system - ** will be undefined.
- **
- ** When a property is bound, its set method is required to fire the
- ** PropertyChangeListener.propertyChange())
event
- ** after the value has changed.
- ** @param bound whether the property is bound or not.
- **/
- public void setBound(boolean bound) {
- this.bound = bound;
- }
-
- /** Get whether the property is constrained. Defaults to false. **/
- public boolean isConstrained() {
- return constrained;
- }
-
- /** Set whether the property is constrained.
- ** If the set method throws java.beans.PropertyVetoException
- ** (or subclass thereof) and the bean implements addVetoableChangeListener()
- ** and removeVetoableChangeListener(), then setConstrained(true) may safely
- ** be called. Otherwise, the system behavior is undefined.
- ** Spec note: given those strict parameters, it would be nice if it
- ** got set automatically by detection, but oh well.
- ** When a property is constrained, its set method is required to:
- **
VetoableChangeListener.vetoableChange()
- ** event notifying others of the change and allowing them a chance to
- ** say it is a bad thing.get<name>()
+ ** (or, optionally, if the property is boolean,
+ ** is<name>()
) and
+ ** set<name>()
in class
+ ** <beanClass>
, where <name> has its
+ ** first letter capitalized by the constructor.
+ **
+ ** Note that using this constructor the given property must be read- and
+ ** writeable. If the implementation does not both, a read and a write method, an
+ ** IntrospectionException
is thrown.
+ **
+ ** Implementation note: If there is both are both isXXX and
+ ** getXXX methods, the former is used in preference to the latter.
+ ** We do not check that an isXXX method returns a boolean. In both
+ ** cases, this matches the behaviour of JDK 1.4
+ ** + ** @param name the programmatic name of the property, usually + ** starting with a lowercase letter (e.g. fooManChu + ** instead of FooManChu). + ** @param beanClass the class the get and set methods live in. + ** @exception IntrospectionException if the methods are not found + ** or invalid. + **/ + public PropertyDescriptor(String name, Class beanClass) + throws IntrospectionException + { + setName(name); + if (name.length() == 0) + { + throw new IntrospectionException("empty property name"); + } + String caps = Character.toUpperCase(name.charAt(0)) + name.substring(1); + findMethods(beanClass, "is" + caps, "get" + caps, "set" + caps); + + if (getMethod == null) + { + throw new IntrospectionException( + "Cannot find a is" + caps + " or get" + caps + " method"); + } + + if (setMethod == null) + { + throw new IntrospectionException( + "Cannot find a " + caps + " method"); + } + + // finally check the methods compatibility + checkMethods(getMethod, setMethod); } - if (setMethod != null) { - if (setMethod.getParameterTypes().length != 1) { - String msg = "set method does not have exactly one parameter"; - throw new IntrospectionException(msg); - } - if (getMethod == null) { - propertyType = setMethod.getParameterTypes()[0]; - } - else { - if (!propertyType.equals(setMethod.getParameterTypes()[0])) { - String msg = "set and get methods do not share the same type"; - throw new IntrospectionException(msg); - } - if ((!getMethod.getDeclaringClass(). - isAssignableFrom(setMethod.getDeclaringClass())) && - (!setMethod.getDeclaringClass(). - isAssignableFrom(getMethod.getDeclaringClass()))) { - String msg = "set and get methods are not in the same class."; - throw new IntrospectionException(msg); - } - } + + /** Create a new PropertyDescriptor by introspection. + ** This form of constructor allows you to specify the + ** names of the get and set methods to search for.
+ ** + ** Implementation note: If there is a get method (or + ** boolean isXXX() method), then the return type of that method + ** is used to find the set method. If there is no get method, + ** then the set method is searched for exhaustively.
+ **
+ ** Spec note:
+ ** If there is no get method and multiple set methods with
+ ** the same name and a single parameter (different type of course),
+ ** then an IntrospectionException is thrown. While Sun's spec
+ ** does not state this, it can make Bean behavior different on
+ ** different systems (since method order is not guaranteed) and as
+ ** such, can be treated as a bug in the spec. I am not aware of
+ ** whether Sun's implementation catches this.
+ **
+ ** @param name the programmatic name of the property, usually
+ ** starting with a lowercase letter (e.g. fooManChu
+ ** instead of FooManChu).
+ ** @param beanClass the class the get and set methods live in.
+ ** @param getMethodName the name of the get method or null
if the property is write-only.
+ ** @param setMethodName the name of the set method or null
if the property is read-only.
+ ** @exception IntrospectionException if the methods are not found
+ ** or invalid.
+ **/
+ public PropertyDescriptor(
+ String name,
+ Class beanClass,
+ String getMethodName,
+ String setMethodName)
+ throws IntrospectionException
+ {
+ setName(name);
+ findMethods(beanClass, getMethodName, null, setMethodName);
+
+ if (getMethod == null && getMethodName != null)
+ {
+ throw new IntrospectionException(
+ "Cannot find a getter method called " + getMethodName);
+ }
+
+ if (setMethod == null && setMethodName != null)
+ {
+ throw new IntrospectionException(
+ "Cannot find a setter method called " + setMethodName);
+ }
+
+ checkMethods(getMethod, setMethod);
}
- }
+
+ /** Create a new PropertyDescriptor using explicit Methods.
+ ** Note that the methods will be checked for conformance to standard
+ ** Property method rules, as described above at the top of this class.
+ **
+ ** It is possible to call this method with both Method
arguments
+ ** being null
. In such a case the property type is null
.
+ **
+ ** @param name the programmatic name of the property, usually
+ ** starting with a lowercase letter (e.g. fooManChu
+ ** instead of FooManChu).
+ ** @param readMethod the read method or null
if the property is write-only.
+ ** @param writeMethod the write method or null
if the property is read-only.
+ ** @exception IntrospectionException if the methods are not found
+ ** or invalid.
+ **/
+ public PropertyDescriptor(
+ String name,
+ Method readMethod,
+ Method writeMethod)
+ throws IntrospectionException
+ {
+ setName(name);
+ getMethod = readMethod;
+ setMethod = writeMethod;
+
+ if (getMethod != null)
+ {
+ this.propertyType = getMethod.getReturnType();
+ }
+ else if (setMethod != null)
+ {
+ this.propertyType = setMethod.getParameterTypes()[0];
+ }
+
+ checkMethods(getMethod, setMethod);
+ }
+
+ /** Get the property type.
+ ** This is the type the get method returns and the set method
+ ** takes in.
+ **/
+ public Class getPropertyType()
+ {
+ return propertyType;
+ }
+
+ /** Get the get method. Why they call it readMethod here and
+ ** get everywhere else is beyond me.
+ **/
+ public Method getReadMethod()
+ {
+ return getMethod;
+ }
+
+ /** Sets the read method.
+ * The read method is used to retrieve the value of a property. A legal
+ * read method must have no arguments. Its return type must not be
+ * void
. If this methods succeeds the property type
+ * is adjusted to the return type of the read method.
+ *
+ * It is legal to set the read and the write method to null
+ * or provide method which have been declared in distinct classes.
+ *
+ * @param readMethod The new method to be used or null
.
+ * @throws IntrospectionException If the given method is invalid.
+ * @since 1.2
+ */
+ public void setReadMethod(Method readMethod) throws IntrospectionException
+ {
+ checkMethods(readMethod, setMethod);
+
+ getMethod = readMethod;
+ }
+
+ /** Get the set method. Why they call it writeMethod here and
+ ** set everywhere else is beyond me.
+ **/
+ public Method getWriteMethod()
+ {
+ return setMethod;
+ }
+
+ /** Sets the write method.
+ * The write method is used to set the value of a property. A legal write method
+ * must have a single argument which can be assigned to the property. If no
+ * read method exists the property type changes to the argument type of the
+ * write method.
+ *
+ * It is legal to set the read and the write method to null
+ * or provide method which have been declared in distinct classes.
+ *
+ * @param writeMethod The new method to be used or null
.
+ * @throws IntrospectionException If the given method is invalid.
+ * @since 1.2
+ */
+ public void setWriteMethod(Method writeMethod)
+ throws IntrospectionException
+ {
+ propertyType = checkMethods(getMethod, writeMethod);
+
+ setMethod = writeMethod;
+ }
+
+ /** Get whether the property is bound. Defaults to false. **/
+ public boolean isBound()
+ {
+ return bound;
+ }
+
+ /** Set whether the property is bound.
+ ** As long as the the bean implements addPropertyChangeListener() and
+ ** removePropertyChangeListener(), setBound(true) may safely be called.
+ ** If these things are not true, then the behavior of the system + ** will be undefined.
+ **
+ ** When a property is bound, its set method is required to fire the
+ ** PropertyChangeListener.propertyChange())
event
+ ** after the value has changed.
+ ** @param bound whether the property is bound or not.
+ **/
+ public void setBound(boolean bound)
+ {
+ this.bound = bound;
+ }
+
+ /** Get whether the property is constrained. Defaults to false. **/
+ public boolean isConstrained()
+ {
+ return constrained;
+ }
+
+ /** Set whether the property is constrained.
+ ** If the set method throws java.beans.PropertyVetoException
+ ** (or subclass thereof) and the bean implements addVetoableChangeListener()
+ ** and removeVetoableChangeListener(), then setConstrained(true) may safely
+ ** be called. Otherwise, the system behavior is undefined.
+ ** Spec note: given those strict parameters, it would be nice if it
+ ** got set automatically by detection, but oh well.
+ ** When a property is constrained, its set method is required to:
+ **
VetoableChangeListener.vetoableChange()
+ ** event notifying others of the change and allowing them a chance to
+ ** say it is a bad thing.Method
instances are legal read and
+ * write methods. The following requirements must be met:PropertyDescriptor
against the
+ * given object.
+ * Two PropertyDescriptors are equals if
+ *