JAL-1807 update
[jalviewjs.git] / site / j2s / java / util / ResourceBundle.js
1 Clazz.declarePackage ("java.util");
2 Clazz.load (["java.util.Arrays", "$.Collections", "$.HashMap"], "java.util.ResourceBundle", ["java.io.BufferedInputStream", "$.ByteArrayInputStream", "java.lang.ClassNotFoundException", "$.IllegalArgumentException", "$.InternalError", "$.InterruptedException", "$.NullPointerException", "$.StringBuilder", "$.Thread", "java.util.ArrayList", "$.HashSet", "java.util.Locale", "$.MissingResourceException", "swingjs.JSToolkit", "swingjs.api.Interface"], function () {
3 c$ = Clazz.decorateAsClass (function () {
4 this.parent = null;
5 this.locale = null;
6 this.expired = false;
7 this.$keySet = null;
8 Clazz.instantialize (this, arguments);
9 }, java.util, "ResourceBundle");
10 Clazz.makeConstructor (c$, 
11 function () {
12 });
13 Clazz.defineMethod (c$, "getString", 
14 function (key) {
15 return this.getObject (key);
16 }, "~S");
17 Clazz.defineMethod (c$, "getStringArray", 
18 function (key) {
19 return this.getObject (key);
20 }, "~S");
21 Clazz.defineMethod (c$, "getObject", 
22 function (key) {
23 var obj = this.handleGetObject (key);
24 if (obj == null) {
25 if (this.parent != null) {
26 obj = this.parent.getObject (key);
27 }if (obj == null) throw  new java.util.MissingResourceException ("Can't find resource for bundle " + this.getClass ().getName () + ", key " + key, this.getClass ().getName (), key);
28 }return obj;
29 }, "~S");
30 Clazz.defineMethod (c$, "getLocale", 
31 function () {
32 return this.locale;
33 });
34 Clazz.defineMethod (c$, "setParent", 
35 function (parent) {
36 this.parent = parent;
37 }, "java.util.ResourceBundle");
38 c$.getBundle = Clazz.defineMethod (c$, "getBundle", 
39 function (baseName, targetLocale, loader, control) {
40 var n = 4;
41 {
42 n = arguments.length;
43 }switch (n) {
44 case 2:
45 if ((Clazz.instanceOf (targetLocale, java.util.ResourceBundle.Control))) {
46 control = targetLocale;
47 targetLocale = null;
48 }break;
49 case 3:
50 if ((Clazz.instanceOf (loader, java.util.ResourceBundle.Control))) {
51 control = loader;
52 loader = null;
53 }break;
54 }
55 if (targetLocale == null) targetLocale = java.util.Locale.getDefault ();
56 if (control == null) control = java.util.ResourceBundle.Control.getControl (java.util.ResourceBundle.Control.FORMAT_PROPERTIES);
57 return java.util.ResourceBundle.getBundleImpl (baseName, targetLocale, loader, control);
58 }, "~S,~O,~O,java.util.ResourceBundle.Control");
59 c$.getBundleImpl = Clazz.defineMethod (c$, "getBundleImpl", 
60  function (baseName, locale, loader, control) {
61 if (control == null) {
62 throw  new NullPointerException ("ResourceBundle locale or control is null");
63 }var cacheKey =  new java.util.ResourceBundle.CacheKey (baseName, locale, loader);
64 var bundle = null;
65 var bundleRef = java.util.ResourceBundle.cacheList.get (cacheKey);
66 if (bundleRef != null) {
67 bundle = bundleRef;
68 bundleRef = null;
69 }if (java.util.ResourceBundle.isValidBundle (bundle)) {
70 return bundle;
71 }var formats = control.getFormats (baseName);
72 var baseBundle = null;
73 for (var targetLocale = locale; targetLocale != null; targetLocale = control.getFallbackLocale (baseName, targetLocale)) {
74 var candidateLocales = control.getCandidateLocales (baseName, targetLocale);
75 bundle = java.util.ResourceBundle.findBundle (cacheKey, candidateLocales, formats, 0, control, baseBundle);
76 if (java.util.ResourceBundle.isValidBundle (bundle)) {
77 var isBaseBundle = java.util.Locale.ROOT.equals (bundle.locale);
78 if (!isBaseBundle || bundle.locale.equals (locale) || (candidateLocales.size () == 1 && bundle.locale.equals (candidateLocales.get (0)))) {
79 break;
80 }if (isBaseBundle && baseBundle == null) {
81 baseBundle = bundle;
82 }}}
83 if (bundle == null) {
84 if (baseBundle == null) {
85 java.util.ResourceBundle.throwMissingResourceException (baseName, locale, cacheKey.getCause ());
86 }bundle = baseBundle;
87 }return bundle;
88 }, "~S,java.util.Locale,~O,java.util.ResourceBundle.Control");
89 c$.findBundle = Clazz.defineMethod (c$, "findBundle", 
90  function (cacheKey, candidateLocales, formats, index, control, baseBundle) {
91 var targetLocale = candidateLocales.get (index);
92 var parent = null;
93 if (index != candidateLocales.size () - 1) {
94 parent = java.util.ResourceBundle.findBundle (cacheKey, candidateLocales, formats, index + 1, control, baseBundle);
95 } else if (baseBundle != null && java.util.Locale.ROOT.equals (targetLocale)) {
96 return baseBundle;
97 }var expiredBundle = false;
98 cacheKey.setLocale (targetLocale);
99 var bundle = java.util.ResourceBundle.findBundleInCache (cacheKey, control);
100 if (java.util.ResourceBundle.isValidBundle (bundle)) {
101 expiredBundle = bundle.expired;
102 if (!expiredBundle) {
103 if (bundle.parent === parent) {
104 return bundle;
105 }var bundleRef = java.util.ResourceBundle.cacheList.get (cacheKey);
106 if (bundleRef != null && bundleRef === bundle) {
107 java.util.ResourceBundle.cacheList.remove (cacheKey);
108 }}}if (bundle !== java.util.ResourceBundle.NONEXISTENT_BUNDLE) {
109 var constKey = cacheKey.clone ();
110 try {
111 try {
112 bundle = java.util.ResourceBundle.loadBundle (cacheKey, formats, control, expiredBundle);
113 if (bundle != null) {
114 if (bundle.parent == null) {
115 bundle.setParent (parent);
116 }bundle.locale = targetLocale;
117 bundle = java.util.ResourceBundle.putBundleInCache (cacheKey, bundle, control);
118 return bundle;
119 }java.util.ResourceBundle.putBundleInCache (cacheKey, java.util.ResourceBundle.NONEXISTENT_BUNDLE, control);
120 } finally {
121 }
122 } finally {
123 if (Clazz.instanceOf (constKey.getCause (), InterruptedException)) {
124 Thread.currentThread ().interrupt ();
125 }}
126 }return parent;
127 }, "java.util.ResourceBundle.CacheKey,java.util.List,java.util.List,~N,java.util.ResourceBundle.Control,java.util.ResourceBundle");
128 c$.loadBundle = Clazz.defineMethod (c$, "loadBundle", 
129  function (cacheKey, formats, control, reload) {
130 var targetLocale = cacheKey.getLocale ();
131 var bundle = null;
132 var size = formats.size ();
133 for (var i = 0; i < size; i++) {
134 var format = formats.get (i);
135 try {
136 bundle = control.newBundle (cacheKey.getName (), targetLocale, format, null, reload);
137 } catch (e$$) {
138 if (Clazz.exceptionOf (e$$, LinkageError)) {
139 var error = e$$;
140 {
141 cacheKey.setCause (error);
142 }
143 } else if (Clazz.exceptionOf (e$$, Exception)) {
144 var cause = e$$;
145 {
146 cacheKey.setCause (cause);
147 }
148 } else {
149 throw e$$;
150 }
151 }
152 if (bundle != null) {
153 cacheKey.setFormat (format);
154 bundle.locale = targetLocale;
155 bundle.expired = false;
156 break;
157 }}
158 return bundle;
159 }, "java.util.ResourceBundle.CacheKey,java.util.List,java.util.ResourceBundle.Control,~B");
160 c$.isValidBundle = Clazz.defineMethod (c$, "isValidBundle", 
161  function (bundle) {
162 return bundle != null && bundle !== java.util.ResourceBundle.NONEXISTENT_BUNDLE;
163 }, "java.util.ResourceBundle");
164 c$.throwMissingResourceException = Clazz.defineMethod (c$, "throwMissingResourceException", 
165  function (baseName, locale, cause) {
166 if (Clazz.instanceOf (cause, java.util.MissingResourceException)) {
167 cause = null;
168 }throw  new java.util.MissingResourceException ("Can't find bundle for base name " + baseName + ", locale " + locale, baseName + "_" + locale, "", cause);
169 }, "~S,java.util.Locale,Throwable");
170 c$.findBundleInCache = Clazz.defineMethod (c$, "findBundleInCache", 
171  function (cacheKey, control) {
172 var bundleRef = java.util.ResourceBundle.cacheList.get (cacheKey);
173 if (bundleRef == null) {
174 return null;
175 }var bundle = bundleRef;
176 return bundle;
177 }, "java.util.ResourceBundle.CacheKey,java.util.ResourceBundle.Control");
178 c$.putBundleInCache = Clazz.defineMethod (c$, "putBundleInCache", 
179  function (cacheKey, bundle, control) {
180 var key = cacheKey.clone ();
181 java.util.ResourceBundle.cacheList.put (key, bundle);
182 return bundle;
183 }, "java.util.ResourceBundle.CacheKey,java.util.ResourceBundle,java.util.ResourceBundle.Control");
184 c$.clearCache = Clazz.defineMethod (c$, "clearCache", 
185 function () {
186 java.util.ResourceBundle.cacheList.clear ();
187 });
188 Clazz.defineMethod (c$, "containsKey", 
189 function (key) {
190 if (key == null) {
191 throw  new NullPointerException ();
192 }for (var rb = this; rb != null; rb = rb.parent) {
193 if (rb.handleKeySet ().contains (key)) {
194 return true;
195 }}
196 return false;
197 }, "~S");
198 Clazz.defineMethod (c$, "keySet", 
199 function () {
200 var keys =  new java.util.HashSet ();
201 for (var rb = this; rb != null; rb = rb.parent) {
202 keys.addAll (rb.handleKeySet ());
203 }
204 return keys;
205 });
206 Clazz.defineMethod (c$, "handleKeySet", 
207 function () {
208 if (this.$keySet == null) {
209 {
210 if (this.$keySet == null) {
211 var keys =  new java.util.HashSet ();
212 var enumKeys = this.getKeys ();
213 while (enumKeys.hasMoreElements ()) {
214 var key = enumKeys.nextElement ();
215 if (this.handleGetObject (key) != null) {
216 keys.add (key);
217 }}
218 this.$keySet = keys;
219 }}}return this.$keySet;
220 });
221 c$.$ResourceBundle$1$ = function () {
222 Clazz.pu$h(self.c$);
223 c$ = Clazz.declareAnonymous (java.util, "ResourceBundle$1", java.util.ResourceBundle);
224 Clazz.defineMethod (c$, "getKeys", 
225 function () {
226 return null;
227 });
228 Clazz.defineMethod (c$, "handleGetObject", 
229 function (key) {
230 return null;
231 }, "~S");
232 Clazz.overrideMethod (c$, "toString", 
233 function () {
234 return "NONEXISTENT_BUNDLE";
235 });
236 c$ = Clazz.p0p ();
237 };
238 Clazz.pu$h(self.c$);
239 c$ = Clazz.decorateAsClass (function () {
240 this.name = null;
241 this.locale = null;
242 this.format = null;
243 this.cause = null;
244 this.hashCodeCache = 0;
245 Clazz.instantialize (this, arguments);
246 }, java.util.ResourceBundle, "CacheKey", null, Cloneable);
247 Clazz.makeConstructor (c$, 
248 function (a, b, c) {
249 this.name = a;
250 this.locale = b;
251 if (this.name != null) this.calculateHashCode ();
252 }, "~S,java.util.Locale,~O");
253 Clazz.defineMethod (c$, "getName", 
254 function () {
255 return this.name;
256 });
257 Clazz.defineMethod (c$, "getLocale", 
258 function () {
259 return this.locale;
260 });
261 Clazz.defineMethod (c$, "setLocale", 
262 function (a) {
263 if (!this.locale.equals (a)) {
264 this.locale = a;
265 this.calculateHashCode ();
266 }return this;
267 }, "java.util.Locale");
268 Clazz.overrideMethod (c$, "equals", 
269 function (a) {
270 if (this === a) {
271 return true;
272 }try {
273 var b = a;
274 if (this.hashCodeCache != b.hashCodeCache) {
275 return false;
276 }if (!this.name.equals (b.name)) {
277 return false;
278 }if (!this.locale.equals (b.locale)) {
279 return false;
280 }return true;
281 } catch (e$$) {
282 if (Clazz.exceptionOf (e$$, NullPointerException)) {
283 var e = e$$;
284 {
285 }
286 } else if (Clazz.exceptionOf (e$$, ClassCastException)) {
287 var e = e$$;
288 {
289 }
290 } else {
291 throw e$$;
292 }
293 }
294 return false;
295 }, "~O");
296 Clazz.overrideMethod (c$, "hashCode", 
297 function () {
298 return this.hashCodeCache;
299 });
300 Clazz.defineMethod (c$, "calculateHashCode", 
301  function () {
302 this.hashCodeCache = this.name.hashCode () << 3;
303 this.hashCodeCache ^= this.locale.hashCode ();
304 });
305 Clazz.defineMethod (c$, "clone", 
306 function () {
307 try {
308 var a = Clazz.superCall (this, java.util.ResourceBundle.CacheKey, "clone", []);
309 a.cause = null;
310 return a;
311 } catch (e) {
312 if (Clazz.exceptionOf (e, CloneNotSupportedException)) {
313 throw  new InternalError ();
314 } else {
315 throw e;
316 }
317 }
318 });
319 Clazz.defineMethod (c$, "setFormat", 
320 function (a) {
321 this.format = a;
322 }, "~S");
323 Clazz.defineMethod (c$, "setCause", 
324  function (a) {
325 if (this.cause == null) {
326 this.cause = a;
327 } else {
328 if (Clazz.instanceOf (this.cause, ClassNotFoundException)) {
329 this.cause = a;
330 }}}, "Throwable");
331 Clazz.defineMethod (c$, "getCause", 
332  function () {
333 return this.cause;
334 });
335 Clazz.overrideMethod (c$, "toString", 
336 function () {
337 var a = this.locale.toString ();
338 if (a.length == 0) {
339 if (this.locale.getVariant ().length != 0) {
340 a = "__" + this.locale.getVariant ();
341 } else {
342 a = "\"\"";
343 }}return "CacheKey[" + this.name + ", lc=" + a + "(format=" + this.format + ")]";
344 });
345 c$ = Clazz.p0p ();
346 Clazz.pu$h(self.c$);
347 c$ = Clazz.declareType (java.util.ResourceBundle, "Control");
348 Clazz.makeConstructor (c$, 
349 function () {
350 });
351 c$.getControl = Clazz.defineMethod (c$, "getControl", 
352 function (a) {
353 if (a.equals (java.util.ResourceBundle.Control.FORMAT_PROPERTIES)) {
354 return java.util.ResourceBundle.SingleFormatControl.PROPERTIES_ONLY;
355 }if (a.equals (java.util.ResourceBundle.Control.FORMAT_CLASS)) {
356 return java.util.ResourceBundle.SingleFormatControl.CLASS_ONLY;
357 }if (a.equals (java.util.ResourceBundle.Control.FORMAT_DEFAULT)) {
358 return java.util.ResourceBundle.Control.INSTANCE;
359 }throw  new IllegalArgumentException ();
360 }, "java.util.List");
361 c$.getNoFallbackControl = Clazz.defineMethod (c$, "getNoFallbackControl", 
362 function (a) {
363 if (a.equals (java.util.ResourceBundle.Control.FORMAT_DEFAULT)) {
364 return java.util.ResourceBundle.NoFallbackControl.NO_FALLBACK;
365 }if (a.equals (java.util.ResourceBundle.Control.FORMAT_PROPERTIES)) {
366 return java.util.ResourceBundle.NoFallbackControl.PROPERTIES_ONLY_NO_FALLBACK;
367 }if (a.equals (java.util.ResourceBundle.Control.FORMAT_CLASS)) {
368 return java.util.ResourceBundle.NoFallbackControl.CLASS_ONLY_NO_FALLBACK;
369 }throw  new IllegalArgumentException ();
370 }, "java.util.List");
371 Clazz.defineMethod (c$, "getFormats", 
372 function (a) {
373 if (a == null) {
374 throw  new NullPointerException ();
375 }return java.util.ResourceBundle.Control.FORMAT_DEFAULT;
376 }, "~S");
377 Clazz.defineMethod (c$, "getCandidateLocales", 
378 function (a, b) {
379 if (a == null) {
380 throw  new NullPointerException ();
381 }var c = b.getLanguage ();
382 var d = b.getCountry ();
383 var e = b.getVariant ();
384 var f =  new java.util.ArrayList (4);
385 if (e.length > 0) {
386 f.add (b);
387 }if (d.length > 0) {
388 f.add ((f.size () == 0) ? b : java.util.Locale.getInstance (c, d, ""));
389 }if (c.length > 0) {
390 f.add ((f.size () == 0) ? b : java.util.Locale.getInstance (c, "", ""));
391 }f.add (java.util.Locale.ROOT);
392 return f;
393 }, "~S,java.util.Locale");
394 Clazz.defineMethod (c$, "getFallbackLocale", 
395 function (a, b) {
396 if (a == null) {
397 throw  new NullPointerException ();
398 }var c = java.util.Locale.getDefault ();
399 return b.equals (c) ? null : c;
400 }, "~S,java.util.Locale");
401 Clazz.defineMethod (c$, "newBundle", 
402 function (a, b, c, d, e) {
403 var f = this.toBundleName (a, b);
404 var g = null;
405 if (c.equals ("java.class")) {
406 g = swingjs.api.Interface.getInstance (f, false);
407 } else if (c.equals ("java.properties")) {
408 var h = this.toResourceName0 (f, "properties");
409 if (h == null) {
410 return null;
411 }var i = swingjs.JSToolkit.getJavaResource (h, false);
412 var j = null;
413 j = (i == null ? null :  new java.io.BufferedInputStream ( new java.io.ByteArrayInputStream (i.getBytes ())));
414 if (j != null) {
415 try {
416 g = this.newPropertyBundle (j);
417 } finally {
418 j.close ();
419 }
420 }} else {
421 throw  new IllegalArgumentException ("unknown format: " + c);
422 }return g;
423 }, "~S,java.util.Locale,~S,~O,~B");
424 Clazz.defineMethod (c$, "newPropertyBundle", 
425  function (a) {
426 return (swingjs.api.Interface.getInstance ("java.util.PropertyResourceBundle", false)).setStream (a);
427 }, "java.io.InputStream");
428 Clazz.defineMethod (c$, "getTimeToLive", 
429 function (a, b) {
430 if (a == null || b == null) {
431 throw  new NullPointerException ();
432 }return -2;
433 }, "~S,java.util.Locale");
434 Clazz.defineMethod (c$, "toBundleName", 
435 function (a, b) {
436 if (b === java.util.Locale.ROOT) {
437 return a;
438 }var c = b.getLanguage ();
439 var d = b.getCountry ();
440 var e = b.getVariant ();
441 if (c === "" && d === "" && e === "") {
442 return a;
443 }var f =  new StringBuilder (a);
444 f.append ('_');
445 if (e !== "") {
446 f.append (c).append ('_').append (d).append ('_').append (e);
447 } else if (d !== "") {
448 f.append (c).append ('_').append (d);
449 } else {
450 f.append (c);
451 }return f.toString ();
452 }, "~S,java.util.Locale");
453 Clazz.defineMethod (c$, "toResourceName", 
454 function (a, b) {
455 var c =  new StringBuilder (a.length + 1 + b.length);
456 c.append (a.$replace ('.', '/')).append ('.').append (b);
457 return c.toString ();
458 }, "~S,~S");
459 Clazz.defineMethod (c$, "toResourceName0", 
460  function (a, b) {
461 if (a.contains ("://")) {
462 return null;
463 } else {
464 return this.toResourceName (a, b);
465 }}, "~S,~S");
466 c$.FORMAT_DEFAULT = c$.prototype.FORMAT_DEFAULT = java.util.Collections.unmodifiableList (java.util.Arrays.asList (["java.class", "java.properties"]));
467 c$.FORMAT_CLASS = c$.prototype.FORMAT_CLASS = java.util.Collections.unmodifiableList (java.util.Arrays.asList (["java.class"]));
468 c$.FORMAT_PROPERTIES = c$.prototype.FORMAT_PROPERTIES = java.util.Collections.unmodifiableList (java.util.Arrays.asList (["java.properties"]));
469 Clazz.defineStatics (c$,
470 "TTL_DONT_CACHE", -1,
471 "TTL_NO_EXPIRATION_CONTROL", -2);
472 c$.INSTANCE = c$.prototype.INSTANCE =  new java.util.ResourceBundle.Control ();
473 c$ = Clazz.p0p ();
474 Clazz.pu$h(self.c$);
475 c$ = Clazz.decorateAsClass (function () {
476 this.formats = null;
477 Clazz.instantialize (this, arguments);
478 }, java.util.ResourceBundle, "SingleFormatControl", java.util.ResourceBundle.Control);
479 Clazz.makeConstructor (c$, 
480 function (a) {
481 Clazz.superConstructor (this, java.util.ResourceBundle.SingleFormatControl, []);
482 this.formats = a;
483 }, "java.util.List");
484 Clazz.overrideMethod (c$, "getFormats", 
485 function (a) {
486 if (a == null) {
487 throw  new NullPointerException ();
488 }return this.formats;
489 }, "~S");
490 c$.PROPERTIES_ONLY = c$.prototype.PROPERTIES_ONLY =  new java.util.ResourceBundle.SingleFormatControl (java.util.ResourceBundle.Control.FORMAT_PROPERTIES);
491 c$.CLASS_ONLY = c$.prototype.CLASS_ONLY =  new java.util.ResourceBundle.SingleFormatControl (java.util.ResourceBundle.Control.FORMAT_CLASS);
492 c$ = Clazz.p0p ();
493 Clazz.pu$h(self.c$);
494 c$ = Clazz.declareType (java.util.ResourceBundle, "NoFallbackControl", java.util.ResourceBundle.SingleFormatControl);
495 Clazz.overrideMethod (c$, "getFallbackLocale", 
496 function (a, b) {
497 if (a == null || b == null) {
498 throw  new NullPointerException ();
499 }return null;
500 }, "~S,java.util.Locale");
501 c$.NO_FALLBACK = c$.prototype.NO_FALLBACK =  new java.util.ResourceBundle.NoFallbackControl (java.util.ResourceBundle.Control.FORMAT_DEFAULT);
502 c$.PROPERTIES_ONLY_NO_FALLBACK = c$.prototype.PROPERTIES_ONLY_NO_FALLBACK =  new java.util.ResourceBundle.NoFallbackControl (java.util.ResourceBundle.Control.FORMAT_PROPERTIES);
503 c$.CLASS_ONLY_NO_FALLBACK = c$.prototype.CLASS_ONLY_NO_FALLBACK =  new java.util.ResourceBundle.NoFallbackControl (java.util.ResourceBundle.Control.FORMAT_CLASS);
504 c$ = Clazz.p0p ();
505 Clazz.defineStatics (c$,
506 "INITIAL_CACHE_SIZE", 32);
507 c$.NONEXISTENT_BUNDLE = c$.prototype.NONEXISTENT_BUNDLE = ((Clazz.isClassDefined ("java.util.ResourceBundle$1") ? 0 : java.util.ResourceBundle.$ResourceBundle$1$ ()), Clazz.innerTypeInstance (java.util.ResourceBundle$1, this, null));
508 c$.cacheList = c$.prototype.cacheList =  new java.util.HashMap (32);
509 });