Path: blob/master/src/java.desktop/share/classes/java/beans/beancontext/BeanContextEvent.java
41159 views
/*1* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package java.beans.beancontext;2627import java.io.Serial;28import java.util.EventObject;2930/**31* <p>32* {@code BeanContextEvent} is the abstract root event class33* for all events emitted34* from, and pertaining to the semantics of, a {@code BeanContext}.35* This class introduces a mechanism to allow the propagation of36* {@code BeanContextEvent} subclasses through a hierarchy of37* {@code BeanContext}s. The {@code setPropagatedFrom()}38* and {@code getPropagatedFrom()} methods allow a39* {@code BeanContext} to identify itself as the source40* of a propagated event.41* </p>42*43* @author Laurence P. G. Cable44* @since 1.245* @see java.beans.beancontext.BeanContext46*/4748public abstract class BeanContextEvent extends EventObject {4950/**51* Use serialVersionUID from JDK 1.7 for interoperability.52*/53@Serial54private static final long serialVersionUID = 7267998073569045052L;5556/**57* Contruct a BeanContextEvent58*59* @param bc The BeanContext source60*/61protected BeanContextEvent(BeanContext bc) {62super(bc);63}6465/**66* Gets the {@code BeanContext} associated with this event.67* @return the {@code BeanContext} associated with this event.68*/69public BeanContext getBeanContext() { return (BeanContext)getSource(); }7071/**72* Sets the {@code BeanContext} from which this event was propagated.73* @param bc the {@code BeanContext} from which this event74* was propagated75*/76public synchronized void setPropagatedFrom(BeanContext bc) {77propagatedFrom = bc;78}7980/**81* Gets the {@code BeanContext} from which this event was propagated.82* @return the {@code BeanContext} from which this83* event was propagated84*/85public synchronized BeanContext getPropagatedFrom() {86return propagatedFrom;87}8889/**90* Reports whether or not this event is91* propagated from some other {@code BeanContext}.92* @return {@code true} if propagated, {@code false}93* if not94*/95public synchronized boolean isPropagated() {96return propagatedFrom != null;97}9899/*100* fields101*/102103/**104* The {@code BeanContext} from which this event was propagated105*/106@SuppressWarnings("serial") // Not statically typed as Serializable107protected BeanContext propagatedFrom;108}109110111