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 () {
8 Clazz.instantialize (this, arguments);
9 }, java.util, "ResourceBundle");
10 Clazz.makeConstructor (c$,
13 Clazz.defineMethod (c$, "getString",
15 return this.getObject (key);
17 Clazz.defineMethod (c$, "getStringArray",
19 return this.getObject (key);
21 Clazz.defineMethod (c$, "getObject",
23 var obj = this.handleGetObject (key);
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);
30 Clazz.defineMethod (c$, "getLocale",
34 Clazz.defineMethod (c$, "setParent",
37 }, "java.util.ResourceBundle");
38 c$.getBundle = Clazz.defineMethod (c$, "getBundle",
39 function (baseName, targetLocale, loader, control) {
45 if ((Clazz.instanceOf (targetLocale, java.util.ResourceBundle.Control))) {
46 control = targetLocale;
50 if ((Clazz.instanceOf (loader, java.util.ResourceBundle.Control))) {
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);
65 var bundleRef = java.util.ResourceBundle.cacheList.get (cacheKey);
66 if (bundleRef != null) {
69 }if (java.util.ResourceBundle.isValidBundle (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)))) {
80 }if (isBaseBundle && baseBundle == null) {
84 if (baseBundle == null) {
85 java.util.ResourceBundle.throwMissingResourceException (baseName, locale, cacheKey.getCause ());
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);
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)) {
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) {
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 ();
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);
119 }java.util.ResourceBundle.putBundleInCache (cacheKey, java.util.ResourceBundle.NONEXISTENT_BUNDLE, control);
123 if (Clazz.instanceOf (constKey.getCause (), InterruptedException)) {
124 Thread.currentThread ().interrupt ();
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 ();
132 var size = formats.size ();
133 for (var i = 0; i < size; i++) {
134 var format = formats.get (i);
136 bundle = control.newBundle (cacheKey.getName (), targetLocale, format, null, reload);
138 if (Clazz.exceptionOf (e$$, LinkageError)) {
141 cacheKey.setCause (error);
143 } else if (Clazz.exceptionOf (e$$, Exception)) {
146 cacheKey.setCause (cause);
152 if (bundle != null) {
153 cacheKey.setFormat (format);
154 bundle.locale = targetLocale;
155 bundle.expired = false;
159 }, "java.util.ResourceBundle.CacheKey,java.util.List,java.util.ResourceBundle.Control,~B");
160 c$.isValidBundle = Clazz.defineMethod (c$, "isValidBundle",
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)) {
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) {
175 }var bundle = bundleRef;
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);
183 }, "java.util.ResourceBundle.CacheKey,java.util.ResourceBundle,java.util.ResourceBundle.Control");
184 c$.clearCache = Clazz.defineMethod (c$, "clearCache",
186 java.util.ResourceBundle.cacheList.clear ();
188 Clazz.defineMethod (c$, "containsKey",
191 throw new NullPointerException ();
192 }for (var rb = this; rb != null; rb = rb.parent) {
193 if (rb.handleKeySet ().contains (key)) {
198 Clazz.defineMethod (c$, "keySet",
200 var keys = new java.util.HashSet ();
201 for (var rb = this; rb != null; rb = rb.parent) {
202 keys.addAll (rb.handleKeySet ());
206 Clazz.defineMethod (c$, "handleKeySet",
208 if (this.$keySet == null) {
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) {
219 }}}return this.$keySet;
221 c$.$ResourceBundle$1$ = function () {
223 c$ = Clazz.declareAnonymous (java.util, "ResourceBundle$1", java.util.ResourceBundle);
224 Clazz.defineMethod (c$, "getKeys",
228 Clazz.defineMethod (c$, "handleGetObject",
232 Clazz.overrideMethod (c$, "toString",
234 return "NONEXISTENT_BUNDLE";
239 c$ = Clazz.decorateAsClass (function () {
244 this.hashCodeCache = 0;
245 Clazz.instantialize (this, arguments);
246 }, java.util.ResourceBundle, "CacheKey", null, Cloneable);
247 Clazz.makeConstructor (c$,
251 if (this.name != null) this.calculateHashCode ();
252 }, "~S,java.util.Locale,~O");
253 Clazz.defineMethod (c$, "getName",
257 Clazz.defineMethod (c$, "getLocale",
261 Clazz.defineMethod (c$, "setLocale",
263 if (!this.locale.equals (a)) {
265 this.calculateHashCode ();
267 }, "java.util.Locale");
268 Clazz.overrideMethod (c$, "equals",
274 if (this.hashCodeCache != b.hashCodeCache) {
276 }if (!this.name.equals (b.name)) {
278 }if (!this.locale.equals (b.locale)) {
282 if (Clazz.exceptionOf (e$$, NullPointerException)) {
286 } else if (Clazz.exceptionOf (e$$, ClassCastException)) {
296 Clazz.overrideMethod (c$, "hashCode",
298 return this.hashCodeCache;
300 Clazz.defineMethod (c$, "calculateHashCode",
302 this.hashCodeCache = this.name.hashCode () << 3;
303 this.hashCodeCache ^= this.locale.hashCode ();
305 Clazz.defineMethod (c$, "clone",
308 var a = Clazz.superCall (this, java.util.ResourceBundle.CacheKey, "clone", []);
312 if (Clazz.exceptionOf (e, CloneNotSupportedException)) {
313 throw new InternalError ();
319 Clazz.defineMethod (c$, "setFormat",
323 Clazz.defineMethod (c$, "setCause",
325 if (this.cause == null) {
328 if (Clazz.instanceOf (this.cause, ClassNotFoundException)) {
331 Clazz.defineMethod (c$, "getCause",
335 Clazz.overrideMethod (c$, "toString",
337 var a = this.locale.toString ();
339 if (this.locale.getVariant ().length != 0) {
340 a = "__" + this.locale.getVariant ();
343 }}return "CacheKey[" + this.name + ", lc=" + a + "(format=" + this.format + ")]";
347 c$ = Clazz.declareType (java.util.ResourceBundle, "Control");
348 Clazz.makeConstructor (c$,
351 c$.getControl = Clazz.defineMethod (c$, "getControl",
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",
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",
374 throw new NullPointerException ();
375 }return java.util.ResourceBundle.Control.FORMAT_DEFAULT;
377 Clazz.defineMethod (c$, "getCandidateLocales",
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);
388 f.add ((f.size () == 0) ? b : java.util.Locale.getInstance (c, d, ""));
390 f.add ((f.size () == 0) ? b : java.util.Locale.getInstance (c, "", ""));
391 }f.add (java.util.Locale.ROOT);
393 }, "~S,java.util.Locale");
394 Clazz.defineMethod (c$, "getFallbackLocale",
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);
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");
411 }var i = swingjs.JSToolkit.getJavaResource (h);
413 j = (i == null ? null : new java.io.BufferedInputStream ( new java.io.ByteArrayInputStream (i.getBytes ())));
416 g = this.newPropertyBundle (j);
421 throw new IllegalArgumentException ("unknown format: " + c);
423 }, "~S,java.util.Locale,~S,~O,~B");
424 Clazz.defineMethod (c$, "newPropertyBundle",
426 return (swingjs.api.Interface.getInstance ("java.util.PropertyResourceBundle", false)).setStream (a);
427 }, "java.io.InputStream");
428 Clazz.defineMethod (c$, "getTimeToLive",
430 if (a == null || b == null) {
431 throw new NullPointerException ();
433 }, "~S,java.util.Locale");
434 Clazz.defineMethod (c$, "toBundleName",
436 if (b === java.util.Locale.ROOT) {
438 }var c = b.getLanguage ();
439 var d = b.getCountry ();
440 var e = b.getVariant ();
441 if (c === "" && d === "" && e === "") {
443 }var f = new StringBuilder (a);
446 f.append (c).append ('_').append (d).append ('_').append (e);
447 } else if (d !== "") {
448 f.append (c).append ('_').append (d);
451 }return f.toString ();
452 }, "~S,java.util.Locale");
453 Clazz.defineMethod (c$, "toResourceName",
455 var c = new StringBuilder (a.length + 1 + b.length);
456 c.append (a.$replace ('.', '/')).append ('.').append (b);
457 return c.toString ();
459 Clazz.defineMethod (c$, "toResourceName0",
461 if (a.contains ("://")) {
464 return this.toResourceName (a, b);
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 ();
475 c$ = Clazz.decorateAsClass (function () {
477 Clazz.instantialize (this, arguments);
478 }, java.util.ResourceBundle, "SingleFormatControl", java.util.ResourceBundle.Control);
479 Clazz.makeConstructor (c$,
481 Clazz.superConstructor (this, java.util.ResourceBundle.SingleFormatControl, []);
483 }, "java.util.List");
484 Clazz.overrideMethod (c$, "getFormats",
487 throw new NullPointerException ();
488 }return this.formats;
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);
494 c$ = Clazz.declareType (java.util.ResourceBundle, "NoFallbackControl", java.util.ResourceBundle.SingleFormatControl);
495 Clazz.overrideMethod (c$, "getFallbackLocale",
497 if (a == null || b == null) {
498 throw new NullPointerException ();
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);
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);