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