Revision: 8524
Author: [email protected]
Date: Thu Aug 12 04:59:39 2010
Log: Rollingback r8521: Lazily generate LocaleInfoImpl (rebase from
superdevmode) since htmlunit is failing.
http://code.google.com/p/google-web-toolkit/source/detail?r=8524
Modified:
/trunk/user/src/com/google/gwt/i18n/client/LocaleInfo.java
=======================================
--- /trunk/user/src/com/google/gwt/i18n/client/LocaleInfo.java Wed Aug 11
12:24:47 2010
+++ /trunk/user/src/com/google/gwt/i18n/client/LocaleInfo.java Thu Aug 12
04:59:39 2010
@@ -33,7 +33,9 @@
* is a static. In the future, we would need a hash map from locale
names
* to LocaleInfo instances.
*/
- private static LocaleInfo instance = new LocaleInfo();
+ private static LocaleInfo instance = new LocaleInfo(
+ (LocaleInfoImpl) GWT.create(LocaleInfoImpl.class),
+ (CldrImpl) GWT.create(CldrImpl.class));
/**
* @return an array of available locale names
@@ -50,7 +52,7 @@
* you might want to get the list of available locales in order to
create
* instances of each of them.
*/
- return LocaleInfoImplHolder.infoImpl.getAvailableLocaleNames();
+ return instance.infoImpl.getAvailableLocaleNames();
}
/**
@@ -82,23 +84,19 @@
/*
* See the comment from getAvailableLocaleNames() above.
*/
- return
LocaleInfoImplHolder.infoImpl.getLocaleNativeDisplayName(localeName);
- }
-
- private static class LocaleInfoImplHolder {
- static final LocaleInfoImpl infoImpl =
GWT.create(LocaleInfoImpl.class);
- }
-
- private static class CldrImplHolder {
- static final CldrImpl cldrImpl = GWT.create(CldrImpl.class);
- }
+ return instance.infoImpl.getLocaleNativeDisplayName(localeName);
+ }
/**
* @return true if any locale supported by this build of the app is RTL.
*/
public static boolean hasAnyRTL() {
- return LocaleInfoImplHolder.infoImpl.hasAnyRTL();
- }
+ return instance.infoImpl.hasAnyRTL();
+ }
+
+ private final LocaleInfoImpl infoImpl;
+
+ private final CldrImpl cldrImpl;
private DateTimeConstants dateTimeConstants;
@@ -111,6 +109,19 @@
* Any such subclass should override all methods.
*/
protected LocaleInfo() {
+ infoImpl = null;
+ cldrImpl = null;
+ }
+
+ /**
+ * Create a LocaleInfo instance, passing in the implementation classes.
+ *
+ * @param impl LocaleInfoImpl instance to use
+ * @param cldr CldrImpl instance to use
+ */
+ private LocaleInfo(LocaleInfoImpl impl, CldrImpl cldr) {
+ this.infoImpl = impl;
+ this.cldrImpl = cldr;
}
/**
@@ -133,7 +144,7 @@
* @return the name of this locale, such as "default, "en_US", etc
*/
public final String getLocaleName() {
- return LocaleInfoImplHolder.infoImpl.getLocaleName();
+ return infoImpl.getLocaleName();
}
/**
@@ -148,7 +159,7 @@
* @return true if this locale is right-to-left instead of left-to-right
*/
public final boolean isRTL() {
- return CldrImplHolder.cldrImpl.isRTL();
+ return cldrImpl.isRTL();
}
private void ensureDateTimeConstants() {
@@ -160,13 +171,13 @@
private void ensureDateTimeFormatInfo() {
if (dateTimeFormatInfo == null) {
- dateTimeFormatInfo =
LocaleInfoImplHolder.infoImpl.getDateTimeFormatInfo();
+ dateTimeFormatInfo = infoImpl.getDateTimeFormatInfo();
}
}
private void ensureNumberConstants() {
if (numberConstants == null) {
- numberConstants = LocaleInfoImplHolder.infoImpl.getNumberConstants();
+ numberConstants = infoImpl.getNumberConstants();
}
}
}
--
http://groups.google.com/group/Google-Web-Toolkit-Contributors