jdk/src/share/classes/java/beans/EventSetDescriptor.java
changeset 4960 99ac74ca2f2f
parent 466 6acd5ec503a8
child 5506 202f599c92aa
equal deleted inserted replaced
4959:cbbde29076d7 4960:99ac74ca2f2f
     1 /*
     1 /*
     2  * Copyright 1996-2008 Sun Microsystems, Inc.  All Rights Reserved.
     2  * Copyright 1996-2010 Sun Microsystems, Inc.  All Rights Reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Sun designates this
     7  * published by the Free Software Foundation.  Sun designates this
    24  */
    24  */
    25 
    25 
    26 package java.beans;
    26 package java.beans;
    27 
    27 
    28 import java.lang.ref.Reference;
    28 import java.lang.ref.Reference;
    29 
       
    30 import java.lang.reflect.Method;
    29 import java.lang.reflect.Method;
    31 
    30 
    32 /**
    31 /**
    33  * An EventSetDescriptor describes a group of events that a given Java
    32  * An EventSetDescriptor describes a group of events that a given Java
    34  * bean fires.
    33  * bean fires.
   355      * Gets the method used to add event listeners.
   354      * Gets the method used to add event listeners.
   356      *
   355      *
   357      * @return The method used to register a listener at the event source.
   356      * @return The method used to register a listener at the event source.
   358      */
   357      */
   359     public synchronized Method getAddListenerMethod() {
   358     public synchronized Method getAddListenerMethod() {
   360         return (addMethodDescriptor != null ?
   359         return getMethod(this.addMethodDescriptor);
   361                     addMethodDescriptor.getMethod() : null);
       
   362     }
   360     }
   363 
   361 
   364     private synchronized void setAddListenerMethod(Method method) {
   362     private synchronized void setAddListenerMethod(Method method) {
   365         if (method == null) {
   363         if (method == null) {
   366             return;
   364             return;
   376      * Gets the method used to remove event listeners.
   374      * Gets the method used to remove event listeners.
   377      *
   375      *
   378      * @return The method used to remove a listener at the event source.
   376      * @return The method used to remove a listener at the event source.
   379      */
   377      */
   380     public synchronized Method getRemoveListenerMethod() {
   378     public synchronized Method getRemoveListenerMethod() {
   381         return (removeMethodDescriptor != null ?
   379         return getMethod(this.removeMethodDescriptor);
   382                     removeMethodDescriptor.getMethod() : null);
       
   383     }
   380     }
   384 
   381 
   385     private synchronized void setRemoveListenerMethod(Method method) {
   382     private synchronized void setRemoveListenerMethod(Method method) {
   386         if (method == null) {
   383         if (method == null) {
   387             return;
   384             return;
   399      * @return The method used to access the array of listeners at the event
   396      * @return The method used to access the array of listeners at the event
   400      *         source or null if it doesn't exist.
   397      *         source or null if it doesn't exist.
   401      * @since 1.4
   398      * @since 1.4
   402      */
   399      */
   403     public synchronized Method getGetListenerMethod() {
   400     public synchronized Method getGetListenerMethod() {
   404         return (getMethodDescriptor != null ?
   401         return getMethod(this.getMethodDescriptor);
   405                     getMethodDescriptor.getMethod() : null);
       
   406     }
   402     }
   407 
   403 
   408     private synchronized void setGetListenerMethod(Method method) {
   404     private synchronized void setGetListenerMethod(Method method) {
   409         if (method == null) {
   405         if (method == null) {
   410             return;
   406             return;
   520         getMethodDescriptor = old.getMethodDescriptor;
   516         getMethodDescriptor = old.getMethodDescriptor;
   521 
   517 
   522         unicast = old.unicast;
   518         unicast = old.unicast;
   523         inDefaultEventSet = old.inDefaultEventSet;
   519         inDefaultEventSet = old.inDefaultEventSet;
   524     }
   520     }
       
   521 
       
   522     void appendTo(StringBuilder sb) {
       
   523         appendTo(sb, "unicast", this.unicast);
       
   524         appendTo(sb, "inDefaultEventSet", this.inDefaultEventSet);
       
   525         appendTo(sb, "listenerType", this.listenerTypeRef);
       
   526         appendTo(sb, "getListenerMethod", getMethod(this.getMethodDescriptor));
       
   527         appendTo(sb, "addListenerMethod", getMethod(this.addMethodDescriptor));
       
   528         appendTo(sb, "removeListenerMethod", getMethod(this.removeMethodDescriptor));
       
   529     }
       
   530 
       
   531     private static Method getMethod(MethodDescriptor descriptor) {
       
   532         return (descriptor != null)
       
   533                 ? descriptor.getMethod()
       
   534                 : null;
       
   535     }
   525 }
   536 }