⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 eventsetdescriptor.java

📁 this gcc-g++-3.3.1.tar.gz is a source file of gcc, you can learn more about gcc through this codes f
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* java.beans.EventSetDescriptor   Copyright (C) 1998 Free Software Foundation, Inc.This file is part of GNU Classpath.GNU Classpath is free software; you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe Free Software Foundation; either version 2, or (at your option)any later version. GNU Classpath is distributed in the hope that it will be useful, butWITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNUGeneral Public License for more details.You should have received a copy of the GNU General Public Licensealong with GNU Classpath; see the file COPYING.  If not, write to theFree Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA02111-1307 USA.Linking this library statically or dynamically with other modules ismaking a combined work based on this library.  Thus, the terms andconditions of the GNU General Public License cover the wholecombination.As a special exception, the copyright holders of this library give youpermission to link this library with independent modules to produce anexecutable, regardless of the license terms of these independentmodules, and to copy and distribute the resulting executable underterms of your choice, provided that you also meet, for each linkedindependent module, the terms and conditions of the license of thatmodule.  An independent module is a module which is not derived fromor based on this library.  If you modify this library, you may extendthis exception to your version of the library, but you are notobligated to do so.  If you do not wish to do so, delete thisexception statement from your version. */package java.beans;import java.util.*;import java.lang.reflect.*;import gnu.java.lang.*;/** ** EventSetDescriptor describes the hookup between an event source ** class and an event listener class. ** ** EventSets have several attributes: the listener class, the events ** that can be fired to the listener (methods in the listener class), and ** an add and remove listener method from the event firer's class.<P> ** ** The methods have these constraints on them:<P> ** <UL> ** <LI>event firing methods: must have <CODE>void</CODE> return value.  Any ** parameters and exceptions are allowed.  May be public, protected or ** package-protected. (Don't ask me why that is, I'm just following the spec. ** The only place it is even mentioned is in the Java Beans white paper, and ** there it is only implied.)</LI> ** <LI>add listener method: must have <CODE>void</CODE> return value.  Must ** take exactly one argument, of the listener class's type.  May fire either ** zero exceptions, or one exception of type <CODE>java.util.TooManyListenersException</CODE>. ** Must be public.</LI> ** <LI>remove listener method: must have <CODE>void</CODE> return value. ** Must take exactly one argument, of the listener class's type.  May not ** fire any exceptions.  Must be public.</LI> ** </UL> ** ** A final constraint is that event listener classes must extend from EventListener.<P> ** ** There are also various design patterns associated with some of the methods ** of construction. Those are explained in more detail in the appropriate ** constructors.<P> ** ** <STRONG>Documentation Convention:</STRONG> for proper ** Internalization of Beans inside an RAD tool, sometimes there ** are two names for a property or method: a programmatic, or ** locale-independent name, which can be used anywhere, and a ** localized, display name, for ease of use.  In the ** documentation I will specify different String values as ** either <EM>programmatic</EM> or <EM>localized</EM> to ** make this distinction clear. ** ** @author John Keiser ** @since JDK1.1 ** @version 1.1.0, 31 May 1998 **/public class EventSetDescriptor extends FeatureDescriptor {	private Method addListenerMethod;	private Method removeListenerMethod;	private Class listenerType;	private MethodDescriptor[] listenerMethodDescriptors;	private Method[] listenerMethods;	private boolean unicast;	private boolean inDefaultEventSet = true;	/** Create a new EventSetDescriptor.	 ** This version of the constructor enforces the rules imposed on the methods	 ** described at the top of this class, as well as searching for:<P>	 ** <OL>	 ** <LI>The event-firing method must be non-private with signature	 ** <CODE>void &lt;listenerMethodName&gt;(&lt;eventSetName&gt;Event)</CODE>	 ** (where <CODE>&lt;eventSetName&gt;</CODE> has its first character capitalized	 ** by the constructor and the Event is a descendant of	 ** <CODE>java.util.EventObject</CODE>) in class <CODE>listenerType</CODE>	 ** (any exceptions may be thrown).	 ** <B>Implementation note:</B> Note that there could conceivably be multiple	 ** methods with this type of signature (example: java.util.MouseEvent vs.	 ** my.very.own.MouseEvent).  In this implementation, all methods fitting the	 ** description will be put into the <CODE>EventSetDescriptor</CODE>, even	 ** though the spec says only one should be chosen (they probably weren't thinking as	 ** pathologically as I was).  I don't like arbitrarily choosing things.	 ** If your class has only one such signature, as most do, you'll have no problems.</LI>	 ** <LI>The add and remove methods must be public and named	 ** <CODE>void add&lt;eventSetName&gt;Listener(&lt;listenerType&gt;)</CODE> and	 ** <CODE>void remove&lt;eventSetName&gt;Listener(&lt;listenerType&gt;)</CODE> in	 ** in class <CODE>eventSourceClass</CODE>, where	 ** <CODE>&lt;eventSetName&gt;</CODE> will have its first letter capitalized.	 ** Standard exception rules (see class description) apply.</LI>	 ** </OL>	 ** @param eventSourceClass the class containing the add/remove listener methods.	 ** @param eventSetName the programmatic name of the event set, generally starting	 ** with a lowercase letter (i.e. fooManChu instead of FooManChu).  This will be used	 ** to generate the name of the event object as well as the names of the add and	 ** remove methods.	 ** @param listenerType the class containing the event firing method.	 ** @param listenerMethodName the name of the event firing method.	 ** @exception IntrospectionException if listenerType is not an EventListener,	 **                                   or if methods are not found or are invalid.	 **/	public EventSetDescriptor(Class  eventSourceClass,				  String eventSetName,				  Class  listenerType,				  String listenerMethodName) throws IntrospectionException {		setName(eventSetName);		if(!java.util.EventListener.class.isAssignableFrom(listenerType)) {			throw new IntrospectionException("Listener type is not an EventListener.");		}		String[] names = new String[1];		names[0] = listenerMethodName;		try {			eventSetName = Character.toUpperCase(eventSetName.charAt(0)) + eventSetName.substring(1);		} catch(StringIndexOutOfBoundsException e) {			eventSetName = "";		}		findMethods(eventSourceClass,listenerType,names,"add"+eventSetName+"Listener","remove"+eventSetName+"Listener",eventSetName+"Event");		this.listenerType = listenerType;		checkAddListenerUnicast();		if(this.removeListenerMethod.getExceptionTypes().length > 0) {			throw new IntrospectionException("Listener remove method throws exceptions.");		}	}	/** Create a new EventSetDescriptor.	 ** This form of the constructor allows you to specify the names of the methods and adds	 ** no new constraints on top of the rules already described at the top of the class.<P>	 ** 	 ** @param eventSourceClass the class containing the add and remove listener methods.	 ** @param eventSetName the programmatic name of the event set, generally starting	 ** with a lowercase letter (i.e. fooManChu instead of FooManChu).	 ** @param listenerType the class containing the event firing methods.	 ** @param listenerMethodNames the names of the even firing methods.	 ** @param addListenerMethodName the name of the add listener method.	 ** @param removeListenerMethodName the name of the remove listener method.	 ** @exception IntrospectionException if listenerType is not an EventListener	 **                                   or if methods are not found or are invalid.	 **/	public EventSetDescriptor(Class eventSourceClass,				   String eventSetName,				   Class listenerType,				   String[] listenerMethodNames,				   String addListenerMethodName,				   String removeListenerMethodName) throws IntrospectionException {		setName(eventSetName);		if(!java.util.EventListener.class.isAssignableFrom(listenerType)) {			throw new IntrospectionException("Listener type is not an EventListener.");		}		findMethods(eventSourceClass,listenerType,listenerMethodNames,addListenerMethodName,removeListenerMethodName,null);		this.listenerType = listenerType;		checkAddListenerUnicast();		if(this.removeListenerMethod.getExceptionTypes().length > 0) {			throw new IntrospectionException("Listener remove method throws exceptions.");		}	}	/** Create a new EventSetDescriptor.	 ** This form of constructor allows you to explicitly say which methods do what, and	 ** no reflection is done by the EventSetDescriptor.  The methods are, however,	 ** checked to ensure that they follow the rules set forth at the top of the class.	 ** @param eventSetName the programmatic name of the event set, generally starting	 ** with a lowercase letter (i.e. fooManChu instead of FooManChu).	 ** @param listenerType the class containing the listenerMethods.	 ** @param listenerMethods the event firing methods.	 ** @param addListenerMethod the add listener method.	 ** @param removeListenerMethod the remove listener method.	 ** @exception IntrospectionException if the listenerType is not an EventListener,	 **                                   or any of the methods are invalid.	 **/	public EventSetDescriptor(String eventSetName,				   Class listenerType,				   Method[] listenerMethods,				   Method addListenerMethod,				   Method removeListenerMethod) throws IntrospectionException {		setName(eventSetName);		if(!java.util.EventListener.class.isAssignableFrom(listenerType)) {			throw new IntrospectionException("Listener type is not an EventListener.");		}	        this.listenerMethods = listenerMethods;		this.addListenerMethod = addListenerMethod;		this.removeListenerMethod = removeListenerMethod;		this.listenerType = listenerType;		checkMethods();		checkAddListenerUnicast();		if(this.removeListenerMethod.getExceptionTypes().length > 0) {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -