gwtproject / gwt

GWT Open Source Project
http://www.gwtproject.org
1.52k stars 375 forks source link

Emulate String.format #3946

Open dankurka opened 9 years ago

dankurka commented 9 years ago

Originally reported on Google Code with ID 3945

Found in GWT Release (e.g. 1.5.3, 1.6 RC):

1.6.4

Encountered on OS / Browser (e.g. WinXP, IE6-7, FF3):

Ubuntu 9.04, Firefox 3.0.13

Detailed description (please be as specific as possible):

This is a request for extending the JRE Emulation with
http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html#format(java.lang.String,%20java.lang.Object...)

Shortest code snippet which demonstrates issue (please indicate where
actual result differs from expected result):

Workaround if you have one:

Links to relevant GWT Developer Forum posts:

http://groups.google.com/group/Google-Web-Toolkit/browse_thread/thread/d18118d7fd4e8c26

Reported by zmeuldumy on 2009-08-12 15:33:00

dankurka commented 9 years ago

Reported by sumitchandel+legacy@google.com on 2009-08-13 23:42:20

dankurka commented 9 years ago

Reported by scottb+legacy@google.com on 2009-08-14 17:53:45

dankurka commented 9 years ago
also not available in 2.0 or previous.

Reported by antony.trupe on 2010-05-24 22:28:43

dankurka commented 9 years ago
Something as simple as one of the examples here would be nice...
http://stackoverflow.com/questions/1038746/equivalent-of-string-format-in-jquery

Reported by tuckerpmt on 2010-11-08 02:49:34

dankurka commented 9 years ago

Reported by rjrjr@google.com on 2011-01-13 03:09:44

dankurka commented 9 years ago
It's quite inconvenient. A simple solution like slf4j is also acceptable:
logger.info("the value of {} is {}", name, value);

Reported by warren.c.tang on 2011-10-27 11:01:20

dankurka commented 9 years ago
Pretty sure nothing is happening on this, moving to PatchesWelcome.

Reported by stephen.haberman on 2011-11-15 04:27:20

dankurka commented 9 years ago
see: https://groups.google.com/d/msg/Google-Web-Toolkit/15XXIsPI4Zc/AGm-vcBZQKUJ

Reported by dankurka@google.com on 2013-06-09 16:51:15

dankurka commented 9 years ago
This issue still exists in GWT Release 2.5.1.

If you code the following:

String foo = "foo";
String bar = "bar";

String foobar = String.format( "Hello %s. Where can I find the %s?", foo, bar);

the gwt compiler fails with:

[ERROR] Line xx: The method format(String, String, String) is undefined for the type
String

regards Tino

Reported by dejavue88 on 2013-10-30 09:14:17

dankurka commented 9 years ago
Any chance this can be fixed in 2.6.1?

Reported by vidal@umich.edu on 2014-02-03 05:13:27

dankurka commented 9 years ago

Reported by goktug@google.com on 2014-05-28 22:35:37

dankurka commented 9 years ago
For an implementation to be accepted would it have to conform to the entire Java Formater
spec? http://docs.oracle.com/javase/7/docs/api/java/util/Formatter.html

Would an implementation lacking the Date/Time conversions be acceptable?

Would an implementation that wraps sprintf.js be acceptable (if the licensing is compatible)?
https://github.com/alexei/sprintf.js

Reported by bpd9116 on 2015-02-06 23:09:50