<i18n dev> java.util.Locale changes

Masayoshi Okutsu masayoshi.okutsu at oracle.com
Wed Aug 28 06:25:43 PDT 2013


(adding core-libs-dev)

Hi Christian,

RFC 4647 defines The Language Priority List [1]. The use of 
java.util.List would be a natural fit, which is the reason why List is 
used. But use of Iterable does work (as API design). The parameter name 
`priorityIterable' sounds a bit odd, though.

Does use of Iterable add much value to the API? (Please note that List 
is also used in Locale.LanguageRange.)

Thanks,
Masayoshi

[1] http://tools.ietf.org/html/rfc4647#section-2.3

On 2013/08/28 18:31, Christian Beikov wrote:
> Hello there,
>
> I have just seen the changes you want to apply to java.util.Locale in 
> JDK 8 and was wondering why you are forcing the use of a 
> java.util.List in the lookup and filter methods. The related methods 
> of java.util.Locale are
>
> public static Locale lookup(List<Locale.LanguageRange> priorityList, 
> Collection<Locale> locales)
> public static String lookupTag(List<Locale.LanguageRange> 
> priorityList, Collection<String> tags)
> public static List<String> filterTags(List<Locale.LanguageRange> 
> priorityList, Collection<String> tags)
> public static List<String> filterTags(List<Locale.LanguageRange> 
> priorityList, Collection<String> tags, Locale.FilteringMode mode)
> public static List<Locale> filter(List<Locale.LanguageRange> 
> priorityList, Collection<Locale> locales)
> public static List<Locale> filter(List<Locale.LanguageRange> 
> priorityList, Collection<Locale> locales, Locale.FilteringMode mode)
>
> which could be changed to
>
> public static Locale lookup(Iterable<Locale.LanguageRange> 
> priorityIterable, Collection<Locale> locales)
> public static String lookupTag(Iterable<Locale.LanguageRange> 
> priorityIterable, Collection<String> tags)
> public static List<String> filterTags(Iterable<Locale.LanguageRange> 
> priorityIterable, Collection<String> tags)
> public static List<String> filterTags(Iterable<Locale.LanguageRange> 
> priorityIterable, Collection<String> tags, Locale.FilteringMode mode)
> public static List<Locale> filter(Iterable<Locale.LanguageRange> 
> priorityIterable, Collection<Locale> locales)
> public static List<Locale> filter(Iterable<Locale.LanguageRange> 
> priorityIterable, Collection<Locale> locales, Locale.FilteringMode mode)
>
> The use of java.util.Collection would also be ok.
> One could also use a java.util.Set or something similar to represent 
> the language ranges. I just wanted to provide that feedback if anyone 
> cares. I am also ok with java.util.List but since you are only relying 
> on the iteration order of the priorityList I was curious about the 
> reason.
>



More information about the i18n-dev mailing list