Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/java/beans/XMLDecoder/spec/TestProperty.java
41155 views
1
/*
2
* Copyright (c) 2008, 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.
8
*
9
* This code is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
* version 2 for more details (a copy is included in the LICENSE file that
13
* accompanied this code).
14
*
15
* You should have received a copy of the GNU General Public License version
16
* 2 along with this work; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18
*
19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
21
* questions.
22
*/
23
24
/*
25
* @test
26
* @summary Tests <property> element
27
* @run main/othervm -Djava.security.manager=allow TestProperty
28
* @author Sergey Malenkov
29
*/
30
31
import java.beans.XMLDecoder;
32
33
public final class TestProperty extends AbstractTest {
34
public static final String XML
35
= "<java>\n"
36
+ " <property name=\"owner\">\n"
37
+ " <property name=\"message\">\n"
38
+ " <string>message</string>\n"
39
+ " </property>\n"
40
+ " <property id=\"message\" name=\"message\"/>\n"
41
+ " <property name=\"indexed\" index=\"1\">\n"
42
+ " <string>indexed</string>\n"
43
+ " </property>\n"
44
+ " <property id=\"indexed\" name=\"indexed\" index=\"1\"/>\n"
45
+ " </property>\n"
46
+ " <var idref=\"message\"/>\n"
47
+ " <var idref=\"indexed\"/>\n"
48
+ "</java>";
49
50
public static void main(String[] args) {
51
new TestProperty().test(true);
52
}
53
54
private int index;
55
private String message;
56
57
public String getMessage() {
58
return this.message;
59
}
60
61
public void setMessage(String message) {
62
this.message = message;
63
}
64
65
public String getIndexed(int index) {
66
if (this.index != index) {
67
throw new Error("unexpected index");
68
}
69
return this.message;
70
}
71
72
public void setIndexed(int index, String message) {
73
this.index = index;
74
this.message = message;
75
}
76
77
@Override
78
protected void validate(XMLDecoder decoder) {
79
decoder.setOwner(this);
80
validate(decoder, "message");
81
validate(decoder, "indexed");
82
}
83
84
private static void validate(XMLDecoder decoder, String name) {
85
if (!decoder.readObject().equals(name)) {
86
throw new Error(name + " expected");
87
}
88
}
89
}
90
91