Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/java/util/Calendar/CalendarTestScripts/GregorianAdapter.java
41152 views
1
/*
2
* Copyright (c) 2007, 2018, 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
import java.util.GregorianCalendar;
25
import java.util.Locale;
26
import java.util.TimeZone;
27
28
public class GregorianAdapter extends GregorianCalendar {
29
static final int ALL_FIELDS = (1 << FIELD_COUNT) - 1;
30
31
public GregorianAdapter() {
32
super();
33
}
34
35
public GregorianAdapter(TimeZone tz) {
36
super(tz);
37
}
38
39
public GregorianAdapter(Locale loc) {
40
super(loc);
41
}
42
43
public GregorianAdapter(TimeZone tz, Locale loc) {
44
super(tz, loc);
45
}
46
47
public void computeTime() {
48
super.computeTime();
49
}
50
51
public void computeFields() {
52
super.computeFields();
53
}
54
55
public void complete() {
56
super.complete();
57
}
58
59
StringBuffer msg = new StringBuffer();
60
61
void initTest() {
62
msg = new StringBuffer();
63
}
64
65
String getMessage() {
66
String s = msg.toString();
67
msg = new StringBuffer();
68
return " " + s;
69
}
70
71
void setMessage(String msg) {
72
this.msg = new StringBuffer(msg);
73
}
74
75
void appendMessage(String msg) {
76
this.msg.append(msg);
77
}
78
79
boolean getStatus() {
80
return msg.length() == 0;
81
}
82
83
int getSetStateFields() {
84
int mask = 0;
85
for (int i = 0; i < FIELD_COUNT; i++) {
86
if (isSet(i)) {
87
mask |= 1 << i;
88
}
89
}
90
return mask;
91
}
92
93
int[] getFields() {
94
int[] fds = new int[fields.length];
95
System.arraycopy(fields, 0, fds, 0, fds.length);
96
return fds;
97
}
98
99
boolean checkInternalDate(int year, int month, int dayOfMonth) {
100
initTest();
101
checkInternalField(YEAR, year);
102
checkInternalField(MONTH, month);
103
checkInternalField(DAY_OF_MONTH, dayOfMonth);
104
return getStatus();
105
}
106
107
boolean checkInternalDate(int year, int month, int dayOfMonth, int dayOfWeek) {
108
initTest();
109
checkInternalField(YEAR, year);
110
checkInternalField(MONTH, month);
111
checkInternalField(DAY_OF_MONTH, dayOfMonth);
112
checkInternalField(DAY_OF_WEEK, dayOfWeek);
113
return getStatus();
114
}
115
116
boolean checkInternalField(int field, int expectedValue) {
117
int val;
118
if ((val = internalGet(field)) != expectedValue) {
119
appendMessage("internalGet(" + CalendarAdapter.FIELD_NAMES[field] + "): got " + val +
120
", expected " + expectedValue + "; ");
121
return false;
122
}
123
return true;
124
}
125
}
126
127