Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » NLS.bind
NLS.bind [message #312927] Mon, 26 February 2007 04:54 Go to next message
Eclipse UserFriend
Hi,

I have reconverted my apps to the new (eclipse 3.1) resource bundles. I also
convert my own helper method which calls "MessageFormat.format" to the new
NLS.bind (see description under
http://www.eclipse.org/eclipse/platform-core/documents/3.1/m essage_bundles.html).

Now I get a "java.lang.IllegalArgumentException" when I call the method
NLS.bind. This is due to the fact, that NLS.bind doesn't use
MessageFormat.format and therefore doesn't understand my format definitions
in the string (example: "Bytes trasferred: {0,number,###,###,###,###}").

Is this a bug or a feature? Why NLS.bind doesn't call MessageFormat.format?

Can anybody help me?

Bye Stefan
Re: NLS.bind [message #312937 is a reply to message #312927] Mon, 26 February 2007 08:36 Go to previous messageGo to next message
Eclipse UserFriend
Stefan Pietsch wrote:
> Hi,
>
> I have reconverted my apps to the new (eclipse 3.1) resource bundles. I also
> convert my own helper method which calls "MessageFormat.format" to the new
> NLS.bind (see description under
> http://www.eclipse.org/eclipse/platform-core/documents/3.1/m essage_bundles.html).
>
> Now I get a "java.lang.IllegalArgumentException" when I call the method
> NLS.bind. This is due to the fact, that NLS.bind doesn't use
> MessageFormat.format and therefore doesn't understand my format definitions
> in the string (example: "Bytes trasferred: {0,number,###,###,###,###}").
>
> Is this a bug or a feature? Why NLS.bind doesn't call MessageFormat.format?

NLS.bind is *no* replacement for MessageFormat.format, this is a
well-documented fact of the NLS class:

"[..]The #bind methods perform string substitution and should be
considered a convenience and not a full substitute replacement for
MessageFormat#format method calls
[..]
"Clients who wish to use the full substitution power of the
MessageFormat class should call that class directly and not use these
#bind methods."

Btw, you can easily combine both worlds by transferring the intermediate
result of your own MessageFormat.format call as further argument of
NLS.bind, if necessary.

Greetings from Bremen,

Daniel Krügler
Re: NLS.bind [message #312941 is a reply to message #312937] Mon, 26 February 2007 09:22 Go to previous message
Eclipse UserFriend
Hi Daniel,

thanks for the information.

Bye Stefan

"Daniel Kr
Previous Topic:Mixing AWT with Eclipse SWT
Next Topic:request for eclipse 3.2.2 for Windows 64-bit
Goto Forum:
  


Current Time: Thu Nov 06 21:10:56 EST 2025

Powered by FUDForum. Page generated in 0.03853 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top