home *** CD-ROM | disk | FTP | other *** search
/ Java 1.2 How-To / JavaHowTo.iso / 3rdParty / jbuilder / unsupported / JDK1.2beta3 / SOURCE / SRC.ZIP / java / beans / beancontext / BeanContextMembershipEvent.java < prev    next >
Encoding:
Java Source  |  1998-03-20  |  2.4 KB  |  101 lines

  1. /*
  2.  * @(#)BeanContextMembershipEvent.java    1.5 98/03/18
  3.  *
  4.  * Copyright 1997, 1998 by Sun Microsystems, Inc.,
  5.  * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
  6.  * All rights reserved.
  7.  *
  8.  * This software is the confidential and proprietary information
  9.  * of Sun Microsystems, Inc. ("Confidential Information").  You
  10.  * shall not disclose such Confidential Information and shall use
  11.  * it only in accordance with the terms of the license agreement
  12.  * you entered into with Sun.
  13.  */
  14.  
  15. package java.beans.beancontext;
  16.  
  17. import java.util.EventObject;
  18.  
  19. import java.beans.beancontext.BeanContext;
  20. import java.beans.beancontext.BeanContextEvent;
  21.  
  22. import java.util.Arrays;
  23. import java.util.Collection;
  24. import java.util.Iterator;
  25.  
  26. /**
  27.  * <p>
  28.  * Compliant BeanContexts fire events on this interface when state maintained
  29.  * by the BeanContext, for some or all of its "children", changes, to all
  30.  * BeanContextListeners that register themselves with a particular BeanContext.
  31.  * </p>
  32.  *
  33.  * @author    Laurence P. G. Cable
  34.  * @version    1.5
  35.  * @since    1.2
  36.  * @see        java.beans.beancontext.BeanContext
  37.  * @see        java.beans.beancontext.BeanContextEvent
  38.  * @see        java.beans.beancontext.BeanContextListener
  39.  */
  40.  
  41. public class BeanContextMembershipEvent extends BeanContextEvent {
  42.  
  43.     /**
  44.      * Contruct a BeanContextMembershipEvent
  45.      *
  46.      * @param bc    The BeanContext source
  47.      * @param changes    The Children effected
  48.      */
  49.  
  50.     public BeanContextMembershipEvent(BeanContext bc, Collection changes) {
  51.     super(bc);
  52.  
  53.     children = changes;
  54.     }
  55.  
  56.     /**
  57.      * Contruct a BeanContextMembershipEvent
  58.      *
  59.      * @param bc    The BeanContext source
  60.      * @param changes    The Children effected
  61.      */
  62.  
  63.     public BeanContextMembershipEvent(BeanContext bc, Object[] changes) {
  64.     super(bc);
  65.  
  66.     children = Arrays.toList(changes);
  67.     }
  68.  
  69.     /**
  70.      * how many children are effected by the notification
  71.      */
  72.  
  73.     public int size() { return children.size(); }
  74.  
  75.     /**
  76.      * @return is the child specified effected by the event?
  77.      */
  78.  
  79.     public boolean contains(Object child) {
  80.     return children.contains(child);
  81.     }
  82.  
  83.     /**
  84.      * @return the array of children effected
  85.      */
  86.  
  87.     public Object[] toArray() { return children.toArray(); }
  88.  
  89.     /**
  90.      * @return the array of children effected
  91.      */
  92.  
  93.     public Iterator iterator() { return children.iterator(); }
  94.  
  95.     /*
  96.      * fields
  97.      */
  98.  
  99.     protected Collection children;
  100. }
  101.