| NLS.bind [message #312927] |
Mon, 26 February 2007 04:54  |
Eclipse User |
|
|
|
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   |
Eclipse User |
|
|
|
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
|
|
|
|
Powered by
FUDForum. Page generated in 0.06136 seconds