1 /* Licensed to the Apache Software Foundation (ASF) under one or more
2 * contributor license agreements. See the NOTICE file distributed with
3 * this work for additional information regarding copyright ownership.
4 * The ASF licenses this file to You under the Apache License, Version 2.0
5 * (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package java.util.prefs;
19 import java.io.IOException;
20 import java.io.NotSerializableException;
21 import java.io.ObjectInputStream;
22 import java.io.ObjectOutputStream;
23 import java.io.Serializable;
24 import java.util.EventObject;
27 * This is the event class to indicate that a preference has been added, deleted
30 * Please note that although the class is marked as {@code Serializable} by
31 * inheritance from {@code EventObject}, this type is not intended to be serialized
32 * so the serialization methods do nothing but throw a {@code NotSerializableException}.
34 * @see java.util.prefs.Preferences
35 * @see java.util.prefs.PreferenceChangeListener
39 public class PreferenceChangeEvent extends EventObject implements Serializable {
41 private static final long serialVersionUID = 793724513368024975L;
43 private final Preferences node;
45 private final String key;
47 private final String value;
50 * Construct a new {@code PreferenceChangeEvent} instance.
53 * the {@code Preferences} instance that fired this event; this object is
54 * considered as the event's source.
56 * the changed preference key.
58 * the new value of the changed preference, this value can be
59 * {@code null}, which means the preference has been removed.
61 public PreferenceChangeEvent(Preferences p, String k, String v) {
69 * Gets the key of the changed preference.
71 * @return the changed preference's key.
73 public String getKey() {
78 * Gets the new value of the changed preference or {@code null} if the
79 * preference has been removed.
81 * @return the new value of the changed preference or {@code null} if the
82 * preference has been removed.
84 public String getNewValue() {
89 * Gets the {@code Preferences} instance that fired this event.
91 * @return the {@code Preferences} instance that fired this event.
93 public Preferences getNode() {
98 * This method always throws a <code>NotSerializableException</code>,
99 * because this object cannot be serialized,
101 private void writeObject(ObjectOutputStream out) throws IOException {
102 throw new NotSerializableException();
106 * This method always throws a <code>NotSerializableException</code>,
107 * because this object cannot be serialized,
109 private void readObject(ObjectInputStream in) throws IOException{
110 throw new NotSerializableException();