jdk/src/share/classes/java/beans/EventSetDescriptor.java
author duke
Sat, 01 Dec 2007 00:00:00 +0000
changeset 2 90ce3da70b43
child 466 6acd5ec503a8
permissions -rw-r--r--
Initial load
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
 * Copyright 1996-2005 Sun Microsystems, Inc.  All Rights Reserved.
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
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * An EventSetDescriptor describes a group of events that a given Java
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * bean fires.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * The given group of events are all delivered as method calls on a single
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * event listener interface, and an event listener object can be registered
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * via a call on a registration method supplied by the event source.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
public class EventSetDescriptor extends FeatureDescriptor {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
    private MethodDescriptor[] listenerMethodDescriptors;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
    private MethodDescriptor addMethodDescriptor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
    private MethodDescriptor removeMethodDescriptor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
    private MethodDescriptor getMethodDescriptor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
    private Reference<Method[]> listenerMethodsRef;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
    private Reference<Class> listenerTypeRef;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    private boolean unicast;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    private boolean inDefaultEventSet = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
     * Creates an <TT>EventSetDescriptor</TT> assuming that you are
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
     * following the most simple standard design pattern where a named
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
     * event &quot;fred&quot; is (1) delivered as a call on the single method of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
     * interface FredListener, (2) has a single argument of type FredEvent,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
     * and (3) where the FredListener may be registered with a call on an
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
     * addFredListener method of the source component and removed with a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
     * call on a removeFredListener method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
     * @param sourceClass  The class firing the event.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
     * @param eventSetName  The programmatic name of the event.  E.g. &quot;fred&quot;.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
     *          Note that this should normally start with a lower-case character.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
     * @param listenerType  The target interface that events
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
     *          will get delivered to.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
     * @param listenerMethodName  The method that will get called when the event gets
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
     *          delivered to its target listener interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
     * @exception IntrospectionException if an exception occurs during
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
     *              introspection.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    public EventSetDescriptor(Class<?> sourceClass, String eventSetName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
                Class<?> listenerType, String listenerMethodName)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
                throws IntrospectionException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
        this(sourceClass, eventSetName, listenerType,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
             new String[] { listenerMethodName },
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
             Introspector.ADD_PREFIX + getListenerClassName(listenerType),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
             Introspector.REMOVE_PREFIX + getListenerClassName(listenerType),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
             Introspector.GET_PREFIX + getListenerClassName(listenerType) + "s");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
        String eventName = NameGenerator.capitalize(eventSetName) + "Event";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
        Method[] listenerMethods = getListenerMethods();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
        if (listenerMethods.length > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
            Class[] args = getParameterTypes(getClass0(), listenerMethods[0]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
            // Check for EventSet compliance. Special case for vetoableChange. See 4529996
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
            if (!"vetoableChange".equals(eventSetName) && !args[0].getName().endsWith(eventName)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
                throw new IntrospectionException("Method \"" + listenerMethodName +
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
                                                 "\" should have argument \"" +
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
                                                 eventName + "\"");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    private static String getListenerClassName(Class cls) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
        String className = cls.getName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        return className.substring(className.lastIndexOf('.') + 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     * Creates an <TT>EventSetDescriptor</TT> from scratch using
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     * string names.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     * @param sourceClass  The class firing the event.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     * @param eventSetName The programmatic name of the event set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     *          Note that this should normally start with a lower-case character.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     * @param listenerType  The Class of the target interface that events
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     *          will get delivered to.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     * @param listenerMethodNames The names of the methods that will get called
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     *          when the event gets delivered to its target listener interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     * @param addListenerMethodName  The name of the method on the event source
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     *          that can be used to register an event listener object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     * @param removeListenerMethodName  The name of the method on the event source
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     *          that can be used to de-register an event listener object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     * @exception IntrospectionException if an exception occurs during
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     *              introspection.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    public EventSetDescriptor(Class<?> sourceClass,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
                String eventSetName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
                Class<?> listenerType,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
                String listenerMethodNames[],
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
                String addListenerMethodName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
                String removeListenerMethodName)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
                throws IntrospectionException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
        this(sourceClass, eventSetName, listenerType,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
             listenerMethodNames, addListenerMethodName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
             removeListenerMethodName, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     * This constructor creates an EventSetDescriptor from scratch using
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     * string names.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     * @param sourceClass  The class firing the event.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     * @param eventSetName The programmatic name of the event set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     *          Note that this should normally start with a lower-case character.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
     * @param listenerType  The Class of the target interface that events
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     *          will get delivered to.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     * @param listenerMethodNames The names of the methods that will get called
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
     *          when the event gets delivered to its target listener interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
     * @param addListenerMethodName  The name of the method on the event source
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
     *          that can be used to register an event listener object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
     * @param removeListenerMethodName  The name of the method on the event source
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
     *          that can be used to de-register an event listener object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     * @param getListenerMethodName The method on the event source that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     *          can be used to access the array of event listener objects.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     * @exception IntrospectionException if an exception occurs during
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     *              introspection.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
    public EventSetDescriptor(Class<?> sourceClass,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
                String eventSetName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
                Class<?> listenerType,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
                String listenerMethodNames[],
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
                String addListenerMethodName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
                String removeListenerMethodName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
                String getListenerMethodName)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
                throws IntrospectionException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
        if (sourceClass == null || eventSetName == null || listenerType == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
            throw new NullPointerException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
        setName(eventSetName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
        setClass0(sourceClass);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
        setListenerType(listenerType);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
        Method[] listenerMethods = new Method[listenerMethodNames.length];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
        for (int i = 0; i < listenerMethodNames.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
            // Check for null names
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
            if (listenerMethodNames[i] == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
                throw new NullPointerException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
            listenerMethods[i] = getMethod(listenerType, listenerMethodNames[i], 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
        setListenerMethods(listenerMethods);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
        setAddListenerMethod(getMethod(sourceClass, addListenerMethodName, 1));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
        setRemoveListenerMethod(getMethod(sourceClass, removeListenerMethodName, 1));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
        // Be more forgiving of not finding the getListener method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
        Method method = Introspector.findMethod(sourceClass,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
                                                getListenerMethodName, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
        if (method != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
            setGetListenerMethod(method);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
    private static Method getMethod(Class cls, String name, int args)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
        throws IntrospectionException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
        if (name == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
        Method method = Introspector.findMethod(cls, name, args);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
        if (method == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
            throw new IntrospectionException("Method not found: " + name +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
                                             " on class " + cls.getName());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
        return method;
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
     * Creates an <TT>EventSetDescriptor</TT> from scratch using
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
     * <TT>java.lang.reflect.Method</TT> and <TT>java.lang.Class</TT> objects.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
     * @param eventSetName The programmatic name of the event set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
     * @param listenerType The Class for the listener interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
     * @param listenerMethods  An array of Method objects describing each
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
     *          of the event handling methods in the target listener.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
     * @param addListenerMethod  The method on the event source
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     *          that can be used to register an event listener object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     * @param removeListenerMethod  The method on the event source
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
     *          that can be used to de-register an event listener object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
     * @exception IntrospectionException if an exception occurs during
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     *              introspection.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
    public EventSetDescriptor(String eventSetName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
                Class<?> listenerType,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
                Method listenerMethods[],
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
                Method addListenerMethod,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
                Method removeListenerMethod)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
                throws IntrospectionException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
        this(eventSetName, listenerType, listenerMethods,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
             addListenerMethod, removeListenerMethod, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
     * This constructor creates an EventSetDescriptor from scratch using
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
     * java.lang.reflect.Method and java.lang.Class objects.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
     * @param eventSetName The programmatic name of the event set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
     * @param listenerType The Class for the listener interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
     * @param listenerMethods  An array of Method objects describing each
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
     *          of the event handling methods in the target listener.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
     * @param addListenerMethod  The method on the event source
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
     *          that can be used to register an event listener object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
     * @param removeListenerMethod  The method on the event source
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
     *          that can be used to de-register an event listener object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
     * @param getListenerMethod The method on the event source
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
     *          that can be used to access the array of event listener objects.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
     * @exception IntrospectionException if an exception occurs during
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
     *              introspection.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
    public EventSetDescriptor(String eventSetName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
                Class<?> listenerType,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
                Method listenerMethods[],
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
                Method addListenerMethod,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
                Method removeListenerMethod,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
                Method getListenerMethod)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
                throws IntrospectionException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
        setName(eventSetName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
        setListenerMethods(listenerMethods);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
        setAddListenerMethod(addListenerMethod);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
        setRemoveListenerMethod( removeListenerMethod);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
        setGetListenerMethod(getListenerMethod);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
        setListenerType(listenerType);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
     * Creates an <TT>EventSetDescriptor</TT> from scratch using
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
     * <TT>java.lang.reflect.MethodDescriptor</TT> and <TT>java.lang.Class</TT>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
     *  objects.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
     * @param eventSetName The programmatic name of the event set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
     * @param listenerType The Class for the listener interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
     * @param listenerMethodDescriptors  An array of MethodDescriptor objects
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
     *           describing each of the event handling methods in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
     *           target listener.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
     * @param addListenerMethod  The method on the event source
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
     *          that can be used to register an event listener object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
     * @param removeListenerMethod  The method on the event source
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
     *          that can be used to de-register an event listener object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
     * @exception IntrospectionException if an exception occurs during
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
     *              introspection.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
    public EventSetDescriptor(String eventSetName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
                Class<?> listenerType,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
                MethodDescriptor listenerMethodDescriptors[],
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
                Method addListenerMethod,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
                Method removeListenerMethod)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
                throws IntrospectionException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
        setName(eventSetName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
        this.listenerMethodDescriptors = listenerMethodDescriptors;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
        setAddListenerMethod(addListenerMethod);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
        setRemoveListenerMethod(removeListenerMethod);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
        setListenerType(listenerType);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
     * Gets the <TT>Class</TT> object for the target interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
     * @return The Class object for the target interface that will
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
     * get invoked when the event is fired.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
    public Class<?> getListenerType() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
        return (this.listenerTypeRef != null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
                ? this.listenerTypeRef.get()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
                : null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
    private void setListenerType(Class cls) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
        this.listenerTypeRef = getWeakReference(cls);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
     * Gets the methods of the target listener interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
     * @return An array of <TT>Method</TT> objects for the target methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
     * within the target listener interface that will get called when
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
     * events are fired.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
    public synchronized Method[] getListenerMethods() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
        Method[] methods = getListenerMethods0();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
        if (methods == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
            if (listenerMethodDescriptors != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
                methods = new Method[listenerMethodDescriptors.length];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
                for (int i = 0; i < methods.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
                    methods[i] = listenerMethodDescriptors[i].getMethod();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
            setListenerMethods(methods);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
        return methods;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
    private void setListenerMethods(Method[] methods) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
        if (methods == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
        if (listenerMethodDescriptors == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
            listenerMethodDescriptors = new MethodDescriptor[methods.length];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
            for (int i = 0; i < methods.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
                listenerMethodDescriptors[i] = new MethodDescriptor(methods[i]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
        this.listenerMethodsRef = getSoftReference(methods);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
    private Method[] getListenerMethods0() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
        return (this.listenerMethodsRef != null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
                ? this.listenerMethodsRef.get()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
                : null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
     * Gets the <code>MethodDescriptor</code>s of the target listener interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
     * @return An array of <code>MethodDescriptor</code> objects for the target methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
     * within the target listener interface that will get called when
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
     * events are fired.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
    public synchronized MethodDescriptor[] getListenerMethodDescriptors() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
        return listenerMethodDescriptors;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
     * Gets the method used to add event listeners.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
     * @return The method used to register a listener at the event source.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
    public synchronized Method getAddListenerMethod() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
        return (addMethodDescriptor != null ?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
                    addMethodDescriptor.getMethod() : null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
    private synchronized void setAddListenerMethod(Method method) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
        if (method == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
        if (getClass0() == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
            setClass0(method.getDeclaringClass());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
        addMethodDescriptor = new MethodDescriptor(method);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
     * Gets the method used to remove event listeners.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
     * @return The method used to remove a listener at the event source.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
    public synchronized Method getRemoveListenerMethod() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
        return (removeMethodDescriptor != null ?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
                    removeMethodDescriptor.getMethod() : null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
    private synchronized void setRemoveListenerMethod(Method method) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
        if (method == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
        if (getClass0() == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
            setClass0(method.getDeclaringClass());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
        removeMethodDescriptor = new MethodDescriptor(method);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
     * Gets the method used to access the registered event listeners.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
     * @return The method used to access the array of listeners at the event
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
     *         source or null if it doesn't exist.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
    public synchronized Method getGetListenerMethod() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
        return (getMethodDescriptor != null ?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
                    getMethodDescriptor.getMethod() : null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
    private synchronized void setGetListenerMethod(Method method) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
        if (method == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
        if (getClass0() == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
            setClass0(method.getDeclaringClass());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
        getMethodDescriptor = new MethodDescriptor(method);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
     * Mark an event set as unicast (or not).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
     * @param unicast  True if the event set is unicast.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
    public void setUnicast(boolean unicast) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
        this.unicast = unicast;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
     * Normally event sources are multicast.  However there are some
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
     * exceptions that are strictly unicast.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
     * @return  <TT>true</TT> if the event set is unicast.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
     *          Defaults to <TT>false</TT>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
    public boolean isUnicast() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
        return unicast;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
     * Marks an event set as being in the &quot;default&quot; set (or not).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
     * By default this is <TT>true</TT>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
     * @param inDefaultEventSet <code>true</code> if the event set is in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
     *                          the &quot;default&quot; set,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
     *                          <code>false</code> if not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
    public void setInDefaultEventSet(boolean inDefaultEventSet) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
        this.inDefaultEventSet = inDefaultEventSet;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
     * Reports if an event set is in the &quot;default&quot; set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
     * @return  <TT>true</TT> if the event set is in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
     *          the &quot;default&quot; set.  Defaults to <TT>true</TT>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
    public boolean isInDefaultEventSet() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
        return inDefaultEventSet;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
     * Package-private constructor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
     * Merge two event set descriptors.  Where they conflict, give the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
     * second argument (y) priority over the first argument (x).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
     * @param x  The first (lower priority) EventSetDescriptor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
     * @param y  The second (higher priority) EventSetDescriptor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
    EventSetDescriptor(EventSetDescriptor x, EventSetDescriptor y) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
        super(x,y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
        listenerMethodDescriptors = x.listenerMethodDescriptors;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
        if (y.listenerMethodDescriptors != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
            listenerMethodDescriptors = y.listenerMethodDescriptors;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
        listenerTypeRef = x.listenerTypeRef;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
        if (y.listenerTypeRef != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
            listenerTypeRef = y.listenerTypeRef;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
        addMethodDescriptor = x.addMethodDescriptor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
        if (y.addMethodDescriptor != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
            addMethodDescriptor = y.addMethodDescriptor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
        removeMethodDescriptor = x.removeMethodDescriptor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
        if (y.removeMethodDescriptor != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
            removeMethodDescriptor = y.removeMethodDescriptor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
        getMethodDescriptor = x.getMethodDescriptor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
        if (y.getMethodDescriptor != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
            getMethodDescriptor = y.getMethodDescriptor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
        unicast = y.unicast;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
        if (!x.inDefaultEventSet || !y.inDefaultEventSet) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
            inDefaultEventSet = 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
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
     * Package-private dup constructor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
     * This must isolate the new object from any changes to the old object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
    EventSetDescriptor(EventSetDescriptor old) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
        super(old);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
        if (old.listenerMethodDescriptors != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
            int len = old.listenerMethodDescriptors.length;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
            listenerMethodDescriptors = new MethodDescriptor[len];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
            for (int i = 0; i < len; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
                listenerMethodDescriptors[i] = new MethodDescriptor(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
                                        old.listenerMethodDescriptors[i]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
        listenerTypeRef = old.listenerTypeRef;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
        addMethodDescriptor = old.addMethodDescriptor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
        removeMethodDescriptor = old.removeMethodDescriptor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
        getMethodDescriptor = old.getMethodDescriptor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
        unicast = old.unicast;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
        inDefaultEventSet = old.inDefaultEventSet;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
}