jdk/src/java.base/share/classes/sun/util/locale/provider/AuxLocaleProviderAdapter.java
changeset 33310 2701a9854bb5
parent 30047 63b6a16968d5
child 42360 5e60b1e45041
equal deleted inserted replaced
33309:3aecb54196d9 33310:2701a9854bb5
     1 /*
     1 /*
     2  * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
    31 import java.text.spi.CollatorProvider;
    31 import java.text.spi.CollatorProvider;
    32 import java.text.spi.DateFormatProvider;
    32 import java.text.spi.DateFormatProvider;
    33 import java.text.spi.DateFormatSymbolsProvider;
    33 import java.text.spi.DateFormatSymbolsProvider;
    34 import java.text.spi.DecimalFormatSymbolsProvider;
    34 import java.text.spi.DecimalFormatSymbolsProvider;
    35 import java.text.spi.NumberFormatProvider;
    35 import java.text.spi.NumberFormatProvider;
       
    36 import java.util.ArrayList;
    36 import java.util.Arrays;
    37 import java.util.Arrays;
    37 import java.util.HashSet;
    38 import java.util.List;
    38 import java.util.Locale;
    39 import java.util.Locale;
    39 import java.util.Set;
       
    40 import java.util.concurrent.ConcurrentHashMap;
    40 import java.util.concurrent.ConcurrentHashMap;
    41 import java.util.concurrent.ConcurrentMap;
    41 import java.util.concurrent.ConcurrentMap;
    42 import java.util.spi.CalendarDataProvider;
    42 import java.util.spi.CalendarDataProvider;
    43 import java.util.spi.CalendarNameProvider;
    43 import java.util.spi.CalendarNameProvider;
    44 import java.util.spi.CurrencyNameProvider;
    44 import java.util.spi.CurrencyNameProvider;
   159     private static Locale[] availableLocales = null;
   159     private static Locale[] availableLocales = null;
   160 
   160 
   161     @Override
   161     @Override
   162     public Locale[] getAvailableLocales() {
   162     public Locale[] getAvailableLocales() {
   163         if (availableLocales == null) {
   163         if (availableLocales == null) {
   164             Set<Locale> avail = new HashSet<>();
   164             List<Locale> avail = new ArrayList<>();
   165             for (Class<? extends LocaleServiceProvider> c :
   165             for (Class<? extends LocaleServiceProvider> c :
   166                     LocaleServiceProviderPool.spiClasses) {
   166                     LocaleServiceProviderPool.spiClasses) {
   167                 LocaleServiceProvider lsp = getLocaleServiceProvider(c);
   167                 LocaleServiceProvider lsp = getLocaleServiceProvider(c);
   168                 if (lsp != null) {
   168                 if (lsp != null) {
   169                     avail.addAll(Arrays.asList(lsp.getAvailableLocales()));
   169                     avail.addAll(Arrays.asList(lsp.getAvailableLocales()));
   170                 }
   170                 }
   171             }
   171             }
       
   172             availableLocales = avail.toArray(new Locale[0]);
   172         }
   173         }
   173 
   174 
   174         // assuming caller won't mutate the array.
   175         // assuming caller won't mutate the array.
   175         return availableLocales;
   176         return availableLocales;
   176     }
   177     }