0N/A/*
2362N/A * Copyright (c) 1997, 2009, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/Apackage java.beans.beancontext;
0N/A
0N/Aimport java.util.EventObject;
0N/A
0N/Aimport java.beans.beancontext.BeanContext;
0N/Aimport java.beans.beancontext.BeanContextEvent;
0N/A
0N/Aimport java.util.Arrays;
0N/Aimport java.util.Collection;
0N/Aimport java.util.Iterator;
0N/A
0N/A/**
0N/A * A <code>BeanContextMembershipEvent</code> encapsulates
0N/A * the list of children added to, or removed from,
0N/A * the membership of a particular <code>BeanContext</code>.
0N/A * An instance of this event is fired whenever a successful
0N/A * add(), remove(), retainAll(), removeAll(), or clear() is
0N/A * invoked on a given <code>BeanContext</code> instance.
0N/A * Objects interested in receiving events of this type must
0N/A * implement the <code>BeanContextMembershipListener</code>
0N/A * interface, and must register their intent via the
0N/A * <code>BeanContext</code>'s
0N/A * <code>addBeanContextMembershipListener(BeanContextMembershipListener bcml)
0N/A * </code> method.
0N/A *
0N/A * @author Laurence P. G. Cable
0N/A * @since 1.2
0N/A * @see java.beans.beancontext.BeanContext
0N/A * @see java.beans.beancontext.BeanContextEvent
0N/A * @see java.beans.beancontext.BeanContextMembershipListener
0N/A */
0N/Apublic class BeanContextMembershipEvent extends BeanContextEvent {
1076N/A private static final long serialVersionUID = 3499346510334590959L;
0N/A
0N/A /**
0N/A * Contruct a BeanContextMembershipEvent
0N/A *
0N/A * @param bc The BeanContext source
0N/A * @param changes The Children affected
0N/A * @throws NullPointerException if <CODE>changes</CODE> is <CODE>null</CODE>
0N/A */
0N/A
0N/A public BeanContextMembershipEvent(BeanContext bc, Collection changes) {
0N/A super(bc);
0N/A
0N/A if (changes == null) throw new NullPointerException(
0N/A "BeanContextMembershipEvent constructor: changes is null.");
0N/A
0N/A children = changes;
0N/A }
0N/A
0N/A /**
0N/A * Contruct a BeanContextMembershipEvent
0N/A *
0N/A * @param bc The BeanContext source
0N/A * @param changes The Children effected
0N/A * @exception NullPointerException if changes associated with this
0N/A * event are null.
0N/A */
0N/A
0N/A public BeanContextMembershipEvent(BeanContext bc, Object[] changes) {
0N/A super(bc);
0N/A
0N/A if (changes == null) throw new NullPointerException(
0N/A "BeanContextMembershipEvent: changes is null.");
0N/A
0N/A children = Arrays.asList(changes);
0N/A }
0N/A
0N/A /**
0N/A * Gets the number of children affected by the notification.
0N/A * @return the number of children affected by the notification
0N/A */
0N/A public int size() { return children.size(); }
0N/A
0N/A /**
0N/A * Is the child specified affected by the event?
0N/A * @return <code>true</code> if affected, <code>false</code>
0N/A * if not
0N/A */
0N/A public boolean contains(Object child) {
0N/A return children.contains(child);
0N/A }
0N/A
0N/A /**
0N/A * Gets the array of children affected by this event.
0N/A * @return the array of children affected
0N/A */
0N/A public Object[] toArray() { return children.toArray(); }
0N/A
0N/A /**
0N/A * Gets the array of children affected by this event.
0N/A * @return the array of children effected
0N/A */
0N/A public Iterator iterator() { return children.iterator(); }
0N/A
0N/A /*
0N/A * fields
0N/A */
0N/A
0N/A /**
0N/A * The list of children affected by this
0N/A * event notification.
0N/A */
0N/A protected Collection children;
0N/A}