1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
/* * @(#)PreferenceChangeEvent.java 1.7 05/11/17 * * Copyright 2006 Sun Microsystems, Inc. All rights reserved. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. */ package java.util.prefs; import java.io.NotSerializableException; /** * An event emitted by a <tt>Preferences</tt> node to indicate that * a preference has been added, removed or has had its value changed.<p> * * Note, that although PreferenceChangeEvent inherits Serializable interface * from EventObject, it is not intended to be Serializable. Appropriate * serialization methods are implemented to throw NotSerializableException. * * @author Josh Bloch * @version 1.7, 11/17/05 * @see Preferences * @see PreferenceChangeListener * @see NodeChangeEvent * @since 1.4 * @serial exclude */ public class PreferenceChangeEvent extends java.util.EventObject { /** * Key of the preference that changed. * * @serial */ private String key; /** * New value for preference, or <tt>null</tt> if it was removed. * * @serial */ private String newValue; /** * Constructs a new <code>PreferenceChangeEvent</code> instance. * * @param node The Preferences node that emitted the event. * @param key The key of the preference that was changed. * @param newValue The new value of the preference, or <tt>null</tt> * if the preference is being removed. */ public PreferenceChangeEvent(Preferences node, String key, String newValue) { super(node); this.key = key; this.newValue = newValue; } /** * Returns the preference node that emitted the event. * * @return The preference node that emitted the event. */ public Preferences getNode() { return (Preferences) getSource(); } /** * Returns the key of the preference that was changed. * * @return The key of the preference that was changed. */ public String getKey() { return key; } /** * Returns the new value for the preference. * * @return The new value for the preference, or <tt>null</tt> if the * preference was removed. */ public String getNewValue() { return newValue; } /** * Throws NotSerializableException, since NodeChangeEvent objects * are not intended to be serializable. */ private void writeObject(java.io.ObjectOutputStream out) throws NotSerializableException { throw new NotSerializableException("Not serializable."); } /** * Throws NotSerializableException, since PreferenceChangeEvent objects * are not intended to be serializable. */ private void readObject(java.io.ObjectInputStream in) throws NotSerializableException { throw new NotSerializableException("Not serializable."); } // Defined so that this class isn't flagged as a potential problem when // searches for missing serialVersionUID fields are done. private static final long serialVersionUID = 793724513368024975L; }