1 Clazz.declarePackage ("java.util");
2 Clazz.load (["java.util.HashMap"], "java.util.Locale", ["java.lang.InternalError", "$.NullPointerException", "$.StringBuilder"], function () {
3 c$ = Clazz.decorateAsClass (function () {
7 this.hashCodeValue = 0;
8 Clazz.instantialize (this, arguments);
9 }, java.util, "Locale", null, [Cloneable, java.io.Serializable]);
10 Clazz.makeConstructor (c$,
11 function (language, country, variant) {
12 this.language = language.intern ();
13 this.country = country.intern ();
14 this.variant = variant.intern ();
16 Clazz.makeConstructor (c$,
17 function (language, country) {
18 this.construct (language, country, "");
20 Clazz.makeConstructor (c$,
22 this.construct (language, "", "");
24 Clazz.makeConstructor (c$,
25 function (language, country, flag) {
26 this.language = language;
27 this.country = country;
30 c$.createSingleton = Clazz.defineMethod (c$, "createSingleton",
31 function (key, language, country) {
32 var locale = new java.util.Locale (language, country, false);
33 java.util.Locale.cache.put (key, locale);
36 c$.getInstance = Clazz.defineMethod (c$, "getInstance",
37 function (language, country, variant) {
38 if (language == null || country == null || variant == null) {
39 throw new NullPointerException ();
40 }var sb = new StringBuilder ();
41 sb.append (language).append ('_').append (country).append ('_').append (variant);
42 var key = sb.toString ();
43 var locale = java.util.Locale.cache.get (key);
45 locale = new java.util.Locale (language, country, variant);
46 var l = java.util.Locale.cache.put (key, locale);
51 c$.getDefault = Clazz.defineMethod (c$, "getDefault",
53 if (java.util.Locale.defaultLocale == null) {
60 java.util.Locale.defaultLocale = java.util.Locale.getInstance (language, country, variant);
61 }return java.util.Locale.defaultLocale;
63 c$.setDefault = Clazz.defineMethod (c$, "setDefault",
64 function (newLocale) {
65 if (newLocale == null) throw new NullPointerException ("Can't set default locale to NULL");
66 java.util.Locale.defaultLocale = newLocale;
67 }, "java.util.Locale");
68 Clazz.defineMethod (c$, "getLanguage",
72 Clazz.defineMethod (c$, "getCountry",
76 Clazz.defineMethod (c$, "getVariant",
80 Clazz.overrideMethod (c$, "toString",
82 var l = this.language.length != 0;
83 var c = this.country.length != 0;
84 var v = this.variant.length != 0;
85 var result = new StringBuilder (this.language);
87 result.append ('_').append (this.country);
89 result.append ('_').append (this.variant);
90 }return result.toString ();
92 Clazz.defineMethod (c$, "getDisplayLanguage",
94 return this.getDisplayLanguage (java.util.Locale.getDefault ());
96 Clazz.defineMethod (c$, "getDisplayLanguage",
98 return this.getDisplayString (this.language, inLocale, 0);
99 }, "java.util.Locale");
100 Clazz.defineMethod (c$, "getDisplayCountry",
102 return this.getDisplayCountry (java.util.Locale.getDefault ());
104 Clazz.defineMethod (c$, "getDisplayCountry",
105 function (inLocale) {
106 return this.getDisplayString (this.country, inLocale, 1);
107 }, "java.util.Locale");
108 Clazz.defineMethod (c$, "getDisplayString",
109 function (code, inLocale, type) {
110 if (code.length == 0) {
112 }if (inLocale == null) {
113 throw new NullPointerException ();
114 }return inLocale.toString ();
115 }, "~S,java.util.Locale,~N");
116 Clazz.defineMethod (c$, "getDisplayVariant",
118 return this.getDisplayVariant (java.util.Locale.getDefault ());
120 Clazz.defineMethod (c$, "getDisplayVariant",
121 function (inLocale) {
122 if (this.variant.length == 0) return "";
124 }, "java.util.Locale");
125 Clazz.defineMethod (c$, "getDisplayName",
127 return this.getDisplayName (java.util.Locale.getDefault ());
129 Clazz.defineMethod (c$, "getDisplayName",
130 function (inLocale) {
131 return inLocale.toString ();
132 }, "java.util.Locale");
133 Clazz.defineMethod (c$, "clone",
136 var that = Clazz.superCall (this, java.util.Locale, "clone", []);
139 if (Clazz.exceptionOf (e, CloneNotSupportedException)) {
140 throw new InternalError ();
146 Clazz.overrideMethod (c$, "hashCode",
148 var hc = this.hashCodeValue;
150 hc = (this.language.hashCode () << 8) ^ this.country.hashCode () ^ (this.variant.hashCode () << 4);
151 this.hashCodeValue = hc;
154 Clazz.overrideMethod (c$, "equals",
156 if (this === obj) return true;
157 if (!(Clazz.instanceOf (obj, java.util.Locale))) return false;
159 return this.language === other.language && this.country === other.country && this.variant === other.variant;
161 c$.cache = c$.prototype.cache = new java.util.HashMap (32);
162 c$.ENGLISH = c$.prototype.ENGLISH = java.util.Locale.createSingleton ("en__", "en", "");
163 c$.ROOT = c$.prototype.ROOT = java.util.Locale.createSingleton ("__", "", "");
164 Clazz.defineStatics (c$,
165 "DISPLAY_LANGUAGE", 0,
166 "DISPLAY_COUNTRY", 1,
167 "defaultLocale", null);