Fix for issue 4111 (comma-decimal-separator bug).
Review: http://gwt-code-reviews.appspot.com/77802
git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@6317 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/user/src/com/google/gwt/uibinder/rebind/UiBinderWriter.java b/user/src/com/google/gwt/uibinder/rebind/UiBinderWriter.java
index 4b3c54a..9726c2b 100644
--- a/user/src/com/google/gwt/uibinder/rebind/UiBinderWriter.java
+++ b/user/src/com/google/gwt/uibinder/rebind/UiBinderWriter.java
@@ -51,6 +51,7 @@
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
+import java.util.Locale;
import java.util.Map;
import javax.xml.parsers.DocumentBuilder;
@@ -298,7 +299,7 @@
* style of {@link String#format}
*/
public void addInitStatement(String format, Object... params) {
- initStatements.add(String.format(format, params));
+ initStatements.add(formatCode(format, params));
}
/**
@@ -306,7 +307,7 @@
* of {@link String#format}
*/
public void addStatement(String format, Object... args) {
- statements.add(String.format(format, args));
+ statements.add(formatCode(format, args));
}
/**
@@ -687,7 +688,7 @@
*/
public void setFieldInitializerAsConstructor(String fieldName,
JClassType type, String... args) {
- setFieldInitializer(fieldName, String.format("new %s(%s)",
+ setFieldInitializer(fieldName, formatCode("new %s(%s)",
type.getQualifiedSourceName(), asCommaSeparatedList(args)));
}
@@ -858,6 +859,15 @@
}
/**
+ * Use this method to format code. It forces the use of the en-US locale,
+ * so that things like decimal format don't get mangled.
+ */
+ private String formatCode(String format, Object... params) {
+ String r = String.format(Locale.US, format, params);
+ return r;
+ }
+
+ /**
* Inspects this element for a gwt:field attribute. If one is found, the
* attribute is consumed and its value returned.
*
@@ -1197,7 +1207,7 @@
// (would that be a user error or a runtime error? Not sure)
if (fieldWriter != null) {
fieldManager.lookup(fieldName).setInitializerMaybe(
- String.format("owner.%1$s", fieldName));
+ formatCode("owner.%1$s", fieldName));
}
}
}
@@ -1301,5 +1311,4 @@
writeStaticMessagesInstance(w);
writeStaticBundleInstances(w);
}
-
}