| NodeChangeEvent.java |
1 /*
2 * %W% %E%
3 *
4 * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
5 * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6 */
7
8 package java.util.prefs;
9
10 import java.io.NotSerializableException;
11
12 /**
13 * An event emitted by a <tt>Preferences</tt> node to indicate that
14 * a child of that node has been added or removed.<p>
15 *
16 * Note, that although NodeChangeEvent inherits Serializable interface from
17 * java.util.EventObject, it is not intended to be Serializable. Appropriate
18 * serialization methods are implemented to throw NotSerializableException.
19 *
20 * @author Josh Bloch
21 * @version $I$, $G$
22 * @see Preferences
23 * @see NodeChangeListener
24 * @see PreferenceChangeEvent
25 * @since 1.4
26 * @serial exclude
27 */
28
29 public class NodeChangeEvent extends java.util.EventObject {
30 /**
31 * The node that was added or removed.
32 *
33 * @serial
34 */
35 private Preferences child;
36
37 /**
38 * Constructs a new <code>NodeChangeEvent</code> instance.
39 *
40 * @param parent The parent of the node that was added or removed.
41 * @param child The node that was added or removed.
42 */
43 public NodeChangeEvent(Preferences parent, Preferences child) {
44 super(parent);
45 this.child = child;
46 }
47
48 /**
49 * Returns the parent of the node that was added or removed.
50 *
51 * @return The parent Preferences node whose child was added or removed
52 */
53 public Preferences getParent() {
54 return (Preferences) getSource();
55 }
56
57 /**
58 * Returns the node that was added or removed.
59 *
60 * @return The node that was added or removed.
61 */
62 public Preferences getChild() {
63 return child;
64 }
65
66 /**
67 * Throws NotSerializableException, since NodeChangeEvent objects are not
68 * intended to be serializable.
69 */
70 private void writeObject(java.io.ObjectOutputStream out)
71 throws NotSerializableException {
72 throw new NotSerializableException("Not serializable.");
73 }
74
75 /**
76 * Throws NotSerializableException, since NodeChangeEvent objects are not
77 * intended to be serializable.
78 */
79 private void readObject(java.io.ObjectInputStream in)
80 throws NotSerializableException {
81 throw new NotSerializableException("Not serializable.");
82 }
83
84 // Defined so that this class isn't flagged as a potential problem when
85 // searches for missing serialVersionUID fields are done.
86 private static final long serialVersionUID = 8068949086596572957L;
87 }
88
89