01: /* Licensed to the Apache Software Foundation (ASF) under one or more
02: * contributor license agreements. See the NOTICE file distributed with
03: * this work for additional information regarding copyright ownership.
04: * The ASF licenses this file to You under the Apache License, Version 2.0
05: * (the "License"); you may not use this file except in compliance with
06: * the License. You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package java.util.prefs;
18:
19: import java.io.Serializable;
20: import java.util.EventObject;
21: import java.io.ObjectOutputStream;
22: import java.io.ObjectInputStream;
23: import java.io.NotSerializableException;
24: import java.io.IOException;
25:
26: /**
27: * This is the event class to indicate one child of the preferences node has
28: * been added or deleted.
29: * <p>
30: * Please note that this class cannot be serialized actually, so relevant
31: * serialization methods only throw <code>NotSerializableException</code>.</p>
32: *
33: * @see java.util.prefs.Preferences
34: * @see java.util.prefs.NodeChangeListener
35: *
36: * @since 1.4
37: */
38: public class NodeChangeEvent extends EventObject implements
39: Serializable {
40:
41: private static final long serialVersionUID = 8068949086596572957L;
42:
43: private final Preferences parent;
44: private final Preferences child;
45:
46: /**
47: * Construct a new <code>NodeChangeEvent</code> instance.
48: *
49: * @param p the <code>Preferences</code> instance that this event happened,
50: * this object is considered as event's source.
51: * @param c the child <code>Preferences</code> instance that was added
52: * or deleted.
53: */
54: public NodeChangeEvent(Preferences p, Preferences c) {
55: super (p);
56: parent = p;
57: child = c;
58: }
59:
60: /**
61: * Get the <code>Preferences</code> instance that this event happened.
62: *
63: * @return the <code>Preferences</code> instance that this event happened.
64: */
65: public Preferences getParent() {
66: return parent;
67: }
68:
69: /**
70: * Get the child <code>Preferences</code> node that was added or removed.
71: *
72: * @return the child <code>Preferences</code> node that was added or removed.
73: */
74: public Preferences getChild() {
75: return child;
76: }
77:
78: /*
79: * This method always throws a <code>NotSerializableException</code>, because
80: * this object cannot be serialized,
81: */
82: private void writeObject(ObjectOutputStream out) throws IOException {
83: throw new NotSerializableException();
84: }
85:
86: /*
87: * This method always throws a <code>NotSerializableException</code>, because
88: * this object cannot be serialized,
89: */
90: private void readObject(ObjectInputStream in) throws IOException,
91: ClassNotFoundException {
92: throw new NotSerializableException();
93: }
94: }
|