| 1 | /* java.beans.EventSetDescriptor
|
|---|
| 2 | Copyright (C) 1998 Free Software Foundation, Inc.
|
|---|
| 3 |
|
|---|
| 4 | This file is part of GNU Classpath.
|
|---|
| 5 |
|
|---|
| 6 | GNU Classpath is free software; you can redistribute it and/or modify
|
|---|
| 7 | it under the terms of the GNU General Public License as published by
|
|---|
| 8 | the Free Software Foundation; either version 2, or (at your option)
|
|---|
| 9 | any later version.
|
|---|
| 10 |
|
|---|
| 11 | GNU Classpath is distributed in the hope that it will be useful, but
|
|---|
| 12 | WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|---|
| 14 | General Public License for more details.
|
|---|
| 15 |
|
|---|
| 16 | You should have received a copy of the GNU General Public License
|
|---|
| 17 | along with GNU Classpath; see the file COPYING. If not, write to the
|
|---|
| 18 | Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
|---|
| 19 | 02111-1307 USA.
|
|---|
| 20 |
|
|---|
| 21 | Linking this library statically or dynamically with other modules is
|
|---|
| 22 | making a combined work based on this library. Thus, the terms and
|
|---|
| 23 | conditions of the GNU General Public License cover the whole
|
|---|
| 24 | combination.
|
|---|
| 25 |
|
|---|
| 26 | As a special exception, the copyright holders of this library give you
|
|---|
| 27 | permission to link this library with independent modules to produce an
|
|---|
| 28 | executable, regardless of the license terms of these independent
|
|---|
| 29 | modules, and to copy and distribute the resulting executable under
|
|---|
| 30 | terms of your choice, provided that you also meet, for each linked
|
|---|
| 31 | independent module, the terms and conditions of the license of that
|
|---|
| 32 | module. An independent module is a module which is not derived from
|
|---|
| 33 | or based on this library. If you modify this library, you may extend
|
|---|
| 34 | this exception to your version of the library, but you are not
|
|---|
| 35 | obligated to do so. If you do not wish to do so, delete this
|
|---|
| 36 | exception statement from your version. */
|
|---|
| 37 |
|
|---|
| 38 |
|
|---|
| 39 | package java.beans;
|
|---|
| 40 |
|
|---|
| 41 | import java.util.*;
|
|---|
| 42 | import java.lang.reflect.*;
|
|---|
| 43 | import gnu.java.lang.*;
|
|---|
| 44 |
|
|---|
| 45 | /**
|
|---|
| 46 | ** EventSetDescriptor describes the hookup between an event source
|
|---|
| 47 | ** class and an event listener class.
|
|---|
| 48 | **
|
|---|
| 49 | ** EventSets have several attributes: the listener class, the events
|
|---|
| 50 | ** that can be fired to the listener (methods in the listener class), and
|
|---|
| 51 | ** an add and remove listener method from the event firer's class.<P>
|
|---|
| 52 | **
|
|---|
| 53 | ** The methods have these constraints on them:<P>
|
|---|
| 54 | ** <UL>
|
|---|
| 55 | ** <LI>event firing methods: must have <CODE>void</CODE> return value. Any
|
|---|
| 56 | ** parameters and exceptions are allowed. May be public, protected or
|
|---|
| 57 | ** package-protected. (Don't ask me why that is, I'm just following the spec.
|
|---|
| 58 | ** The only place it is even mentioned is in the Java Beans white paper, and
|
|---|
| 59 | ** there it is only implied.)</LI>
|
|---|
| 60 | ** <LI>add listener method: must have <CODE>void</CODE> return value. Must
|
|---|
| 61 | ** take exactly one argument, of the listener class's type. May fire either
|
|---|
| 62 | ** zero exceptions, or one exception of type <CODE>java.util.TooManyListenersException</CODE>.
|
|---|
| 63 | ** Must be public.</LI>
|
|---|
| 64 | ** <LI>remove listener method: must have <CODE>void</CODE> return value.
|
|---|
| 65 | ** Must take exactly one argument, of the listener class's type. May not
|
|---|
| 66 | ** fire any exceptions. Must be public.</LI>
|
|---|
| 67 | ** </UL>
|
|---|
| 68 | **
|
|---|
| 69 | ** A final constraint is that event listener classes must extend from EventListener.<P>
|
|---|
| 70 | **
|
|---|
| 71 | ** There are also various design patterns associated with some of the methods
|
|---|
| 72 | ** of construction. Those are explained in more detail in the appropriate
|
|---|
| 73 | ** constructors.<P>
|
|---|
| 74 | **
|
|---|
| 75 | ** <STRONG>Documentation Convention:</STRONG> for proper
|
|---|
| 76 | ** Internalization of Beans inside an RAD tool, sometimes there
|
|---|
| 77 | ** are two names for a property or method: a programmatic, or
|
|---|
| 78 | ** locale-independent name, which can be used anywhere, and a
|
|---|
| 79 | ** localized, display name, for ease of use. In the
|
|---|
| 80 | ** documentation I will specify different String values as
|
|---|
| 81 | ** either <EM>programmatic</EM> or <EM>localized</EM> to
|
|---|
| 82 | ** make this distinction clear.
|
|---|
| 83 | **
|
|---|
| 84 | ** @author John Keiser
|
|---|
| 85 | ** @since JDK1.1
|
|---|
| 86 | ** @version 1.1.0, 31 May 1998
|
|---|
| 87 | **/
|
|---|
| 88 |
|
|---|
| 89 | public class EventSetDescriptor extends FeatureDescriptor {
|
|---|
| 90 | private Method addListenerMethod;
|
|---|
| 91 | private Method removeListenerMethod;
|
|---|
| 92 | private Class listenerType;
|
|---|
| 93 | private MethodDescriptor[] listenerMethodDescriptors;
|
|---|
| 94 | private Method[] listenerMethods;
|
|---|
| 95 |
|
|---|
| 96 | private boolean unicast;
|
|---|
| 97 | private boolean inDefaultEventSet = true;
|
|---|
| 98 |
|
|---|
| 99 | /** Create a new EventSetDescriptor.
|
|---|
| 100 | ** This version of the constructor enforces the rules imposed on the methods
|
|---|
| 101 | ** described at the top of this class, as well as searching for:<P>
|
|---|
| 102 | ** <OL>
|
|---|
| 103 | ** <LI>The event-firing method must be non-private with signature
|
|---|
| 104 | ** <CODE>void <listenerMethodName>(<eventSetName>Event)</CODE>
|
|---|
| 105 | ** (where <CODE><eventSetName></CODE> has its first character capitalized
|
|---|
|
|---|