jdk/src/share/classes/java/beans/PropertyDescriptor.java
author malenkov
Wed, 07 May 2008 23:20:32 +0400
changeset 466 6acd5ec503a8
parent 2 90ce3da70b43
child 3241 6fd229e009e7
permissions -rw-r--r--
4935607: RFE: LTP: Should be possible to set the TRANSIENT attribute of propertiies to FALSE Summary: Add the Transient annotation and support it (JSR-273) Reviewed-by: peterz, loneid
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
466
6acd5ec503a8 4935607: RFE: LTP: Should be possible to set the TRANSIENT attribute of propertiies to FALSE
malenkov
parents: 2
diff changeset
     2
 * Copyright 1996-2008 Sun Microsystems, Inc.  All Rights Reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * have any questions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package java.beans;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.lang.ref.Reference;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.lang.reflect.Method;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.lang.reflect.Constructor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * A PropertyDescriptor describes one property that a Java Bean
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * exports via a pair of accessor methods.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
public class PropertyDescriptor extends FeatureDescriptor {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
    private Reference<Class> propertyTypeRef;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
    private Reference<Method> readMethodRef;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
    private Reference<Method> writeMethodRef;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
    private Reference<Class> propertyEditorClassRef;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
    private boolean bound;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
    private boolean constrained;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
    // The base name of the method name which will be prefixed with the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
    // read and write method. If name == "foo" then the baseName is "Foo"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
    private String baseName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    private String writeMethodName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    private String readMethodName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
     * Constructs a PropertyDescriptor for a property that follows
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
     * the standard Java convention by having getFoo and setFoo
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
     * accessor methods.  Thus if the argument name is "fred", it will
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
     * assume that the writer method is "setFred" and the reader method
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
     * is "getFred" (or "isFred" for a boolean property).  Note that the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
     * property name should start with a lower case character, which will
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
     * be capitalized in the method names.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
     * @param propertyName The programmatic name of the property.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
     * @param beanClass The Class object for the target bean.  For
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
     *          example sun.beans.OurButton.class.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
     * @exception IntrospectionException if an exception occurs during
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
     *              introspection.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    public PropertyDescriptor(String propertyName, Class<?> beanClass)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
                throws IntrospectionException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
        this(propertyName, beanClass,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
             Introspector.IS_PREFIX + NameGenerator.capitalize(propertyName),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
             Introspector.SET_PREFIX + NameGenerator.capitalize(propertyName));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     * This constructor takes the name of a simple property, and method
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     * names for reading and writing the property.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     * @param propertyName The programmatic name of the property.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     * @param beanClass The Class object for the target bean.  For
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     *          example sun.beans.OurButton.class.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     * @param readMethodName The name of the method used for reading the property
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     *           value.  May be null if the property is write-only.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     * @param writeMethodName The name of the method used for writing the property
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     *           value.  May be null if the property is read-only.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     * @exception IntrospectionException if an exception occurs during
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     *              introspection.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    public PropertyDescriptor(String propertyName, Class<?> beanClass,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
                String readMethodName, String writeMethodName)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
                throws IntrospectionException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
        if (beanClass == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
            throw new IntrospectionException("Target Bean class is null");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        if (propertyName == null || propertyName.length() == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
            throw new IntrospectionException("bad property name");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
        if ("".equals(readMethodName) || "".equals(writeMethodName)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
            throw new IntrospectionException("read or write method name should not be the empty string");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
        setName(propertyName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
        setClass0(beanClass);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        this.readMethodName = readMethodName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
        if (readMethodName != null && getReadMethod() == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
            throw new IntrospectionException("Method not found: " + readMethodName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
        this.writeMethodName = writeMethodName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
        if (writeMethodName != null && getWriteMethod() == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
            throw new IntrospectionException("Method not found: " + writeMethodName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        // If this class or one of its base classes allow PropertyChangeListener,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
        // then we assume that any properties we discover are "bound".
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
        // See Introspector.getTargetPropertyInfo() method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
        String name = "addPropertyChangeListener";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        Class[] args = {PropertyChangeListener.class};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
        this.bound = (null != Introspector.findMethod(beanClass, name, args.length, args));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     * This constructor takes the name of a simple property, and Method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     * objects for reading and writing the property.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     * @param propertyName The programmatic name of the property.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     * @param readMethod The method used for reading the property value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     *          May be null if the property is write-only.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     * @param writeMethod The method used for writing the property value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     *          May be null if the property is read-only.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     * @exception IntrospectionException if an exception occurs during
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     *              introspection.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
    public PropertyDescriptor(String propertyName, Method readMethod, Method writeMethod)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
                throws IntrospectionException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
        if (propertyName == null || propertyName.length() == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
            throw new IntrospectionException("bad property name");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
        setName(propertyName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        setReadMethod(readMethod);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        setWriteMethod(writeMethod);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     * Creates <code>PropertyDescriptor</code> for the specified bean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     * with the specified name and methods to read/write the property value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     * @param bean   the type of the target bean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     * @param base   the base name of the property (the rest of the method name)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     * @param read   the method used for reading the property value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     * @param write  the method used for writing the property value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     * @exception IntrospectionException if an exception occurs during introspection
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     * @since 1.7
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
    PropertyDescriptor(Class<?> bean, String base, Method read, Method write) throws IntrospectionException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
        if (bean == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
            throw new IntrospectionException("Target Bean class is null");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
        setClass0(bean);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
        setName(Introspector.decapitalize(base));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
        setReadMethod(read);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
        setWriteMethod(write);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
        this.baseName = base;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
     * Gets the Class object for the property.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     * @return The Java type info for the property.  Note that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     * the "Class" object may describe a built-in Java type such as "int".
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     * The result may be "null" if this is an indexed property that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
     * does not support non-indexed access.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
     * This is the type that will be returned by the ReadMethod.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
    public synchronized Class<?> getPropertyType() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
        Class type = getPropertyType0();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
        if (type  == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
                type = findPropertyType(getReadMethod(), getWriteMethod());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
                setPropertyType(type);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
            } catch (IntrospectionException ex) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
                // Fall
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
        return type;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
    private void setPropertyType(Class type) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
        this.propertyTypeRef = getWeakReference(type);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
    private Class getPropertyType0() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
        return (this.propertyTypeRef != null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
                ? this.propertyTypeRef.get()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
                : null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
     * Gets the method that should be used to read the property value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
     * @return The method that should be used to read the property value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
     * May return null if the property can't be read.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
    public synchronized Method getReadMethod() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
        Method readMethod = getReadMethod0();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
        if (readMethod == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
            Class cls = getClass0();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
            if (cls == null || (readMethodName == null && readMethodRef == null)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
                // The read method was explicitly set to null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
                return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
            if (readMethodName == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
                Class type = getPropertyType0();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
                if (type == boolean.class || type == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
                    readMethodName = Introspector.IS_PREFIX + getBaseName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
                    readMethodName = Introspector.GET_PREFIX + getBaseName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
            // Since there can be multiple write methods but only one getter
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
            // method, find the getter method first so that you know what the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
            // property type is.  For booleans, there can be "is" and "get"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
            // methods.  If an "is" method exists, this is the official
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
            // reader method so look for this one first.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
            readMethod = Introspector.findMethod(cls, readMethodName, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
            if (readMethod == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
                readMethodName = Introspector.GET_PREFIX + getBaseName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
                readMethod = Introspector.findMethod(cls, readMethodName, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
                setReadMethod(readMethod);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
            } catch (IntrospectionException ex) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
                // fall
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
        return readMethod;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
     * Sets the method that should be used to read the property value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
     * @param readMethod The new read method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
    public synchronized void setReadMethod(Method readMethod)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
                                throws IntrospectionException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
        if (readMethod == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
            readMethodName = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
            readMethodRef = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
        // The property type is determined by the read method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
        setPropertyType(findPropertyType(readMethod, getWriteMethod0()));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
        setClass0(readMethod.getDeclaringClass());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
        readMethodName = readMethod.getName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
        this.readMethodRef = getSoftReference(readMethod);
466
6acd5ec503a8 4935607: RFE: LTP: Should be possible to set the TRANSIENT attribute of propertiies to FALSE
malenkov
parents: 2
diff changeset
   259
        setTransient(readMethod.getAnnotation(Transient.class));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
     * Gets the method that should be used to write the property value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
     * @return The method that should be used to write the property value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
     * May return null if the property can't be written.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
    public synchronized Method getWriteMethod() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
        Method writeMethod = getWriteMethod0();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
        if (writeMethod == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
            Class cls = getClass0();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
            if (cls == null || (writeMethodName == null && writeMethodRef == null)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
                // The write method was explicitly set to null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
                return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
            // We need the type to fetch the correct method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
            Class type = getPropertyType0();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
            if (type == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
                try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
                    // Can't use getPropertyType since it will lead to recursive loop.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
                    type = findPropertyType(getReadMethod(), null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
                    setPropertyType(type);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
                } catch (IntrospectionException ex) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
                    // Without the correct property type we can't be guaranteed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
                    // to find the correct method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
                    return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
            if (writeMethodName == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
                writeMethodName = Introspector.SET_PREFIX + getBaseName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
            writeMethod = Introspector.findMethod(cls, writeMethodName, 1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
                          (type == null) ? null : new Class[] { type });
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
                setWriteMethod(writeMethod);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
            } catch (IntrospectionException ex) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
                // fall through
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
        return writeMethod;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
     * Sets the method that should be used to write the property value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
     * @param writeMethod The new write method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
    public synchronized void setWriteMethod(Method writeMethod)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
                                throws IntrospectionException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
        if (writeMethod == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
            writeMethodName = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
            writeMethodRef = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
        // Set the property type - which validates the method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
        setPropertyType(findPropertyType(getReadMethod(), writeMethod));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
        setClass0(writeMethod.getDeclaringClass());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
        writeMethodName = writeMethod.getName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
        this.writeMethodRef = getSoftReference(writeMethod);
466
6acd5ec503a8 4935607: RFE: LTP: Should be possible to set the TRANSIENT attribute of propertiies to FALSE
malenkov
parents: 2
diff changeset
   324
        setTransient(writeMethod.getAnnotation(Transient.class));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
    private Method getReadMethod0() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
        return (this.readMethodRef != null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
                ? this.readMethodRef.get()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
                : null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
    private Method getWriteMethod0() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
        return (this.writeMethodRef != null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
                ? this.writeMethodRef.get()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
                : null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
     * Overridden to ensure that a super class doesn't take precedent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
    void setClass0(Class clz) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
        if (getClass0() != null && clz.isAssignableFrom(getClass0())) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
            // dont replace a subclass with a superclass
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
        super.setClass0(clz);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
     * Updates to "bound" properties will cause a "PropertyChange" event to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
     * get fired when the property is changed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
     * @return True if this is a bound property.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
    public boolean isBound() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
        return bound;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
     * Updates to "bound" properties will cause a "PropertyChange" event to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
     * get fired when the property is changed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
     * @param bound True if this is a bound property.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
    public void setBound(boolean bound) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
        this.bound = bound;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
     * Attempted updates to "Constrained" properties will cause a "VetoableChange"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
     * event to get fired when the property is changed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
     * @return True if this is a constrained property.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
    public boolean isConstrained() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
        return constrained;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
     * Attempted updates to "Constrained" properties will cause a "VetoableChange"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
     * event to get fired when the property is changed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
     * @param constrained True if this is a constrained property.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
    public void setConstrained(boolean constrained) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
        this.constrained = constrained;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
     * Normally PropertyEditors will be found using the PropertyEditorManager.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
     * However if for some reason you want to associate a particular
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
     * PropertyEditor with a given property, then you can do it with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
     * this method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
     * @param propertyEditorClass  The Class for the desired PropertyEditor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
    public void setPropertyEditorClass(Class<?> propertyEditorClass) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
        this.propertyEditorClassRef = getWeakReference((Class)propertyEditorClass);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
     * Gets any explicit PropertyEditor Class that has been registered
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
     * for this property.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
     * @return Any explicit PropertyEditor Class that has been registered
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
     *          for this property.  Normally this will return "null",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
     *          indicating that no special editor has been registered,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
     *          so the PropertyEditorManager should be used to locate
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
     *          a suitable PropertyEditor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
    public Class<?> getPropertyEditorClass() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
        return (this.propertyEditorClassRef != null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
                ? this.propertyEditorClassRef.get()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
                : null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
     * Constructs an instance of a property editor using the current
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
     * property editor class.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
     * If the property editor class has a public constructor that takes an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
     * Object argument then it will be invoked using the bean parameter
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
     * as the argument. Otherwise, the default constructor will be invoked.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
     * @param bean the source object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
     * @return a property editor instance or null if a property editor has
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
     *         not been defined or cannot be created
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
     * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
    public PropertyEditor createPropertyEditor(Object bean) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
        Object editor = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
        Class cls = getPropertyEditorClass();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
        if (cls != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
            Constructor ctor = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
            if (bean != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
                try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
                    ctor = cls.getConstructor(new Class[] { Object.class });
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
                } catch (Exception ex) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
                    // Fall through
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
                if (ctor == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
                    editor = cls.newInstance();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
                    editor = ctor.newInstance(new Object[] { bean });
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
            } catch (Exception ex) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
                // A serious error has occured.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
                // Proably due to an invalid property editor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
                throw new RuntimeException("PropertyEditor not instantiated",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
                                           ex);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
        return (PropertyEditor)editor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
     * Compares this <code>PropertyDescriptor</code> against the specified object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
     * Returns true if the objects are the same. Two <code>PropertyDescriptor</code>s
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
     * are the same if the read, write, property types, property editor and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
     * flags  are equivalent.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
    public boolean equals(Object obj) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
        if (this == obj) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
            return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
        if (obj != null && obj instanceof PropertyDescriptor) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
            PropertyDescriptor other = (PropertyDescriptor)obj;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
            Method otherReadMethod = other.getReadMethod();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
            Method otherWriteMethod = other.getWriteMethod();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
            if (!compareMethods(getReadMethod(), otherReadMethod)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
                return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
            if (!compareMethods(getWriteMethod(), otherWriteMethod)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
                return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
            if (getPropertyType() == other.getPropertyType() &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
                getPropertyEditorClass() == other.getPropertyEditorClass() &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
                bound == other.isBound() && constrained == other.isConstrained() &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
                writeMethodName == other.writeMethodName &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
                readMethodName == other.readMethodName) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
                return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
        return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
     * Package private helper method for Descriptor .equals methods.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
     * @param a first method to compare
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
     * @param b second method to compare
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
     * @return boolean to indicate that the methods are equivalent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
    boolean compareMethods(Method a, Method b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
        // Note: perhaps this should be a protected method in FeatureDescriptor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
        if ((a == null) != (b == null)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
        if (a != null && b != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
            if (!a.equals(b)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
                return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
        return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
     * Package-private constructor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
     * Merge two property descriptors.  Where they conflict, give the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
     * second argument (y) priority over the first argument (x).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
     * @param x  The first (lower priority) PropertyDescriptor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
     * @param y  The second (higher priority) PropertyDescriptor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
    PropertyDescriptor(PropertyDescriptor x, PropertyDescriptor y) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
        super(x,y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
        if (y.baseName != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
            baseName = y.baseName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
            baseName = x.baseName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
        if (y.readMethodName != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
            readMethodName = y.readMethodName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
            readMethodName = x.readMethodName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
        if (y.writeMethodName != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
            writeMethodName = y.writeMethodName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
            writeMethodName = x.writeMethodName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
        if (y.propertyTypeRef != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
            propertyTypeRef = y.propertyTypeRef;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
            propertyTypeRef = x.propertyTypeRef;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
        // Figure out the merged read method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
        Method xr = x.getReadMethod();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
        Method yr = y.getReadMethod();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
        // Normally give priority to y's readMethod.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
            if (yr != null && yr.getDeclaringClass() == getClass0()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
                setReadMethod(yr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
                setReadMethod(xr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
        } catch (IntrospectionException ex) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
            // fall through
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
        // However, if both x and y reference read methods in the same class,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
        // give priority to a boolean "is" method over a boolean "get" method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
        if (xr != null && yr != null &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
                   xr.getDeclaringClass() == yr.getDeclaringClass() &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
                   getReturnType(getClass0(), xr) == boolean.class &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
                   getReturnType(getClass0(), yr) == boolean.class &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
                   xr.getName().indexOf(Introspector.IS_PREFIX) == 0 &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
                   yr.getName().indexOf(Introspector.GET_PREFIX) == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
                setReadMethod(xr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
            } catch (IntrospectionException ex) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
                // fall through
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
        Method xw = x.getWriteMethod();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
        Method yw = y.getWriteMethod();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
            if (yw != null && yw.getDeclaringClass() == getClass0()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
                setWriteMethod(yw);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
                setWriteMethod(xw);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
        } catch (IntrospectionException ex) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
            // Fall through
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
        if (y.getPropertyEditorClass() != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
            setPropertyEditorClass(y.getPropertyEditorClass());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
            setPropertyEditorClass(x.getPropertyEditorClass());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
        bound = x.bound | y.bound;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
        constrained = x.constrained | y.constrained;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
     * Package-private dup constructor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
     * This must isolate the new object from any changes to the old object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
    PropertyDescriptor(PropertyDescriptor old) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
        super(old);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
        propertyTypeRef = old.propertyTypeRef;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
        readMethodRef = old.readMethodRef;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
        writeMethodRef = old.writeMethodRef;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
        propertyEditorClassRef = old.propertyEditorClassRef;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
        writeMethodName = old.writeMethodName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
        readMethodName = old.readMethodName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
        baseName = old.baseName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
        bound = old.bound;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
        constrained = old.constrained;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
     * Returns the property type that corresponds to the read and write method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
     * The type precedence is given to the readMethod.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
     * @return the type of the property descriptor or null if both
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
     *         read and write methods are null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
     * @throws IntrospectionException if the read or write method is invalid
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
    private Class findPropertyType(Method readMethod, Method writeMethod)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
        throws IntrospectionException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
        Class propertyType = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
            if (readMethod != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
                Class[] params = getParameterTypes(getClass0(), readMethod);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
                if (params.length != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
                    throw new IntrospectionException("bad read method arg count: "
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
                                                     + readMethod);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
                propertyType = getReturnType(getClass0(), readMethod);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
                if (propertyType == Void.TYPE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
                    throw new IntrospectionException("read method " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
                                        readMethod.getName() + " returns void");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
            if (writeMethod != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
                Class params[] = getParameterTypes(getClass0(), writeMethod);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
                if (params.length != 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
                    throw new IntrospectionException("bad write method arg count: "
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
                                                     + writeMethod);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
                if (propertyType != null && propertyType != params[0]) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
                    throw new IntrospectionException("type mismatch between read and write methods");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
                propertyType = params[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
        } catch (IntrospectionException ex) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
            throw ex;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
        return propertyType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
     * Returns a hash code value for the object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
     * See {@link java.lang.Object#hashCode} for a complete description.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
     * @return a hash code value for this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
     * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
    public int hashCode() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
        int result = 7;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
        result = 37 * result + ((getPropertyType() == null) ? 0 :
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
                                getPropertyType().hashCode());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
        result = 37 * result + ((getReadMethod() == null) ? 0 :
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
                                getReadMethod().hashCode());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
        result = 37 * result + ((getWriteMethod() == null) ? 0 :
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
                                getWriteMethod().hashCode());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
        result = 37 * result + ((getPropertyEditorClass() == null) ? 0 :
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
                                getPropertyEditorClass().hashCode());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
        result = 37 * result + ((writeMethodName == null) ? 0 :
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
                                writeMethodName.hashCode());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
        result = 37 * result + ((readMethodName == null) ? 0 :
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
                                readMethodName.hashCode());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
        result = 37 * result + getName().hashCode();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
        result = 37 * result + ((bound == false) ? 0 : 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
        result = 37 * result + ((constrained == false) ? 0 : 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
        return result;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
    // Calculate once since capitalize() is expensive.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
    String getBaseName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
        if (baseName == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
            baseName = NameGenerator.capitalize(getName());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
        return baseName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
    public String toString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
        String message = "name=" + getName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
        message += ", class=" + getClass0();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
        message += ", type=" + getPropertyType();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
        message += ", writeMethod=";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
        message += writeMethodName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
        message += ", readMethod=";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
        message += readMethodName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
        message += ", bound=" + bound;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
        message += ", constrained=" + constrained;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
        return message;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
}