-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFormatStyle.bal
More file actions
345 lines (298 loc) · 13.5 KB
/
Copy pathFormatStyle.bal
File metadata and controls
345 lines (298 loc) · 13.5 KB
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
import ballerina/jballerina.java;
import ballerina/jballerina.java.arrays as jarrays;
# Ballerina class mapping for the Java `java.time.format.FormatStyle` class.
#
# `FormatStyle` is an enum representing the degree of detail to use when formatting a
# localized date, time, or date-time — from `FULL` (most detailed) to `SHORT` (most compact).
# Used together with `DateTimeFormatter.ofLocalizedDate`/`ofLocalizedDateTime`/`ofLocalizedTime`
# and a `Locale` to produce human-readable, locale-appropriate output.
@java:Binding {'class: "java.time.format.FormatStyle"}
public distinct class FormatStyle {
*java:JObject;
*Enum;
# The `handle` field that stores the reference to the `java.time.format.FormatStyle` object.
public handle jObj;
# The init function of the Ballerina class mapping the `java.time.format.FormatStyle` Java class.
#
# + obj - The `handle` value containing the Java reference of the object.
public function init(handle obj) {
self.jObj = obj;
}
# Returns the name of this format style, exactly as declared (e.g. "FULL").
#
# + return - The `string` form of the Java object instance.
public function toString() returns string {
return java:toString(self.jObj) ?: "";
}
# Compares this format style to another enum constant by declaration (ordinal) order.
#
# + other - The enum constant to compare against, not null
# + return - Negative, zero, or positive if this constant is declared before, at the same position as, or after `other`
public function compareTo(Enum other) returns int {
return java_time_format_FormatStyle_compareTo(self.jObj, other.jObj);
}
# Returns an optional descriptor of this format style for use with nominal descriptors
# (Java's `Constable` mechanism).
#
# + return - The optional descriptor
function describeConstable() returns Optional {
handle externalObj = java_time_format_FormatStyle_describeConstable(self.jObj);
Optional newObj = new (externalObj);
return newObj;
}
# Checks whether this format style is equal to another object. Enum constants are only
# ever equal to themselves.
#
# + other - The object to compare against, may be `()`
# + return - `true` if equal, `false` otherwise
public function isEquals(Object other) returns boolean {
return java_time_format_FormatStyle_equals(self.jObj, other.jObj);
}
# Returns the runtime class of this object.
#
# + return - The `Class` object representing the runtime class, not null
public function getClass() returns Class {
handle externalObj = java_time_format_FormatStyle_getClass(self.jObj);
Class newObj = new (externalObj);
return newObj;
}
# Returns the `Class` object corresponding to this enum constant's declaring type.
#
# + return - The `Class` of the enum type, not null
public function getDeclaringClass() returns Class {
handle externalObj = java_time_format_FormatStyle_getDeclaringClass(self.jObj);
Class newObj = new (externalObj);
return newObj;
}
# Returns the hash code for this format style.
#
# + return - The hash code
public function hashCode() returns int {
return java_time_format_FormatStyle_hashCode(self.jObj);
}
# Returns the name of this enum constant, exactly as declared (e.g. "FULL", "SHORT").
#
# + return - The declared name of this constant
public function name() returns string {
return java:toString(java_time_format_FormatStyle_name(self.jObj)) ?: "";
}
# Wakes up a single thread that is waiting on this object's monitor.
public function notify() {
java_time_format_FormatStyle_notify(self.jObj);
}
# Wakes up all threads that are waiting on this object's monitor.
public function notifyAll() {
java_time_format_FormatStyle_notifyAll(self.jObj);
}
# Returns the position of this constant in its enum declaration, where the first constant
# (`FULL`) has an ordinal of zero.
#
# + return - The ordinal of this constant, from 0 (FULL) to 3 (SHORT)
public function ordinal() returns int {
return java_time_format_FormatStyle_ordinal(self.jObj);
}
# Causes the current thread to wait until it is woken up on this object's monitor, typically
# via a call to notify() or notifyAll().
#
# + return - An `InterruptedException` if the waiting thread is interrupted, otherwise `()`
public function doWait() returns InterruptedException? {
error|() externalObj = java_time_format_FormatStyle_wait(self.jObj);
if (externalObj is error) {
InterruptedException e = error InterruptedException(INTERRUPTEDEXCEPTION, externalObj, message = externalObj.message());
return e;
}
}
# Causes the current thread to wait until either it is woken up or the specified timeout elapses.
#
# + timeoutMillis - The maximum time to wait, in milliseconds
# + return - An `InterruptedException` if the waiting thread is interrupted, otherwise `()`
public function waitWithTimeout(int timeoutMillis) returns InterruptedException? {
error|() externalObj = java_time_format_FormatStyle_wait2(self.jObj, timeoutMillis);
if (externalObj is error) {
InterruptedException e = error InterruptedException(INTERRUPTEDEXCEPTION, externalObj, message = externalObj.message());
return e;
}
}
# Causes the current thread to wait until either it is woken up or the specified timeout
# elapses, with additional nanosecond precision.
#
# + timeoutMillis - The maximum time to wait, in milliseconds
# + additionalNanos - The additional time to wait, in nanoseconds, from 0 to 999999
# + return - An `InterruptedException` if the waiting thread is interrupted, otherwise `()`
public function waitWithTimeoutAndNanos(int timeoutMillis, int additionalNanos) returns InterruptedException? {
error|() externalObj = java_time_format_FormatStyle_wait3(self.jObj, timeoutMillis, additionalNanos);
if (externalObj is error) {
InterruptedException e = error InterruptedException(INTERRUPTEDEXCEPTION, externalObj, message = externalObj.message());
return e;
}
}
}
# Returns the enum constant of the specified enum type with the specified name.
# This is the generic `Enum.valueOf(Class, String)` form.
#
# INTERNAL — duplicates `ofEnumValue` in Enum.bal and similar generic valueOf functions in
# Month.bal/DayOfWeek.bal (all call the same underlying `Enum.valueOf(Class, String)` via
# different binding paths, since `valueOf` cannot be overridden per enum subtype in Java).
# Kept package-private as a placeholder in case a future generic use case needs it via this
# specific class; ordinary users should use `formatStyleValueOf(string)` instead.
#
# + enumClass - The Class object of the enum type
# + name - The name of the constant to return
# + return - Enum|error — the enum constant, or an error if no constant with the given name exists
public function formatStyleValueOfEnum(Class enumClass, string name) returns Enum|error {
handle externalObj = check trap java_time_format_FormatStyle_valueOf(enumClass.jObj, java:fromString(name));
Enum newObj = new (externalObj);
return newObj;
}
# Returns the FormatStyle constant with the specified name (e.g. "FULL", "SHORT").
#
# + name - The name of the constant to return
# + return - FormatStyle|error — the corresponding FormatStyle, or an error if no constant with that name exists
public function formatStyleValueOf(string name) returns FormatStyle|error {
handle externalObj = check trap java_time_format_FormatStyle_valueOf2(java:fromString(name));
FormatStyle newObj = new (externalObj);
return newObj;
}
# Returns all four FormatStyle constants, in declaration order (FULL, LONG, MEDIUM, SHORT).
#
# + return - FormatStyle[]|error — an array of all four FormatStyle constants, or an error if the underlying Java array conversion fails
public function getFormatStyleValues() returns FormatStyle[]|error {
handle externalObj = java_time_format_FormatStyle_values();
FormatStyle[] newObj = [];
handle[] anyObj = <handle[]>check jarrays:fromHandle(externalObj, "handle");
int count = anyObj.length();
foreach int i in 0 ... count - 1 {
FormatStyle element = new (anyObj[i]);
newObj[i] = element;
}
return newObj;
}
# Returns the constant for the most detailed, verbose format style, such as
# "Wednesday, July 15, 2026" for a date.
#
# + return - The FULL format style constant
public function formatStyleGetFull() returns FormatStyle {
handle externalObj = java_time_format_FormatStyle_getFULL();
FormatStyle newObj = new (externalObj);
return newObj;
}
# Returns the constant for a detailed format style, such as "July 15, 2026" for a date.
#
# + return - The LONG format style constant
public function formatStyleGetLong() returns FormatStyle {
handle externalObj = java_time_format_FormatStyle_getLONG();
FormatStyle newObj = new (externalObj);
return newObj;
}
# Returns the constant for a moderately detailed format style, such as "Jul 15, 2026" for a date.
#
# + return - The MEDIUM format style constant
public function formatStyleGetMedium() returns FormatStyle {
handle externalObj = java_time_format_FormatStyle_getMEDIUM();
FormatStyle newObj = new (externalObj);
return newObj;
}
# Returns the constant for the most compact format style, such as "7/15/26" for a date.
#
# + return - The SHORT format style constant
public function formatStyleGetShort() returns FormatStyle {
handle externalObj = java_time_format_FormatStyle_getSHORT();
FormatStyle newObj = new (externalObj);
return newObj;
}
function java_time_format_FormatStyle_compareTo(handle receiver, handle arg0) returns int = @java:Method {
name: "compareTo",
'class: "java.time.format.FormatStyle",
paramTypes: ["java.lang.Enum"]
} external;
function java_time_format_FormatStyle_describeConstable(handle receiver) returns handle = @java:Method {
name: "describeConstable",
'class: "java.time.format.FormatStyle",
paramTypes: []
} external;
function java_time_format_FormatStyle_equals(handle receiver, handle arg0) returns boolean = @java:Method {
name: "equals",
'class: "java.time.format.FormatStyle",
paramTypes: ["java.lang.Object"]
} external;
function java_time_format_FormatStyle_getClass(handle receiver) returns handle = @java:Method {
name: "getClass",
'class: "java.time.format.FormatStyle",
paramTypes: []
} external;
function java_time_format_FormatStyle_getDeclaringClass(handle receiver) returns handle = @java:Method {
name: "getDeclaringClass",
'class: "java.time.format.FormatStyle",
paramTypes: []
} external;
function java_time_format_FormatStyle_hashCode(handle receiver) returns int = @java:Method {
name: "hashCode",
'class: "java.time.format.FormatStyle",
paramTypes: []
} external;
function java_time_format_FormatStyle_name(handle receiver) returns handle = @java:Method {
name: "name",
'class: "java.time.format.FormatStyle",
paramTypes: []
} external;
function java_time_format_FormatStyle_notify(handle receiver) = @java:Method {
name: "notify",
'class: "java.time.format.FormatStyle",
paramTypes: []
} external;
function java_time_format_FormatStyle_notifyAll(handle receiver) = @java:Method {
name: "notifyAll",
'class: "java.time.format.FormatStyle",
paramTypes: []
} external;
function java_time_format_FormatStyle_ordinal(handle receiver) returns int = @java:Method {
name: "ordinal",
'class: "java.time.format.FormatStyle",
paramTypes: []
} external;
function java_time_format_FormatStyle_valueOf(handle arg0, handle arg1) returns handle|error = @java:Method {
name: "valueOf",
'class: "java.time.format.FormatStyle",
paramTypes: ["java.lang.Class", "java.lang.String"]
} external;
function java_time_format_FormatStyle_valueOf2(handle arg0) returns handle|error = @java:Method {
name: "valueOf",
'class: "java.time.format.FormatStyle",
paramTypes: ["java.lang.String"]
} external;
function java_time_format_FormatStyle_values() returns handle = @java:Method {
name: "values",
'class: "java.time.format.FormatStyle",
paramTypes: []
} external;
function java_time_format_FormatStyle_wait(handle receiver) returns error? = @java:Method {
name: "wait",
'class: "java.time.format.FormatStyle",
paramTypes: []
} external;
function java_time_format_FormatStyle_wait2(handle receiver, int arg0) returns error? = @java:Method {
name: "wait",
'class: "java.time.format.FormatStyle",
paramTypes: ["long"]
} external;
function java_time_format_FormatStyle_wait3(handle receiver, int arg0, int arg1) returns error? = @java:Method {
name: "wait",
'class: "java.time.format.FormatStyle",
paramTypes: ["long", "int"]
} external;
function java_time_format_FormatStyle_getFULL() returns handle = @java:FieldGet {
name: "FULL",
'class: "java.time.format.FormatStyle"
} external;
function java_time_format_FormatStyle_getLONG() returns handle = @java:FieldGet {
name: "LONG",
'class: "java.time.format.FormatStyle"
} external;
function java_time_format_FormatStyle_getMEDIUM() returns handle = @java:FieldGet {
name: "MEDIUM",
'class: "java.time.format.FormatStyle"
} external;
function java_time_format_FormatStyle_getSHORT() returns handle = @java:FieldGet {
name: "SHORT",
'class: "java.time.format.FormatStyle"
} external;