yugalatea / gwt-google-apis

Automatically exported from code.google.com/p/gwt-google-apis
0 stars 0 forks source link

Language enum valueOf has problem to handle correct language code string #270

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Found in Release:
Language-1.0.0
Detailed description:
For example, if I write this code: 
Language.valueOf(Language.ENGLISH.getLangCode()). This should 
be a legal method call, but it throws java.lang.IllegalArgumentException 
exception. 

Workaround if you have one:

Links to the relevant GWT Developer Forum posts:

Original issue reported on code.google.com by benzhe...@gmail.com on 25 May 2009 at 5:51

GoogleCodeExporter commented 9 years ago
Here is the way to use valueOf with the Language enum - the string is the name 
of the
constant, not the parameter it was initialized with.

    Language result = Language.ENGLISH;
    Language result2 = Language.valueOf(Language.class, "ENGLISH");
    assertEquals("Language.ENGLISH", result, result2);

If you want to lookup by lang code, you'll have to search Language.values() or
construct a lookup table from Language.values().

Original comment by galgwt.reviews@gmail.com on 5 Jun 2009 at 3:31

GoogleCodeExporter commented 9 years ago
Now I understand this enumeration. Will it be possible to provide some utility 
method which can return the 
Language enum (Language.ENGLISH) by giving locale ISO code("en")? If so, it 
will be very useful to use with GWT 
locale implementation.

Original comment by benzhe...@gmail.com on 11 Jun 2009 at 7:37