Showing the changes to java/pkg/javax/swing/ClientPropertyKey.java (1 of 18352 files). Show all
Unified · Split
| @@ -0,0 +1,113 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2006, 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 javax.swing; | |
| 27 | + | |
| 28 | +/** | |
| 29 | + * An enumeration for keys used as client properties within the Swing | |
| 30 | + * implementation. | |
| 31 | + * <p> | |
| 32 | + * This enum holds only a small subset of the keys currently used within Swing, | |
| 33 | + * but we may move more of them here in the future. | |
| 34 | + * <p> | |
| 35 | + * Adding an item to, and using, this class instead of {@code String} for | |
| 36 | + * client properties protects against conflicts with developer-set client | |
| 37 | + * properties. Using this class also avoids a problem with {@code StringBuilder} | |
| 38 | + * and {@code StringBuffer} keys, whereby the keys are not recognized upon | |
| 39 | + * deserialization. | |
| 40 | + * <p> | |
| 41 | + * When a client property value associated with one of these keys does not | |
| 42 | + * implement {@code Serializable}, the result during serialization depends | |
| 43 | + * on how the key is defined here. Historically, client properties with values | |
| 44 | + * not implementing {@code Serializable} have simply been dropped and left out | |
| 45 | + * of the serialized representation. To define keys with such behavior in this | |
| 46 | + * enum, provide a value of {@code false} for the {@code reportValueNotSerializable} | |
| 47 | + * property. When migrating existing properties to this enum, one may wish to | |
| 48 | + * consider using this by default, to preserve backward compatibility. | |
| 49 | + * <p> | |
| 50 | + * To instead have a {@code NotSerializableException} thrown when a | |
| 51 | + * {@code non-Serializable} property is encountered, provide the value of | |
| 52 | + * {@code true} for the {@code reportValueNotSerializable} property. This | |
| 53 | + * is useful when the property represents something that the developer | |
| 54 | + * needs to know about when it cannot be serialized. | |
| 55 | + * | |
| 56 | + * @author Shannon Hickey | |
| 57 | + */ | |
| 58 | +enum ClientPropertyKey { | |
| 59 | + | |
| 60 | + /** | |
| 61 | + * Key used by JComponent for storing InputVerifier. | |
| 62 | + */ | |
| 63 | + JComponent_INPUT_VERIFIER(true), | |
| 64 | + | |
| 65 | + /** | |
| 66 | + * Key used by JComponent for storing TransferHandler. | |
| 67 | + */ | |
| 68 | + JComponent_TRANSFER_HANDLER(true), | |
| 69 | + | |
| 70 | + /** | |
| 71 | + * Key used by JComponent for storing AncestorNotifier. | |
| 72 | + */ | |
| 73 | + JComponent_ANCESTOR_NOTIFIER(true), | |
| 74 | + | |
| 75 | + /** | |
| 76 | + * Key used by PopupFactory to force heavy weight popups for a | |
| 77 | + * component. | |
| 78 | + */ | |
| 79 | + PopupFactory_FORCE_HEAVYWEIGHT_POPUP(true); | |
| 80 | + | |
| 81 | + | |
| 82 | + /** | |
| 83 | + * Whether or not a {@code NotSerializableException} should be thrown | |
| 84 | + * during serialization, when the value associated with this key does | |
| 85 | + * not implement {@code Serializable}. | |
| 86 | + */ | |
| 87 | + private final boolean reportValueNotSerializable; | |
| 88 | + | |
| 89 | + /** | |
| 90 | + * Constructs a key with the {@code reportValueNotSerializable} property | |
| 91 | + * set to {@code false}. | |
| 92 | + */ | |
| 93 | + private ClientPropertyKey() { | |
| 94 | + this(false); | |
| 95 | + } | |
| 96 | + | |
| 97 | + /** | |
| 98 | + * Constructs a key with the {@code reportValueNotSerializable} property | |
| 99 | + * set to the given value. | |
| 100 | + */ | |
| 101 | + private ClientPropertyKey(boolean reportValueNotSerializable) { | |
| 102 | + this.reportValueNotSerializable = reportValueNotSerializable; | |
| 103 | + } | |
| 104 | + | |
| 105 | + /** | |
| 106 | + * Returns whether or not a {@code NotSerializableException} should be thrown | |
| 107 | + * during serialization, when the value associated with this key does | |
| 108 | + * not implement {@code Serializable}. | |
| 109 | + */ | |
| 110 | + public boolean getReportValueNotSerializable() { | |
| 111 | + return reportValueNotSerializable; | |
| 112 | + } | |
| 113 | +} | |