@ui5/webcomponents-localization 1.22.0-rc.1 → 1.22.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/dist/.tsbuildinfo +1 -1
- package/dist/generated/assets/cldr/ar.json +102 -62
- package/dist/generated/assets/cldr/ar_EG.json +102 -62
- package/dist/generated/assets/cldr/ar_SA.json +102 -62
- package/dist/generated/assets/cldr/bg.json +364 -325
- package/dist/generated/assets/cldr/ca.json +491 -453
- package/dist/generated/assets/cldr/cs.json +431 -324
- package/dist/generated/assets/cldr/cy.json +608 -340
- package/dist/generated/assets/cldr/da.json +290 -227
- package/dist/generated/assets/cldr/de.json +348 -241
- package/dist/generated/assets/cldr/de_AT.json +348 -241
- package/dist/generated/assets/cldr/de_CH.json +347 -240
- package/dist/generated/assets/cldr/el.json +128 -100
- package/dist/generated/assets/cldr/el_CY.json +128 -100
- package/dist/generated/assets/cldr/en.json +538 -512
- package/dist/generated/assets/cldr/en_AU.json +583 -520
- package/dist/generated/assets/cldr/en_GB.json +485 -441
- package/dist/generated/assets/cldr/en_HK.json +519 -474
- package/dist/generated/assets/cldr/en_IE.json +485 -440
- package/dist/generated/assets/cldr/en_IN.json +465 -420
- package/dist/generated/assets/cldr/en_NZ.json +505 -460
- package/dist/generated/assets/cldr/en_PG.json +505 -460
- package/dist/generated/assets/cldr/en_SG.json +505 -460
- package/dist/generated/assets/cldr/en_ZA.json +485 -440
- package/dist/generated/assets/cldr/es.json +709 -456
- package/dist/generated/assets/cldr/es_AR.json +687 -434
- package/dist/generated/assets/cldr/es_BO.json +721 -468
- package/dist/generated/assets/cldr/es_CL.json +567 -422
- package/dist/generated/assets/cldr/es_CO.json +485 -339
- package/dist/generated/assets/cldr/es_MX.json +734 -481
- package/dist/generated/assets/cldr/es_PE.json +409 -372
- package/dist/generated/assets/cldr/es_UY.json +433 -396
- package/dist/generated/assets/cldr/es_VE.json +453 -416
- package/dist/generated/assets/cldr/et.json +340 -307
- package/dist/generated/assets/cldr/fa.json +96 -34
- package/dist/generated/assets/cldr/fi.json +359 -308
- package/dist/generated/assets/cldr/fr.json +347 -321
- package/dist/generated/assets/cldr/fr_BE.json +347 -321
- package/dist/generated/assets/cldr/fr_CA.json +458 -432
- package/dist/generated/assets/cldr/fr_CH.json +290 -264
- package/dist/generated/assets/cldr/fr_LU.json +347 -321
- package/dist/generated/assets/cldr/he.json +241 -130
- package/dist/generated/assets/cldr/hi.json +103 -53
- package/dist/generated/assets/cldr/hr.json +467 -410
- package/dist/generated/assets/cldr/hu.json +246 -195
- package/dist/generated/assets/cldr/id.json +478 -406
- package/dist/generated/assets/cldr/it.json +418 -362
- package/dist/generated/assets/cldr/it_CH.json +418 -362
- package/dist/generated/assets/cldr/ja.json +58 -18
- package/dist/generated/assets/cldr/kk.json +562 -398
- package/dist/generated/assets/cldr/ko.json +36 -15
- package/dist/generated/assets/cldr/lt.json +320 -231
- package/dist/generated/assets/cldr/lv.json +184 -120
- package/dist/generated/assets/cldr/ms.json +460 -388
- package/dist/generated/assets/cldr/nb.json +160 -92
- package/dist/generated/assets/cldr/nl.json +621 -373
- package/dist/generated/assets/cldr/nl_BE.json +621 -373
- package/dist/generated/assets/cldr/pl.json +590 -279
- package/dist/generated/assets/cldr/pt.json +696 -334
- package/dist/generated/assets/cldr/pt_PT.json +730 -454
- package/dist/generated/assets/cldr/ro.json +409 -339
- package/dist/generated/assets/cldr/ru.json +317 -279
- package/dist/generated/assets/cldr/ru_UA.json +312 -274
- package/dist/generated/assets/cldr/sk.json +454 -413
- package/dist/generated/assets/cldr/sl.json +118 -80
- package/dist/generated/assets/cldr/sr.json +294 -142
- package/dist/generated/assets/cldr/sr_Latn.json +972 -824
- package/dist/generated/assets/cldr/sv.json +382 -338
- package/dist/generated/assets/cldr/th.json +56 -36
- package/dist/generated/assets/cldr/tr.json +371 -320
- package/dist/generated/assets/cldr/uk.json +340 -290
- package/dist/generated/assets/cldr/vi.json +352 -328
- package/dist/generated/assets/cldr/zh_CN.json +34 -10
- package/dist/generated/assets/cldr/zh_HK.json +33 -9
- package/dist/generated/assets/cldr/zh_SG.json +33 -9
- package/dist/generated/assets/cldr/zh_TW.json +32 -8
- package/dist/sap/base/Event.js +59 -0
- package/dist/sap/base/Eventing.js +146 -0
- package/dist/sap/base/Log.js +2 -239
- package/dist/sap/base/assert.js +28 -1
- package/dist/sap/base/config/MemoryConfigurationProvider.js +20 -0
- package/dist/sap/base/config.js +17 -0
- package/dist/sap/base/i18n/Formatting.js +1130 -0
- package/dist/sap/base/i18n/LanguageTag.js +168 -30
- package/dist/sap/base/i18n/date/CalendarType.js +36 -1
- package/dist/sap/base/i18n/date/CalendarWeekNumbering.js +76 -1
- package/dist/sap/base/i18n/date/TimezoneUtils.js +242 -12
- package/dist/sap/base/strings/camelize.js +30 -0
- package/dist/sap/base/strings/formatMessage.js +88 -15
- package/dist/sap/base/util/ObjectPath.js +95 -3
- package/dist/sap/base/util/Version.js +157 -0
- package/dist/sap/base/util/_merge.js +83 -26
- package/dist/sap/base/util/array/uniqueSort.js +37 -15
- package/dist/sap/base/util/deepClone.js +102 -0
- package/dist/sap/base/util/deepEqual.js +75 -51
- package/dist/sap/base/util/extend.js +58 -7
- package/dist/sap/base/util/isEmptyObject.js +34 -0
- package/dist/sap/base/util/isPlainObject.js +35 -1
- package/dist/sap/base/util/now.js +24 -3
- package/dist/sap/base/util/resolveReference.js +157 -0
- package/dist/sap/base/util/uid.js +27 -0
- package/dist/sap/ui/base/DataType.js +657 -0
- package/dist/sap/ui/base/Interface.js +47 -1
- package/dist/sap/ui/base/Metadata.js +433 -180
- package/dist/sap/ui/base/Object.js +284 -48
- package/dist/sap/ui/core/CalendarType.js +23 -1
- package/dist/sap/ui/core/Locale.js +189 -57
- package/dist/sap/ui/core/LocaleData.js +2670 -1380
- package/dist/sap/ui/core/Supportability.js +5 -0
- package/dist/sap/ui/core/Theming.js +539 -0
- package/dist/sap/ui/core/date/Buddhist.js +162 -87
- package/dist/sap/ui/core/date/CalendarUtils.js +61 -21
- package/dist/sap/ui/core/date/CalendarWeekNumbering.js +29 -1
- package/dist/sap/ui/core/date/Gregorian.js +25 -10
- package/dist/sap/ui/core/date/Islamic.js +298 -185
- package/dist/sap/ui/core/date/Japanese.js +210 -115
- package/dist/sap/ui/core/date/Persian.js +324 -195
- package/dist/sap/ui/core/date/UI5Date.js +923 -237
- package/dist/sap/ui/core/date/UniversalDate.js +1238 -245
- package/dist/sap/ui/core/date/_Calendars.js +10 -1
- package/dist/sap/ui/core/format/DateFormat.js +3163 -2145
- package/dist/sap/ui/core/format/TimezoneUtil.js +23 -1
- package/package-scripts.cjs +4 -10
- package/package.json +9 -5
- package/used-modules.txt +20 -1
- package/dist/sap/ui/Device.js +0 -5
@@ -1,230 +1,483 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
/*!
|
2
|
+
* OpenUI5
|
3
|
+
* (c) Copyright 2009-2024 SAP SE or an SAP affiliate company.
|
4
|
+
* Licensed under the Apache License, Version 2.0 - see LICENSE.txt.
|
5
|
+
*/
|
6
|
+
// Provides class sap.ui.base.Metadata
|
7
|
+
import ObjectPath from "../../base/util/ObjectPath.js";
|
8
|
+
import assert from "../../base/assert.js";
|
9
|
+
import Log from "../../base/Log.js";
|
10
|
+
import uniqueSort from "../../base/util/array/uniqueSort.js";
|
5
11
|
function isFunction(obj) {
|
6
|
-
|
12
|
+
return typeof obj === "function";
|
7
13
|
}
|
14
|
+
|
15
|
+
/**
|
16
|
+
* Creates a new metadata object from the given static infos.
|
17
|
+
*
|
18
|
+
* <b>Note:</b> Throughout this class documentation, the described subclass of Object
|
19
|
+
* is referenced as <i>the described class</i>.
|
20
|
+
*
|
21
|
+
* @param {string} sClassName Fully qualified name of the described class
|
22
|
+
* @param {object} oClassInfo Info to construct the class and its metadata from
|
23
|
+
* @param {sap.ui.base.Object.MetadataOptions} [oClassInfo.metadata]
|
24
|
+
* The metadata object describing the class
|
25
|
+
*
|
26
|
+
* @class Metadata for a class.
|
27
|
+
* @author Frank Weigel
|
28
|
+
* @version 1.120.3
|
29
|
+
* @since 0.8.6
|
30
|
+
* @public
|
31
|
+
* @alias sap.ui.base.Metadata
|
32
|
+
*/
|
8
33
|
var Metadata = function (sClassName, oClassInfo) {
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
34
|
+
assert(typeof sClassName === "string" && sClassName, "Metadata: sClassName must be a non-empty string");
|
35
|
+
assert(typeof oClassInfo === "object", "Metadata: oClassInfo must be empty or an object");
|
36
|
+
|
37
|
+
// support for old usage of Metadata
|
38
|
+
if (!oClassInfo || typeof oClassInfo.metadata !== "object") {
|
39
|
+
oClassInfo = {
|
40
|
+
metadata: oClassInfo || {},
|
41
|
+
// retrieve class by its name. Using a lookup costs time but avoids the need for redundant arguments to this function
|
42
|
+
constructor: ObjectPath.get(sClassName) // legacy-relevant, code path not used by extend call
|
43
|
+
};
|
44
|
+
oClassInfo.metadata.__version = 1.0;
|
45
|
+
}
|
46
|
+
oClassInfo.metadata.__version = oClassInfo.metadata.__version || 2.0;
|
47
|
+
if (!isFunction(oClassInfo.constructor)) {
|
48
|
+
throw Error("constructor for class " + sClassName + " must have been declared before creating metadata for it");
|
49
|
+
}
|
50
|
+
|
51
|
+
// invariant: oClassInfo exists, oClassInfo.metadata exists, oClassInfo.constructor exists
|
52
|
+
this._sClassName = sClassName;
|
53
|
+
this._oClass = oClassInfo.constructor;
|
54
|
+
this.extend(oClassInfo);
|
25
55
|
};
|
56
|
+
|
57
|
+
/**
|
58
|
+
* @private
|
59
|
+
* @final
|
60
|
+
*/
|
26
61
|
Metadata.prototype.extend = function (oClassInfo) {
|
27
|
-
|
28
|
-
|
62
|
+
this.applySettings(oClassInfo);
|
63
|
+
this.afterApplySettings();
|
29
64
|
};
|
65
|
+
|
66
|
+
/**
|
67
|
+
* @private
|
68
|
+
* @since 1.3.1
|
69
|
+
*/
|
30
70
|
Metadata.prototype.applySettings = function (oClassInfo) {
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
if (!isFunction(oParentClass)) {
|
42
|
-
Log.fatal('base class \'' + oStaticInfo.baseType + '\' does not exist');
|
43
|
-
}
|
44
|
-
}
|
45
|
-
if (oParentClass.getMetadata) {
|
46
|
-
this._oParent = oParentClass.getMetadata();
|
47
|
-
assert(oParentClass === oParentClass.getMetadata().getClass(), 'Metadata: oParentClass must match the class in the parent metadata');
|
48
|
-
} else {
|
49
|
-
this._oParent = new Metadata(oStaticInfo.baseType, {});
|
50
|
-
}
|
71
|
+
var that = this,
|
72
|
+
oStaticInfo = oClassInfo.metadata,
|
73
|
+
oPrototype;
|
74
|
+
if (oStaticInfo.baseType) {
|
75
|
+
var oParentClass;
|
76
|
+
if (isFunction(oStaticInfo.baseType)) {
|
77
|
+
oParentClass = oStaticInfo.baseType;
|
78
|
+
if (!isFunction(oParentClass.getMetadata)) {
|
79
|
+
throw new TypeError("baseType must be a UI5 class with a static getMetadata function");
|
80
|
+
}
|
51
81
|
} else {
|
52
|
-
|
82
|
+
// lookup base class by its name - same reasoning as above
|
83
|
+
oParentClass = ObjectPath.get(oStaticInfo.baseType); // legacy-relevant, code path not used by extend call
|
84
|
+
if (!isFunction(oParentClass)) {
|
85
|
+
Log.fatal("base class '" + oStaticInfo.baseType + "' does not exist");
|
86
|
+
}
|
53
87
|
}
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
oPrototype = this._oClass.prototype;
|
62
|
-
for (var n in oClassInfo) {
|
63
|
-
if (n !== 'metadata' && n !== 'constructor') {
|
64
|
-
oPrototype[n] = oClassInfo[n];
|
65
|
-
if (!n.match(/^_|^on|^init$|^exit$/)) {
|
66
|
-
that._aPublicMethods.push(n);
|
67
|
-
}
|
68
|
-
}
|
88
|
+
// link metadata with base metadata
|
89
|
+
if (oParentClass.getMetadata) {
|
90
|
+
this._oParent = oParentClass.getMetadata();
|
91
|
+
assert(oParentClass === oParentClass.getMetadata().getClass(), "Metadata: oParentClass must match the class in the parent metadata");
|
92
|
+
} else {
|
93
|
+
// fallback, if base class has no metadata - can only happen if baseType is a string
|
94
|
+
this._oParent = new Metadata(oStaticInfo.baseType, {});
|
69
95
|
}
|
96
|
+
} else {
|
97
|
+
this._oParent = undefined;
|
98
|
+
}
|
99
|
+
this._bAbstract = !!oStaticInfo["abstract"];
|
100
|
+
this._bFinal = !!oStaticInfo["final"];
|
101
|
+
this._sStereotype = oStaticInfo.stereotype || (this._oParent ? this._oParent._sStereotype : "object");
|
102
|
+
this._bDeprecated = !!oStaticInfo["deprecated"];
|
103
|
+
|
104
|
+
// handle interfaces
|
105
|
+
this._aInterfaces = oStaticInfo.interfaces || [];
|
106
|
+
|
107
|
+
// take over metadata from static info
|
108
|
+
this._aPublicMethods = oStaticInfo.publicMethods || [];
|
109
|
+
|
110
|
+
// interfaces info possibly not unique
|
111
|
+
this._bInterfacesUnique = false;
|
112
|
+
|
113
|
+
// enrich prototype
|
114
|
+
oPrototype = this._oClass.prototype;
|
115
|
+
for (var n in oClassInfo) {
|
116
|
+
if (n !== "metadata" && n !== "constructor") {
|
117
|
+
oPrototype[n] = oClassInfo[n];
|
118
|
+
if (!n.match(/^_|^on|^init$|^exit$/)) {
|
119
|
+
// TODO hard coded knowledge about event handlers ("on") and about init/exit hooks is not nice....
|
120
|
+
that._aPublicMethods.push(n);
|
121
|
+
}
|
122
|
+
}
|
123
|
+
}
|
70
124
|
};
|
125
|
+
|
126
|
+
/**
|
127
|
+
* Called after new settings have been applied.
|
128
|
+
*
|
129
|
+
* Typically, this method is used to do some cleanup (e.g. uniqueness)
|
130
|
+
* or to calculate an optimized version of some data.
|
131
|
+
* @private
|
132
|
+
* @since 1.3.1
|
133
|
+
*/
|
71
134
|
Metadata.prototype.afterApplySettings = function () {
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
135
|
+
// create the flattened "all" view
|
136
|
+
if (this._oParent) {
|
137
|
+
this._aAllPublicMethods = this._oParent._aAllPublicMethods.concat(this._aPublicMethods);
|
138
|
+
this._bInterfacesUnique = false;
|
139
|
+
} else {
|
140
|
+
this._aAllPublicMethods = this._aPublicMethods;
|
141
|
+
}
|
78
142
|
};
|
143
|
+
|
144
|
+
/**
|
145
|
+
* Stereotype of the described class.
|
146
|
+
*
|
147
|
+
* @experimental might be enhanced to a set of stereotypes
|
148
|
+
* @private
|
149
|
+
* @ui5-restricted
|
150
|
+
*/
|
79
151
|
Metadata.prototype.getStereotype = function () {
|
80
|
-
|
152
|
+
return this._sStereotype;
|
81
153
|
};
|
154
|
+
|
155
|
+
/**
|
156
|
+
* Returns the fully qualified name of the described class
|
157
|
+
* @return {string} name of the described class
|
158
|
+
* @public
|
159
|
+
*/
|
82
160
|
Metadata.prototype.getName = function () {
|
83
|
-
|
161
|
+
return this._sClassName;
|
84
162
|
};
|
163
|
+
|
164
|
+
/**
|
165
|
+
* Returns the (constructor of the) described class
|
166
|
+
* @return {function(new:sap.ui.base.Object)} class described by this metadata
|
167
|
+
* @public
|
168
|
+
*/
|
85
169
|
Metadata.prototype.getClass = function () {
|
86
|
-
|
170
|
+
return this._oClass;
|
87
171
|
};
|
172
|
+
|
173
|
+
/**
|
174
|
+
* Returns the metadata object of the base class of the described class
|
175
|
+
* or undefined if the class has no (documented) base class.
|
176
|
+
*
|
177
|
+
* @return {sap.ui.base.Metadata | undefined} metadata of the base class
|
178
|
+
* @public
|
179
|
+
*/
|
88
180
|
Metadata.prototype.getParent = function () {
|
89
|
-
|
181
|
+
return this._oParent;
|
90
182
|
};
|
183
|
+
|
184
|
+
/**
|
185
|
+
* Removes duplicate names in place from the interfaces and public methods members of this metadata object.
|
186
|
+
*
|
187
|
+
* @private
|
188
|
+
*/
|
91
189
|
Metadata.prototype._dedupInterfaces = function () {
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
190
|
+
if (!this._bInterfacesUnique) {
|
191
|
+
uniqueSort(this._aInterfaces);
|
192
|
+
uniqueSort(this._aPublicMethods);
|
193
|
+
uniqueSort(this._aAllPublicMethods);
|
194
|
+
this._bInterfacesUnique = true;
|
195
|
+
}
|
98
196
|
};
|
197
|
+
|
198
|
+
/**
|
199
|
+
* Returns an array with the names of the public methods declared by the described class, methods of
|
200
|
+
* ancestors are not listed.
|
201
|
+
*
|
202
|
+
* @return {string[]} array with names of public methods declared by the described class
|
203
|
+
* @deprecated As of 1.58, this method should not be used for productive code. The accuracy of the returned
|
204
|
+
* information highly depends on the concrete class and is not actively monitored. There might be
|
205
|
+
* more public methods or some of the returned methods might not really be intended for public use.
|
206
|
+
* In general, pure visibility information should not be exposed in runtime metadata but be part of the
|
207
|
+
* documentation.
|
208
|
+
* Subclasses of <code>sap.ui.base.Object</code> might decide to provide runtime metadata describing
|
209
|
+
* their public API, but this then should not be backed by this method.
|
210
|
+
* See {@link sap.ui.core.mvc.ControllerMetadata#getAllMethods} for an example.
|
211
|
+
* @public
|
212
|
+
*/
|
99
213
|
Metadata.prototype.getPublicMethods = function () {
|
100
|
-
|
101
|
-
|
214
|
+
this._dedupInterfaces();
|
215
|
+
return this._aPublicMethods;
|
102
216
|
};
|
217
|
+
|
218
|
+
/**
|
219
|
+
* Returns an array with the names of all public methods declared by the described class
|
220
|
+
* and all its ancestors classes.
|
221
|
+
*
|
222
|
+
* @return {string[]} array with names of all public methods provided by the described class and its ancestors
|
223
|
+
* @deprecated As of 1.58, this method should not be used for productive code. The accuracy of the returned
|
224
|
+
* information highly depends on the concrete class and is not actively monitored. There might be
|
225
|
+
* more public methods or some of the returned methods might not really be intended for public use.
|
226
|
+
* In general, pure visibility information should not be exposed in runtime metadata but be part of the
|
227
|
+
* documentation.
|
228
|
+
* Subclasses of <code>sap.ui.base.Object</code> might decide to provide runtime metadata describing
|
229
|
+
* their public API, but this then should not be backed by this method.
|
230
|
+
* See {@link sap.ui.core.mvc.ControllerMetadata#getAllMethods} for an example.
|
231
|
+
* @public
|
232
|
+
*/
|
103
233
|
Metadata.prototype.getAllPublicMethods = function () {
|
104
|
-
|
105
|
-
|
234
|
+
this._dedupInterfaces();
|
235
|
+
return this._aAllPublicMethods;
|
106
236
|
};
|
237
|
+
|
238
|
+
/**
|
239
|
+
* Returns the names of interfaces implemented by the described class.
|
240
|
+
* As the representation of interfaces is not clear yet, this method is still private.
|
241
|
+
*
|
242
|
+
* @return {string} array of names of implemented interfaces
|
243
|
+
* @private
|
244
|
+
*/
|
107
245
|
Metadata.prototype.getInterfaces = function () {
|
108
|
-
|
109
|
-
|
246
|
+
this._dedupInterfaces();
|
247
|
+
return this._aInterfaces;
|
110
248
|
};
|
249
|
+
|
250
|
+
/**
|
251
|
+
* Checks whether the described class or one of its ancestor classes implements the given interface.
|
252
|
+
*
|
253
|
+
* @param {string} sInterface name of the interface to test for (in dot notation)
|
254
|
+
* @return {boolean} whether this class implements the interface
|
255
|
+
* @public
|
256
|
+
*/
|
111
257
|
Metadata.prototype.isInstanceOf = function (sInterface) {
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
}
|
258
|
+
if (this._oParent) {
|
259
|
+
if (this._oParent.isInstanceOf(sInterface)) {
|
260
|
+
return true;
|
116
261
|
}
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
262
|
+
}
|
263
|
+
var a = this._aInterfaces;
|
264
|
+
for (var i = 0, l = a.length; i < l; i++) {
|
265
|
+
// FIXME doesn't handle interface inheritance (requires object representation for interfaces)
|
266
|
+
if (a[i] === sInterface) {
|
267
|
+
return true;
|
122
268
|
}
|
123
|
-
|
269
|
+
}
|
270
|
+
return false;
|
124
271
|
};
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
272
|
+
|
273
|
+
/*
|
274
|
+
* Lazy calculation of the set of implemented types.
|
275
|
+
*
|
276
|
+
* A calculation function is configured as getter for the <code>_mImplementedTypes</code>
|
277
|
+
* on the prototype object. On first call for a metadata instance, it collects
|
278
|
+
* the implemented types (classes, interfaces) from the described class and
|
279
|
+
* any base classes and writes it to the property <code>_mImplementedTypes</code> of the
|
280
|
+
* current instance of metadata. Future read access to the property will immediately
|
281
|
+
* return the instance property and not call the calculation function again.
|
282
|
+
*/
|
283
|
+
Object.defineProperty(Metadata.prototype, "_mImplementedTypes", {
|
284
|
+
get: function () {
|
285
|
+
if (this === Metadata.prototype) {
|
286
|
+
throw new Error("sap.ui.base.Metadata: The '_mImplementedTypes' property must not be accessed on the prototype");
|
287
|
+
}
|
288
|
+
|
289
|
+
// create map of types, including inherited types
|
290
|
+
// Note: to save processing time and memory, the inherited types are merged via the prototype chain of 'result'
|
291
|
+
var result = Object.create(this._oParent ? this._oParent._mImplementedTypes : null);
|
292
|
+
/*
|
293
|
+
* Flat alternative:
|
294
|
+
* var result = Object.create(null);
|
295
|
+
* if ( this._oParent ) {
|
296
|
+
* Object.assign(result, this._oParent._mImplementedTypes);
|
297
|
+
* }
|
298
|
+
*/
|
299
|
+
|
300
|
+
// add own class
|
301
|
+
result[this._sClassName] = true;
|
302
|
+
|
303
|
+
// additionally collect interfaces
|
304
|
+
var aInterfaces = this._aInterfaces,
|
305
|
+
i = aInterfaces.length;
|
306
|
+
while (i-- > 0) {
|
307
|
+
if (!result[aInterfaces[i]]) {
|
308
|
+
// take care to write property only if it hasn't been set already
|
309
|
+
result[aInterfaces[i]] = true;
|
310
|
+
}
|
311
|
+
}
|
312
|
+
|
313
|
+
// write instance property, hiding the getter on the prototype
|
314
|
+
Object.defineProperty(this, "_mImplementedTypes", {
|
315
|
+
value: Object.freeze(result),
|
316
|
+
writable: false,
|
317
|
+
configurable: false
|
318
|
+
});
|
319
|
+
return result;
|
320
|
+
},
|
321
|
+
configurable: true
|
146
322
|
});
|
323
|
+
|
324
|
+
/**
|
325
|
+
* Checks whether the class described by this metadata object is of the named type.
|
326
|
+
*
|
327
|
+
* This check is solely based on the type names as declared in the class metadata.
|
328
|
+
* It compares the given <code>vTypeName</code> with the name of this class, with the
|
329
|
+
* names of any base class of this class and with the names of all interfaces
|
330
|
+
* implemented by any of the aforementioned classes.
|
331
|
+
*
|
332
|
+
* Instead of a single type name, an array of type names can be given and the method
|
333
|
+
* will check if this class is of any of the listed types (logical or).
|
334
|
+
*
|
335
|
+
* Should the UI5 class system in future implement additional means of associating classes
|
336
|
+
* with type names (e.g. by introducing mixins), then this method might detect matches
|
337
|
+
* for those names as well.
|
338
|
+
*
|
339
|
+
* @param {string|string[]} vTypeName Type or types to check for
|
340
|
+
* @returns {boolean} Whether this class is of the given type or of any of the given types
|
341
|
+
* @public
|
342
|
+
* @since 1.56
|
343
|
+
*/
|
147
344
|
Metadata.prototype.isA = function (vTypeName) {
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
}
|
155
|
-
return false;
|
345
|
+
var mTypes = this._mImplementedTypes;
|
346
|
+
if (Array.isArray(vTypeName)) {
|
347
|
+
for (var i = 0; i < vTypeName.length; i++) {
|
348
|
+
if (vTypeName[i] in mTypes) {
|
349
|
+
return true;
|
350
|
+
}
|
156
351
|
}
|
157
|
-
return
|
352
|
+
return false;
|
353
|
+
}
|
354
|
+
// Note: the check with 'in' also finds inherited types via the prototype chain of mTypes
|
355
|
+
return vTypeName in mTypes;
|
158
356
|
};
|
357
|
+
|
358
|
+
/**
|
359
|
+
* Returns whether the described class is abstract
|
360
|
+
* @return {boolean} whether the class is abstract
|
361
|
+
* @public
|
362
|
+
*/
|
159
363
|
Metadata.prototype.isAbstract = function () {
|
160
|
-
|
364
|
+
return this._bAbstract;
|
161
365
|
};
|
366
|
+
|
367
|
+
/**
|
368
|
+
* Returns whether the described class is final
|
369
|
+
* @return {boolean} whether the class is final
|
370
|
+
* @public
|
371
|
+
*/
|
162
372
|
Metadata.prototype.isFinal = function () {
|
163
|
-
|
373
|
+
return this._bFinal;
|
164
374
|
};
|
375
|
+
|
376
|
+
/**
|
377
|
+
* Whether the described class is deprecated and should not be used any more
|
378
|
+
*
|
379
|
+
* @return {boolean} whether the class is considered deprecated
|
380
|
+
* @public
|
381
|
+
* @since 1.26.4
|
382
|
+
*/
|
165
383
|
Metadata.prototype.isDeprecated = function () {
|
166
|
-
|
384
|
+
return this._bDeprecated;
|
167
385
|
};
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
386
|
+
|
387
|
+
/**
|
388
|
+
* Adds one or more new methods to the list of API methods.
|
389
|
+
*
|
390
|
+
* Can be used by contributer classes (like the EnabledPropagator) to enrich the declared set of methods.
|
391
|
+
* The method can either be called with multiple names (strings) or with one array of strings.
|
392
|
+
*
|
393
|
+
* <b>Note</b>: the newly added method(s) will only be visible in {@link sap.ui.base.Interface interface}
|
394
|
+
* objects that are created <i>after</i> this method has been called.
|
395
|
+
*
|
396
|
+
* @param {string|string[]} sMethod name(s) of the new method(s)
|
397
|
+
*/
|
398
|
+
Metadata.prototype.addPublicMethods = function (sMethod /* ... */) {
|
399
|
+
var aNames = sMethod instanceof Array ? sMethod : arguments;
|
400
|
+
Array.prototype.push.apply(this._aPublicMethods, aNames);
|
401
|
+
Array.prototype.push.apply(this._aAllPublicMethods, aNames);
|
402
|
+
this._bInterfacesUnique = false;
|
173
403
|
};
|
404
|
+
|
405
|
+
/**
|
406
|
+
* @since 1.3.1
|
407
|
+
* @private
|
408
|
+
*/
|
174
409
|
Metadata.createClass = function (fnBaseClass, sClassName, oClassInfo, FNMetaImpl) {
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
oClassInfo = oClassInfo
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
fnClass.prototype.constructor = fnClass;
|
211
|
-
oClassInfo.metadata.baseType = fnBaseClass;
|
212
|
-
} else {
|
213
|
-
fnClass = fnClass || function () {
|
410
|
+
if (typeof fnBaseClass === "string") {
|
411
|
+
FNMetaImpl = oClassInfo;
|
412
|
+
oClassInfo = sClassName;
|
413
|
+
sClassName = fnBaseClass;
|
414
|
+
fnBaseClass = null;
|
415
|
+
}
|
416
|
+
assert(!fnBaseClass || isFunction(fnBaseClass));
|
417
|
+
assert(typeof sClassName === "string" && !!sClassName);
|
418
|
+
assert(!oClassInfo || typeof oClassInfo === "object");
|
419
|
+
assert(!FNMetaImpl || isFunction(FNMetaImpl));
|
420
|
+
|
421
|
+
// allow metadata class to preprocess
|
422
|
+
FNMetaImpl = FNMetaImpl || Metadata;
|
423
|
+
if (isFunction(FNMetaImpl.preprocessClassInfo)) {
|
424
|
+
oClassInfo = FNMetaImpl.preprocessClassInfo(oClassInfo);
|
425
|
+
}
|
426
|
+
|
427
|
+
// normalize oClassInfo
|
428
|
+
oClassInfo = oClassInfo || {};
|
429
|
+
oClassInfo.metadata = oClassInfo.metadata || {};
|
430
|
+
if (!oClassInfo.hasOwnProperty('constructor')) {
|
431
|
+
oClassInfo.constructor = undefined;
|
432
|
+
}
|
433
|
+
var fnClass = oClassInfo.constructor;
|
434
|
+
assert(!fnClass || isFunction(fnClass));
|
435
|
+
|
436
|
+
// ensure defaults
|
437
|
+
if (fnBaseClass) {
|
438
|
+
// default constructor just delegates to base class
|
439
|
+
if (!fnClass) {
|
440
|
+
if (oClassInfo.metadata.deprecated) {
|
441
|
+
// create default factory with deprecation warning
|
442
|
+
fnClass = function () {
|
443
|
+
Log.warning("Usage of deprecated class: " + sClassName);
|
444
|
+
fnBaseClass.apply(this, arguments);
|
214
445
|
};
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
var oMetadata = new FNMetaImpl(sClassName, oClassInfo);
|
220
|
-
fnClass.getMetadata = fnClass.prototype.getMetadata = function () {
|
221
|
-
return oMetadata;
|
222
|
-
};
|
223
|
-
if (!fnClass.getMetadata().isFinal()) {
|
224
|
-
fnClass.extend = function (sSCName, oSCClassInfo, fnSCMetaImpl) {
|
225
|
-
return Metadata.createClass(fnClass, sSCName, oSCClassInfo, fnSCMetaImpl || FNMetaImpl);
|
446
|
+
} else {
|
447
|
+
// create default factory
|
448
|
+
fnClass = function () {
|
449
|
+
fnBaseClass.apply(this, arguments);
|
226
450
|
};
|
451
|
+
}
|
227
452
|
}
|
228
|
-
|
453
|
+
// create prototype chain
|
454
|
+
fnClass.prototype = Object.create(fnBaseClass.prototype);
|
455
|
+
fnClass.prototype.constructor = fnClass;
|
456
|
+
// enforce correct baseType
|
457
|
+
oClassInfo.metadata.baseType = fnBaseClass;
|
458
|
+
} else {
|
459
|
+
// default constructor does nothing
|
460
|
+
fnClass = fnClass || function () {};
|
461
|
+
// enforce correct baseType
|
462
|
+
delete oClassInfo.metadata.baseType;
|
463
|
+
}
|
464
|
+
oClassInfo.constructor = fnClass;
|
465
|
+
|
466
|
+
// make the class visible as JS Object
|
467
|
+
ObjectPath.set(sClassName, fnClass);
|
468
|
+
|
469
|
+
// add metadata
|
470
|
+
var oMetadata = new FNMetaImpl(sClassName, oClassInfo);
|
471
|
+
fnClass.getMetadata = fnClass.prototype.getMetadata = function () {
|
472
|
+
return oMetadata;
|
473
|
+
};
|
474
|
+
|
475
|
+
// enrich function
|
476
|
+
if (!fnClass.getMetadata().isFinal()) {
|
477
|
+
fnClass.extend = function (sSCName, oSCClassInfo, fnSCMetaImpl) {
|
478
|
+
return Metadata.createClass(fnClass, sSCName, oSCClassInfo, fnSCMetaImpl || FNMetaImpl);
|
479
|
+
};
|
480
|
+
}
|
481
|
+
return fnClass;
|
229
482
|
};
|
230
483
|
export default Metadata;
|