Revision: 6317 Author: j...@google.com Date: Wed Oct 7 13:08:06 2009 Log: Fix for issue 4111 (comma-decimal-separator bug). Review: http://gwt-code-reviews.appspot.com/77802 http://code.google.com/p/google-web-toolkit/source/detail?r=6317
Modified: /trunk/user/src/com/google/gwt/uibinder/rebind/UiBinderWriter.java ======================================= --- /trunk/user/src/com/google/gwt/uibinder/rebind/UiBinderWriter.java Tue Oct 6 14:43:09 2009 +++ /trunk/user/src/com/google/gwt/uibinder/rebind/UiBinderWriter.java Wed Oct 7 13:08:06 2009 @@ -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))); } @@ -856,6 +857,15 @@ return elementClass; } + + /** + * 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 @@ -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); } - -} +} --~--~---------~--~----~------------~-------~--~----~ http://groups.google.com/group/Google-Web-Toolkit-Contributors -~----------~----~----~----~------~----~------~--~---