Path: blob/master/src/java.prefs/share/classes/java/util/prefs/NodeChangeEvent.java
41159 views
/*1* Copyright (c) 2000, 2019, 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.util.prefs;2627import java.io.NotSerializableException;2829/**30* An event emitted by a {@code Preferences} node to indicate that31* a child of that node has been added or removed.<p>32*33* Note, that although NodeChangeEvent inherits Serializable interface from34* java.util.EventObject, it is not intended to be Serializable. Appropriate35* serialization methods are implemented to throw NotSerializableException.36*37* @author Josh Bloch38* @see Preferences39* @see NodeChangeListener40* @see PreferenceChangeEvent41* @since 1.442* @serial exclude43*/4445public class NodeChangeEvent extends java.util.EventObject {46/**47* The node that was added or removed.48*/49private transient Preferences child;5051/**52* Constructs a new {@code NodeChangeEvent} instance.53*54* @param parent The parent of the node that was added or removed.55* @param child The node that was added or removed.56*/57public NodeChangeEvent(Preferences parent, Preferences child) {58super(parent);59this.child = child;60}6162/**63* Returns the parent of the node that was added or removed.64*65* @return The parent Preferences node whose child was added or removed66*/67public Preferences getParent() {68return (Preferences) getSource();69}7071/**72* Returns the node that was added or removed.73*74* @return The node that was added or removed.75*/76public Preferences getChild() {77return child;78}7980/**81* Throws NotSerializableException, since NodeChangeEvent objects are not82* intended to be serializable.83*/84private void writeObject(java.io.ObjectOutputStream out)85throws NotSerializableException {86throw new NotSerializableException("Not serializable.");87}8889/**90* Throws NotSerializableException, since NodeChangeEvent objects are not91* intended to be serializable.92*/93private void readObject(java.io.ObjectInputStream in)94throws NotSerializableException {95throw new NotSerializableException("Not serializable.");96}9798// Defined so that this class isn't flagged as a potential problem when99// searches for missing serialVersionUID fields are done.100private static final long serialVersionUID = 8068949086596572957L;101}102103104