1 /* 2 * Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package java.util.prefs; 27 28 import java.io.NotSerializableException; 29 30 /** 31 * An event emitted by a <tt>Preferences</tt> node to indicate that 32 * a child of that node has been added or removed.<p> 33 * 34 * Note, that although NodeChangeEvent inherits Serializable interface from 35 * java.util.EventObject, it is not intended to be Serializable. Appropriate 36 * serialization methods are implemented to throw NotSerializableException. 37 * 38 * @author Josh Bloch 39 * @see Preferences 40 * @see NodeChangeListener 41 * @see PreferenceChangeEvent 42 * @since 1.4 43 * @serial exclude 44 */ 45 46 public class NodeChangeEvent extends java.util.EventObject { 47 /** 48 * The node that was added or removed. 49 * 50 * @serial 51 */ 52 private Preferences child; 53 54 /** 55 * Constructs a new <code>NodeChangeEvent</code> instance. 56 * 57 * @param parent The parent of the node that was added or removed. 58 * @param child The node that was added or removed. 59 */ NodeChangeEvent(Preferences parent, Preferences child)60 public NodeChangeEvent(Preferences parent, Preferences child) { 61 super(parent); 62 this.child = child; 63 } 64 65 /** 66 * Returns the parent of the node that was added or removed. 67 * 68 * @return The parent Preferences node whose child was added or removed 69 */ getParent()70 public Preferences getParent() { 71 return (Preferences) getSource(); 72 } 73 74 /** 75 * Returns the node that was added or removed. 76 * 77 * @return The node that was added or removed. 78 */ getChild()79 public Preferences getChild() { 80 return child; 81 } 82 83 /** 84 * Throws NotSerializableException, since NodeChangeEvent objects are not 85 * intended to be serializable. 86 */ writeObject(java.io.ObjectOutputStream out)87 private void writeObject(java.io.ObjectOutputStream out) 88 throws NotSerializableException { 89 throw new NotSerializableException("Not serializable."); 90 } 91 92 /** 93 * Throws NotSerializableException, since NodeChangeEvent objects are not 94 * intended to be serializable. 95 */ readObject(java.io.ObjectInputStream in)96 private void readObject(java.io.ObjectInputStream in) 97 throws NotSerializableException { 98 throw new NotSerializableException("Not serializable."); 99 } 100 101 // Defined so that this class isn't flagged as a potential problem when 102 // searches for missing serialVersionUID fields are done. 103 private static final long serialVersionUID = 8068949086596572957L; 104 } 105