1. /*
  2. * @(#)BeanContextMembershipEvent.java 1.7 01/11/29
  3. *
  4. * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package java.beans.beancontext;
  8. import java.util.EventObject;
  9. import java.beans.beancontext.BeanContext;
  10. import java.beans.beancontext.BeanContextEvent;
  11. import java.util.Arrays;
  12. import java.util.Collection;
  13. import java.util.Iterator;
  14. /**
  15. * <p>
  16. * Compliant BeanContexts fire events on this interface when state maintained
  17. * by the BeanContext, for some or all of its "children", changes, to all
  18. * BeanContextListeners that register themselves with a particular BeanContext.
  19. * </p>
  20. *
  21. * @author Laurence P. G. Cable
  22. * @version 1.7
  23. * @since 1.2
  24. * @see java.beans.beancontext.BeanContext
  25. * @see java.beans.beancontext.BeanContextEvent
  26. * @see java.beans.beancontext.BeanContextListener
  27. */
  28. public class BeanContextMembershipEvent extends BeanContextEvent {
  29. /**
  30. * Contruct a BeanContextMembershipEvent
  31. *
  32. * @param bc The BeanContext source
  33. * @param changes The Children effected
  34. */
  35. public BeanContextMembershipEvent(BeanContext bc, Collection changes) {
  36. super(bc);
  37. children = changes;
  38. }
  39. /**
  40. * Contruct a BeanContextMembershipEvent
  41. *
  42. * @param bc The BeanContext source
  43. * @param changes The Children effected
  44. */
  45. public BeanContextMembershipEvent(BeanContext bc, Object[] changes) {
  46. super(bc);
  47. children = Arrays.asList(changes);
  48. }
  49. /**
  50. * how many children are effected by the notification
  51. */
  52. public int size() { return children.size(); }
  53. /**
  54. * @return is the child specified effected by the event?
  55. */
  56. public boolean contains(Object child) {
  57. return children.contains(child);
  58. }
  59. /**
  60. * @return the array of children effected
  61. */
  62. public Object[] toArray() { return children.toArray(); }
  63. /**
  64. * @return the array of children effected
  65. */
  66. public Iterator iterator() { return children.iterator(); }
  67. /*
  68. * fields
  69. */
  70. protected Collection children;
  71. }