Removal of text/util spi classes and references
This commit contains changes to docs and code.
Reasoning:
The changes made in Android to delegate through to ICU for
various I18N concerns make it unlikely that Android could
support the SPI code without substantial testing.
Explicitly removing the code and docs removes the
pretence / confusion over Android support for pluggable
locale data. It has definite code-size impact and will have
a slight runtime performance improvement.
Changes:
The docs previously referenced SPI classes that are not
public on Android. These references and associated
conditional text have been removed. Some references to
methods returning at least Locale.US have also been
removed because Android provides a larger set.
Code related to calls to the LocaleServiceProviderPool
has been removed or commented. The SPI classes and internal
support classes have been deleted.
Some additional "Android-changed" markers have been made
to highlight Android changes associated with the use of ICU
and/or preexisting removal of the SPI.
Bug: 31851669
Test: Ran CtsLibcoreTestCase and make checkbuild
Change-Id: I262b33f2c88d88dbb0c2f1d2b116952dc4e046e3
diff --git a/ojluni/src/main/java/java/text/BreakIterator.java b/ojluni/src/main/java/java/text/BreakIterator.java
index be75a9e..6e7e053 100644
--- a/ojluni/src/main/java/java/text/BreakIterator.java
+++ b/ojluni/src/main/java/java/text/BreakIterator.java
@@ -445,6 +445,7 @@
*/
public static BreakIterator getWordInstance(Locale locale)
{
+ // Android-changed: Switched to ICU.
return new IcuIteratorWrapper(
android.icu.text.BreakIterator.getWordInstance(locale));
}
@@ -470,6 +471,7 @@
*/
public static BreakIterator getLineInstance(Locale locale)
{
+ // Android-changed: Switched to ICU.
return new IcuIteratorWrapper(
android.icu.text.BreakIterator.getLineInstance(locale));
}
@@ -495,6 +497,7 @@
*/
public static BreakIterator getCharacterInstance(Locale locale)
{
+ // Android-changed: Switched to ICU.
return new IcuIteratorWrapper(
android.icu.text.BreakIterator.getCharacterInstance(locale));
}
@@ -520,25 +523,23 @@
*/
public static BreakIterator getSentenceInstance(Locale locale)
{
+ // Android-changed: Switched to ICU.
return new IcuIteratorWrapper(
android.icu.text.BreakIterator.getSentenceInstance(locale));
}
+ // Android-changed: Removed references to BreakIteratorProvider.
/**
* Returns an array of all locales for which the
* <code>get*Instance</code> methods of this class can return
* localized instances.
- * The returned array represents the union of locales supported by the Java
- * runtime and by installed
- * {@link java.text.spi.BreakIteratorProvider BreakIteratorProvider} implementations.
- * It must contain at least a <code>Locale</code>
- * instance equal to {@link java.util.Locale#US Locale.US}.
*
* @return An array of locales for which localized
* <code>BreakIterator</code> instances are available.
*/
public static synchronized Locale[] getAvailableLocales()
{
+ // Android-changed: Switched to ICU.
return android.icu.text.BreakIterator.getAvailableLocales();
}
}
diff --git a/ojluni/src/main/java/java/text/Collator.java b/ojluni/src/main/java/java/text/Collator.java
index 478074c..01e7dc9 100644
--- a/ojluni/src/main/java/java/text/Collator.java
+++ b/ojluni/src/main/java/java/text/Collator.java
@@ -229,6 +229,7 @@
public static synchronized
Collator getInstance(Locale desiredLocale)
{
+ // Android-changed: Switched to ICU.
if (desiredLocale == null) {
throw new NullPointerException("locale == null");
}
@@ -317,6 +318,7 @@
*/
public synchronized int getStrength()
{
+ // Android-changed: Switched to ICU.
// The value for IDENTICAL in ICU differs from that used in this class.
int value = icuColl.getStrength();
return (value == android.icu.text.Collator.IDENTICAL) ? IDENTICAL : value;
@@ -336,6 +338,7 @@
* PRIMARY, SECONDARY, TERTIARY or IDENTICAL.
*/
public synchronized void setStrength(int newStrength) {
+ // Android-changed: Switched to ICU.
// The ICU value for IDENTICAL differs from that defined in this class.
if (newStrength == IDENTICAL) {
newStrength = android.icu.text.Collator.IDENTICAL;
@@ -364,6 +367,7 @@
*/
public synchronized int getDecomposition()
{
+ // Android-changed: Switched to ICU.
return decompositionMode_ICU_Java(icuColl.getDecomposition());
}
/**
@@ -378,23 +382,21 @@
* mode.
*/
public synchronized void setDecomposition(int decompositionMode) {
+ // Android-changed: Switched to ICU.
icuColl.setDecomposition(decompositionMode_Java_ICU(decompositionMode));
}
+ // Android-changed: Removed references to CollatorProvider.
/**
* Returns an array of all locales for which the
* <code>getInstance</code> methods of this class can return
* localized instances.
- * The returned array represents the union of locales supported
- * by the Java runtime and by installed
- * {@link java.text.spi.CollatorProvider CollatorProvider} implementations.
- * It must contain at least a Locale instance equal to
- * {@link java.util.Locale#US Locale.US}.
*
* @return An array of locales for which localized
* <code>Collator</code> instances are available.
*/
public static synchronized Locale[] getAvailableLocales() {
+ // Android-changed: Removed reference to CollatorProvider. Switched to ICU.
return ICU.getAvailableCollatorLocales();
}
@@ -432,6 +434,7 @@
public Object clone()
{
try {
+ // Android-changed: Switched to ICU.
Collator clone = (Collator) super.clone();
clone.icuColl = (android.icu.text.Collator) icuColl.clone();
return clone;
@@ -459,6 +462,7 @@
return false;
}
Collator other = (Collator) that;
+ // Android-changed: Switched to ICU.
return icuColl == null ? other.icuColl == null : icuColl.equals(other.icuColl);
}
@@ -476,6 +480,7 @@
*/
protected Collator()
{
+ // Android-changed: Switched to ICU.
icuColl = android.icu.text.RuleBasedCollator.getInstance(Locale.getDefault());
}
diff --git a/ojluni/src/main/java/java/text/DateFormat.java b/ojluni/src/main/java/java/text/DateFormat.java
index 6d7c956..799694e 100644
--- a/ojluni/src/main/java/java/text/DateFormat.java
+++ b/ojluni/src/main/java/java/text/DateFormat.java
@@ -40,18 +40,14 @@
package java.text;
import java.io.InvalidObjectException;
-import java.text.spi.DateFormatProvider;
import java.util.Calendar;
import java.util.Date;
-import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.MissingResourceException;
-import java.util.ResourceBundle;
import java.util.TimeZone;
-import java.util.spi.LocaleServiceProvider;
-import sun.util.LocaleServiceProviderPool;
+import libcore.icu.ICU;
/**
* {@code DateFormat} is an abstract class for date/time formatting subclasses which
@@ -596,7 +592,12 @@
return getDateTimeInstance(SHORT, SHORT);
}
- /** @hide */
+ // Android-changed: Added support for overriding locale default 12 / 24 hour preference.
+ /**
+ * {@code null}: use Locale default. {@code true}: force 24-hour format.
+ * {@code false} force 12-hour format.
+ * @hide
+ */
public static Boolean is24Hour;
/**
@@ -606,24 +607,19 @@
DateFormat.is24Hour = is24Hour;
}
+ // Android-changed: Remove reference to DateFormatProvider.
/**
* Returns an array of all locales for which the
* <code>get*Instance</code> methods of this class can return
* localized instances.
- * The returned array represents the union of locales supported by the Java
- * runtime and by installed
- * {@link java.text.spi.DateFormatProvider DateFormatProvider} implementations.
- * It must contain at least a <code>Locale</code> instance equal to
- * {@link java.util.Locale#US Locale.US}.
*
* @return An array of locales for which localized
* <code>DateFormat</code> instances are available.
*/
public static Locale[] getAvailableLocales()
{
- LocaleServiceProviderPool pool =
- LocaleServiceProviderPool.getPool(DateFormatProvider.class);
- return pool.getAvailableLocales();
+ // Android-changed: Removed used of DateFormatProvider. Switched to use ICU.
+ return ICU.getAvailableLocales();
}
/**
@@ -803,23 +799,8 @@
} else {
dateStyle = -1;
}
+ // Android-changed: Removed used of DateFormatProvider.
try {
- // Check whether a provider can provide an implementation that's closer
- // to the requested locale than what the Java runtime itself can provide.
- LocaleServiceProviderPool pool =
- LocaleServiceProviderPool.getPool(DateFormatProvider.class);
- if (pool.hasProviders()) {
- DateFormat providersInstance = pool.getLocalizedObject(
- DateFormatGetter.INSTANCE,
- loc,
- timeStyle,
- dateStyle,
- flags);
- if (providersInstance != null) {
- return providersInstance;
- }
- }
-
return new SimpleDateFormat(timeStyle, dateStyle, loc);
} catch (MissingResourceException e) {
return new SimpleDateFormat("M/d/yy h:mm a");
@@ -1046,37 +1027,4 @@
*/
public final static Field TIME_ZONE = new Field("time zone", -1);
}
-
- /**
- * Obtains a DateFormat instance from a DateFormatProvider
- * implementation.
- */
- private static class DateFormatGetter
- implements LocaleServiceProviderPool.LocalizedObjectGetter<DateFormatProvider, DateFormat> {
- private static final DateFormatGetter INSTANCE = new DateFormatGetter();
-
- public DateFormat getObject(DateFormatProvider dateFormatProvider,
- Locale locale,
- String key,
- Object... params) {
- assert params.length == 3;
-
- int timeStyle = (Integer)params[0];
- int dateStyle = (Integer)params[1];
- int flags = (Integer)params[2];
-
- switch (flags) {
- case 1:
- return dateFormatProvider.getTimeInstance(timeStyle, locale);
- case 2:
- return dateFormatProvider.getDateInstance(dateStyle, locale);
- case 3:
- return dateFormatProvider.getDateTimeInstance(dateStyle, timeStyle, locale);
- default:
- assert false : "should not happen";
- }
-
- return null;
- }
- }
}
diff --git a/ojluni/src/main/java/java/text/DateFormatSymbols.java b/ojluni/src/main/java/java/text/DateFormatSymbols.java
index c617a18..47f0973 100644
--- a/ojluni/src/main/java/java/text/DateFormatSymbols.java
+++ b/ojluni/src/main/java/java/text/DateFormatSymbols.java
@@ -44,7 +44,6 @@
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.lang.ref.SoftReference;
-import java.text.spi.DateFormatSymbolsProvider;
import java.util.Arrays;
import java.util.Locale;
import java.util.Objects;
@@ -52,9 +51,9 @@
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
+import libcore.icu.ICU;
import libcore.icu.LocaleData;
import libcore.icu.TimeZoneNames;
-import sun.util.LocaleServiceProviderPool;
/**
* <code>DateFormatSymbols</code> is a public class for encapsulating
@@ -103,15 +102,13 @@
*/
public class DateFormatSymbols implements Serializable, Cloneable {
+ // Android-changed: Removed reference to DateFormatSymbolsProvider but suggested getInstance()
+ // be used instead in case Android supports it in future.
/**
* Construct a DateFormatSymbols object by loading format data from
* resources for the default {@link java.util.Locale.Category#FORMAT FORMAT}
- * locale. This constructor can only
- * construct instances for the locales supported by the Java
- * runtime environment, not for those supported by installed
- * {@link java.text.spi.DateFormatSymbolsProvider DateFormatSymbolsProvider}
- * implementations. For full locale coverage, use the
- * {@link #getInstance(Locale) getInstance} method.
+ * locale. It is recommended that the {@link #getInstance(Locale) getInstance} method is used
+ * instead.
* <p>This is equivalent to calling
* {@link #DateFormatSymbols(Locale)
* DateFormatSymbols(Locale.getDefault(Locale.Category.FORMAT))}.
@@ -127,14 +124,12 @@
initializeData(Locale.getDefault(Locale.Category.FORMAT));
}
+ // Android-changed: Removed reference to DateFormatSymbolsProvider but suggested getInstance()
+ // be used instead in case Android supports it in future.
/**
* Construct a DateFormatSymbols object by loading format data from
- * resources for the given locale. This constructor can only
- * construct instances for the locales supported by the Java
- * runtime environment, not for those supported by installed
- * {@link java.text.spi.DateFormatSymbolsProvider DateFormatSymbolsProvider}
- * implementations. For full locale coverage, use the
- * {@link #getInstance(Locale) getInstance} method.
+ * resources for the given locale. It is recommended that the
+ * {@link #getInstance(Locale) getInstance} method is used instead.
*
* @param locale the desired locale
* @see #getInstance(Locale)
@@ -361,33 +356,25 @@
*/
private String[] tinyStandAloneWeekdays;
+ // Android-changed: Removed reference to DateFormatSymbolsProvider.
/**
* Returns an array of all locales for which the
* <code>getInstance</code> methods of this class can return
* localized instances.
- * The returned array represents the union of locales supported by the
- * Java runtime and by installed
- * {@link java.text.spi.DateFormatSymbolsProvider DateFormatSymbolsProvider}
- * implementations. It must contain at least a <code>Locale</code>
- * instance equal to {@link java.util.Locale#US Locale.US}.
*
* @return An array of locales for which localized
* <code>DateFormatSymbols</code> instances are available.
* @since 1.6
*/
public static Locale[] getAvailableLocales() {
- LocaleServiceProviderPool pool=
- LocaleServiceProviderPool.getPool(DateFormatSymbolsProvider.class);
- return pool.getAvailableLocales();
+ // Android-changed: No support for DateFormatSymbolsProvider.
+ return ICU.getAvailableLocales();
}
+ // Android-changed: Removed reference to DateFormatSymbolsProvider.
/**
* Gets the <code>DateFormatSymbols</code> instance for the default
- * locale. This method provides access to <code>DateFormatSymbols</code>
- * instances for locales supported by the Java runtime itself as well
- * as for those supported by installed
- * {@link java.text.spi.DateFormatSymbolsProvider DateFormatSymbolsProvider}
- * implementations.
+ * locale.
* <p>This is equivalent to calling {@link #getInstance(Locale)
* getInstance(Locale.getDefault(Locale.Category.FORMAT))}.
* @see java.util.Locale#getDefault(java.util.Locale.Category)
@@ -399,23 +386,17 @@
return getInstance(Locale.getDefault(Locale.Category.FORMAT));
}
+ // Android-changed: Removed reference to DateFormatSymbolsProvider.
/**
* Gets the <code>DateFormatSymbols</code> instance for the specified
- * locale. This method provides access to <code>DateFormatSymbols</code>
- * instances for locales supported by the Java runtime itself as well
- * as for those supported by installed
- * {@link java.text.spi.DateFormatSymbolsProvider DateFormatSymbolsProvider}
- * implementations.
+ * locale.
* @param locale the given locale.
* @return a <code>DateFormatSymbols</code> instance.
* @exception NullPointerException if <code>locale</code> is null
* @since 1.6
*/
public static final DateFormatSymbols getInstance(Locale locale) {
- DateFormatSymbols dfs = getProviderInstance(locale);
- if (dfs != null) {
- return dfs;
- }
+ // Android-changed: Removed used of DateFormatSymbolsProvider.
return (DateFormatSymbols) getCachedInstance(locale).clone();
}
@@ -426,27 +407,10 @@
* an application.
*/
static final DateFormatSymbols getInstanceRef(Locale locale) {
- DateFormatSymbols dfs = getProviderInstance(locale);
- if (dfs != null) {
- return dfs;
- }
+ // Android-changed: Removed used of DateFormatSymbolsProvider.
return getCachedInstance(locale);
}
- private static DateFormatSymbols getProviderInstance(Locale locale) {
- DateFormatSymbols providersInstance = null;
-
- // Check whether a provider can provide an implementation that's closer
- // to the requested locale than what the Java runtime itself can provide.
- LocaleServiceProviderPool pool =
- LocaleServiceProviderPool.getPool(DateFormatSymbolsProvider.class);
- if (pool.hasProviders()) {
- providersInstance = pool.getLocalizedObject(
- DateFormatSymbolsGetter.INSTANCE, locale);
- }
- return providersInstance;
- }
-
/**
* Returns a cached DateFormatSymbols if it's found in the
* cache. Otherwise, this method returns a newly cached instance
@@ -580,6 +544,7 @@
cachedHashCode = 0;
}
+ // Android-changed: Removed reference to TimeZoneNameProvider.
/**
* Gets time zone strings. Use of this method is discouraged; use
* {@link java.util.TimeZone#getDisplayName() TimeZone.getDisplayName()}
@@ -611,9 +576,7 @@
* If {@link #setZoneStrings(String[][]) setZoneStrings} has been called
* on this <code>DateFormatSymbols</code> instance, then the strings
* provided by that call are returned. Otherwise, the returned array
- * contains names provided by the Java runtime and by installed
- * {@link java.util.spi.TimeZoneNameProvider TimeZoneNameProvider}
- * implementations.
+ * contains names provided by the runtime.
*
* @return the time zone strings.
* @see #setZoneStrings(String[][])
@@ -1004,23 +967,4 @@
internalZoneStrings();
stream.defaultWriteObject();
}
-
- /**
- * Obtains a DateFormatSymbols instance from a DateFormatSymbolsProvider
- * implementation.
- */
- private static class DateFormatSymbolsGetter
- implements LocaleServiceProviderPool.LocalizedObjectGetter<DateFormatSymbolsProvider,
- DateFormatSymbols> {
- private static final DateFormatSymbolsGetter INSTANCE =
- new DateFormatSymbolsGetter();
-
- public DateFormatSymbols getObject(DateFormatSymbolsProvider dateFormatSymbolsProvider,
- Locale locale,
- String key,
- Object... params) {
- assert params.length == 0;
- return dateFormatSymbolsProvider.getInstance(locale);
- }
- }
}
diff --git a/ojluni/src/main/java/java/text/DecimalFormatSymbols.java b/ojluni/src/main/java/java/text/DecimalFormatSymbols.java
index a2bb05b..3937065 100644
--- a/ojluni/src/main/java/java/text/DecimalFormatSymbols.java
+++ b/ojluni/src/main/java/java/text/DecimalFormatSymbols.java
@@ -44,14 +44,12 @@
import java.io.ObjectOutputStream;
import java.io.ObjectStreamField;
import java.io.Serializable;
-import java.text.spi.DecimalFormatSymbolsProvider;
import java.util.Currency;
import java.util.Locale;
import java.util.concurrent.ConcurrentHashMap;
+import libcore.icu.ICU;
import libcore.icu.LocaleData;
-import sun.util.LocaleServiceProviderPool;
-
/**
* This class represents the set of symbols (such as the decimal separator,
* the grouping separator, and so on) needed by <code>DecimalFormat</code>
@@ -68,15 +66,13 @@
public class DecimalFormatSymbols implements Cloneable, Serializable {
+ // Android-changed: Removed reference to DecimalFormatSymbolsProvider but suggested
+ // getInstance() be used instead in case Android supports it in future.
/**
* Create a DecimalFormatSymbols object for the default
* {@link java.util.Locale.Category#FORMAT FORMAT} locale.
- * This constructor can only construct instances for the locales
- * supported by the Java runtime environment, not for those
- * supported by installed
- * {@link java.text.spi.DecimalFormatSymbolsProvider DecimalFormatSymbolsProvider}
- * implementations. For full locale coverage, use the
- * {@link #getInstance(Locale) getInstance} method.
+ * It is recommended that the {@link #getInstance(Locale) getInstance} method is used
+ * instead.
* <p>This is equivalent to calling
* {@link #DecimalFormatSymbols(Locale)
* DecimalFormatSymbols(Locale.getDefault(Locale.Category.FORMAT))}.
@@ -87,14 +83,12 @@
initialize( Locale.getDefault(Locale.Category.FORMAT) );
}
+ // Android-changed: Removed reference to DecimalFormatSymbolsProvider but suggested
+ // getInstance() be used instead in case Android supports it in future.
/**
* Create a DecimalFormatSymbols object for the given locale.
- * This constructor can only construct instances for the locales
- * supported by the Java runtime environment, not for those
- * supported by installed
- * {@link java.text.spi.DecimalFormatSymbolsProvider DecimalFormatSymbolsProvider}
- * implementations. For full locale coverage, use the
- * {@link #getInstance(Locale) getInstance} method.
+ * It is recommended that the {@link #getInstance(Locale) getInstance} method is used
+ * instead.
* If the specified locale contains the {@link java.util.Locale#UNICODE_LOCALE_EXTENSION}
* for the numbering system, the instance is initialized with the specified numbering
* system if the JRE implementation supports it. For example,
@@ -111,33 +105,25 @@
initialize( locale );
}
+ // Android-changed: Removed reference to DecimalFormatSymbolsProvider.
/**
* Returns an array of all locales for which the
* <code>getInstance</code> methods of this class can return
* localized instances.
- * The returned array represents the union of locales supported by the Java
- * runtime and by installed
- * {@link java.text.spi.DecimalFormatSymbolsProvider DecimalFormatSymbolsProvider}
- * implementations. It must contain at least a <code>Locale</code>
- * instance equal to {@link java.util.Locale#US Locale.US}.
*
* @return an array of locales for which localized
* <code>DecimalFormatSymbols</code> instances are available.
* @since 1.6
*/
public static Locale[] getAvailableLocales() {
- LocaleServiceProviderPool pool =
- LocaleServiceProviderPool.getPool(DecimalFormatSymbolsProvider.class);
- return pool.getAvailableLocales();
+ // Android-changed: Removed used of DecimalFormatSymbolsProvider. Switched to use ICU.
+ return ICU.getAvailableLocales();
}
+ // Android-changed: Removed reference to DecimalFormatSymbolsProvider.
/**
* Gets the <code>DecimalFormatSymbols</code> instance for the default
- * locale. This method provides access to <code>DecimalFormatSymbols</code>
- * instances for locales supported by the Java runtime itself as well
- * as for those supported by installed
- * {@link java.text.spi.DecimalFormatSymbolsProvider
- * DecimalFormatSymbolsProvider} implementations.
+ * locale.
* <p>This is equivalent to calling
* {@link #getInstance(Locale)
* getInstance(Locale.getDefault(Locale.Category.FORMAT))}.
@@ -150,13 +136,10 @@
return getInstance(Locale.getDefault(Locale.Category.FORMAT));
}
+ // Android-changed: Removed reference to DecimalFormatSymbolsProvider.
/**
* Gets the <code>DecimalFormatSymbols</code> instance for the specified
- * locale. This method provides access to <code>DecimalFormatSymbols</code>
- * instances for locales supported by the Java runtime itself as well
- * as for those supported by installed
- * {@link java.text.spi.DecimalFormatSymbolsProvider
- * DecimalFormatSymbolsProvider} implementations.
+ * locale.
* If the specified locale contains the {@link java.util.Locale#UNICODE_LOCALE_EXTENSION}
* for the numbering system, the instance is initialized with the specified numbering
* system if the JRE implementation supports it. For example,
@@ -172,19 +155,7 @@
* @since 1.6
*/
public static final DecimalFormatSymbols getInstance(Locale locale) {
-
- // Check whether a provider can provide an implementation that's closer
- // to the requested locale than what the Java runtime itself can provide.
- LocaleServiceProviderPool pool =
- LocaleServiceProviderPool.getPool(DecimalFormatSymbolsProvider.class);
- if (pool.hasProviders()) {
- DecimalFormatSymbols providersInstance = pool.getLocalizedObject(
- DecimalFormatSymbolsGetter.INSTANCE, locale);
- if (providersInstance != null) {
- return providersInstance;
- }
- }
-
+ // Android-changed: Removed used of DecimalFormatSymbolsProvider.
return new DecimalFormatSymbols(locale);
}
@@ -659,6 +630,7 @@
private void initialize( Locale locale ) {
this.locale = locale;
+ // Android-changed: Removed use of DecimalFormatSymbolsProvider. Switched to ICU.
// get resource bundle data - try the cache first
boolean needCacheUpdate = false;
Object[] data = cachedLocaleData.get(locale);
@@ -1128,24 +1100,4 @@
private static final ConcurrentHashMap<Locale, Object[]> cachedLocaleData = new ConcurrentHashMap<Locale, Object[]>(3);
private transient android.icu.text.DecimalFormatSymbols cachedIcuDFS = null;
-
- /**
- * Obtains a DecimalFormatSymbols instance from a DecimalFormatSymbolsProvider
- * implementation.
- */
- private static class DecimalFormatSymbolsGetter
- implements LocaleServiceProviderPool.LocalizedObjectGetter<DecimalFormatSymbolsProvider,
- DecimalFormatSymbols> {
- private static final DecimalFormatSymbolsGetter INSTANCE =
- new DecimalFormatSymbolsGetter();
-
- public DecimalFormatSymbols getObject(
- DecimalFormatSymbolsProvider decimalFormatSymbolsProvider,
- Locale locale,
- String key,
- Object... params) {
- assert params.length == 0;
- return decimalFormatSymbolsProvider.getInstance(locale);
- }
- }
}
diff --git a/ojluni/src/main/java/java/text/NumberFormat.java b/ojluni/src/main/java/java/text/NumberFormat.java
index 476983f..218a668 100644
--- a/ojluni/src/main/java/java/text/NumberFormat.java
+++ b/ojluni/src/main/java/java/text/NumberFormat.java
@@ -45,18 +45,15 @@
import java.io.ObjectOutputStream;
import java.math.BigInteger;
import java.math.RoundingMode;
-import java.text.spi.NumberFormatProvider;
import java.util.Currency;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Locale;
import java.util.Map;
-import java.util.ResourceBundle;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
-import java.util.spi.LocaleServiceProvider;
+import libcore.icu.ICU;
import libcore.icu.LocaleData;
-import sun.util.LocaleServiceProviderPool;
/**
* <code>NumberFormat</code> is the abstract base class for all number
@@ -548,23 +545,18 @@
return getInstance(inLocale, PERCENTSTYLE);
}
+ // Android-changed: Removed reference to NumberFormatProvider.
/**
* Returns an array of all locales for which the
* <code>get*Instance</code> methods of this class can return
* localized instances.
- * The returned array represents the union of locales supported by the Java
- * runtime and by installed
- * {@link java.text.spi.NumberFormatProvider NumberFormatProvider} implementations.
- * It must contain at least a <code>Locale</code> instance equal to
- * {@link java.util.Locale#US Locale.US}.
*
* @return An array of locales for which localized
* <code>NumberFormat</code> instances are available.
*/
public static Locale[] getAvailableLocales() {
- LocaleServiceProviderPool pool =
- LocaleServiceProviderPool.getPool(NumberFormatProvider.class);
- return pool.getAvailableLocales();
+ // Android-changed: Removed used of NumberFormatProvider. Switched to use ICU.
+ return ICU.getAvailableLocales();
}
/**
@@ -829,20 +821,7 @@
private static NumberFormat getInstance(Locale desiredLocale,
int choice) {
- // Check whether a provider can provide an implementation that's closer
- // to the requested locale than what the Java runtime itself can provide.
- LocaleServiceProviderPool pool =
- LocaleServiceProviderPool.getPool(NumberFormatProvider.class);
- if (pool.hasProviders()) {
- NumberFormat providersInstance = pool.getLocalizedObject(
- NumberFormatGetter.INSTANCE,
- desiredLocale,
- choice);
- if (providersInstance != null) {
- return providersInstance;
- }
- }
-
+ // Android-changed: Removed use of NumberFormatProvider. Switched to use ICU.
/* try the cache first */
String[] numberPatterns = (String[])cachedLocaleData.get(desiredLocale);
if (numberPatterns == null) { /* cache miss */
@@ -1219,36 +1198,4 @@
*/
public static final Field EXPONENT_SIGN = new Field("exponent sign");
}
-
- /**
- * Obtains a NumberFormat instance from a NumberFormatProvider implementation.
- */
- private static class NumberFormatGetter
- implements LocaleServiceProviderPool.LocalizedObjectGetter<NumberFormatProvider,
- NumberFormat> {
- private static final NumberFormatGetter INSTANCE = new NumberFormatGetter();
-
- public NumberFormat getObject(NumberFormatProvider numberFormatProvider,
- Locale locale,
- String key,
- Object... params) {
- assert params.length == 1;
- int choice = (Integer)params[0];
-
- switch (choice) {
- case NUMBERSTYLE:
- return numberFormatProvider.getNumberInstance(locale);
- case PERCENTSTYLE:
- return numberFormatProvider.getPercentInstance(locale);
- case CURRENCYSTYLE:
- return numberFormatProvider.getCurrencyInstance(locale);
- case INTEGERSTYLE:
- return numberFormatProvider.getIntegerInstance(locale);
- default:
- assert false : choice;
- }
-
- return null;
- }
- }
}
diff --git a/ojluni/src/main/java/java/text/spi/BreakIteratorProvider.java b/ojluni/src/main/java/java/text/spi/BreakIteratorProvider.java
deleted file mode 100644
index dd4a1a2..0000000
--- a/ojluni/src/main/java/java/text/spi/BreakIteratorProvider.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package java.text.spi;
-
-import java.text.BreakIterator;
-import java.util.Locale;
-import java.util.spi.LocaleServiceProvider;
-
-/**
- * An abstract class for service providers that
- * provide concrete implementations of the
- * {@link java.text.BreakIterator BreakIterator} class.
- *
- * @since 1.6
- */
-public abstract class BreakIteratorProvider extends LocaleServiceProvider {
-
- /**
- * Sole constructor. (For invocation by subclass constructors, typically
- * implicit.)
- */
- protected BreakIteratorProvider() {
- }
-
- /**
- * Returns a new <code>BreakIterator</code> instance
- * for <a href="../BreakIterator.html#word">word breaks</a>
- * for the given locale.
- * @param locale the desired locale
- * @return A break iterator for word breaks
- * @exception NullPointerException if <code>locale</code> is null
- * @exception IllegalArgumentException if <code>locale</code> isn't
- * one of the locales returned from
- * {@link java.util.spi.LocaleServiceProvider#getAvailableLocales()
- * getAvailableLocales()}.
- * @see java.text.BreakIterator#getWordInstance(java.util.Locale)
- */
- public abstract BreakIterator getWordInstance(Locale locale);
-
- /**
- * Returns a new <code>BreakIterator</code> instance
- * for <a href="../BreakIterator.html#line">line breaks</a>
- * for the given locale.
- * @param locale the desired locale
- * @return A break iterator for line breaks
- * @exception NullPointerException if <code>locale</code> is null
- * @exception IllegalArgumentException if <code>locale</code> isn't
- * one of the locales returned from
- * {@link java.util.spi.LocaleServiceProvider#getAvailableLocales()
- * getAvailableLocales()}.
- * @see java.text.BreakIterator#getLineInstance(java.util.Locale)
- */
- public abstract BreakIterator getLineInstance(Locale locale);
-
- /**
- * Returns a new <code>BreakIterator</code> instance
- * for <a href="../BreakIterator.html#character">character breaks</a>
- * for the given locale.
- * @param locale the desired locale
- * @return A break iterator for character breaks
- * @exception NullPointerException if <code>locale</code> is null
- * @exception IllegalArgumentException if <code>locale</code> isn't
- * one of the locales returned from
- * {@link java.util.spi.LocaleServiceProvider#getAvailableLocales()
- * getAvailableLocales()}.
- * @see java.text.BreakIterator#getCharacterInstance(java.util.Locale)
- */
- public abstract BreakIterator getCharacterInstance(Locale locale);
-
- /**
- * Returns a new <code>BreakIterator</code> instance
- * for <a href="../BreakIterator.html#sentence">sentence breaks</a>
- * for the given locale.
- * @param locale the desired locale
- * @return A break iterator for sentence breaks
- * @exception NullPointerException if <code>locale</code> is null
- * @exception IllegalArgumentException if <code>locale</code> isn't
- * one of the locales returned from
- * {@link java.util.spi.LocaleServiceProvider#getAvailableLocales()
- * getAvailableLocales()}.
- * @see java.text.BreakIterator#getSentenceInstance(java.util.Locale)
- */
- public abstract BreakIterator getSentenceInstance(Locale locale);
-}
diff --git a/ojluni/src/main/java/java/text/spi/CollatorProvider.java b/ojluni/src/main/java/java/text/spi/CollatorProvider.java
deleted file mode 100644
index 1480908..0000000
--- a/ojluni/src/main/java/java/text/spi/CollatorProvider.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package java.text.spi;
-
-import java.text.Collator;
-import java.util.Locale;
-import java.util.spi.LocaleServiceProvider;
-
-/**
- * An abstract class for service providers that
- * provide concrete implementations of the
- * {@link java.text.Collator Collator} class.
- *
- * @since 1.6
- */
-public abstract class CollatorProvider extends LocaleServiceProvider {
-
- /**
- * Sole constructor. (For invocation by subclass constructors, typically
- * implicit.)
- */
- protected CollatorProvider() {
- }
-
- /**
- * Returns a new <code>Collator</code> instance for the specified locale.
- * @param locale the desired locale.
- * @return the <code>Collator</code> for the desired locale.
- * @exception NullPointerException if
- * <code>locale</code> is null
- * @exception IllegalArgumentException if <code>locale</code> isn't
- * one of the locales returned from
- * {@link java.util.spi.LocaleServiceProvider#getAvailableLocales()
- * getAvailableLocales()}.
- * @see java.text.Collator#getInstance(java.util.Locale)
- */
- public abstract Collator getInstance(Locale locale);
-}
diff --git a/ojluni/src/main/java/java/text/spi/DateFormatProvider.java b/ojluni/src/main/java/java/text/spi/DateFormatProvider.java
deleted file mode 100644
index e12effd..0000000
--- a/ojluni/src/main/java/java/text/spi/DateFormatProvider.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package java.text.spi;
-
-import java.text.DateFormat;
-import java.util.Locale;
-import java.util.spi.LocaleServiceProvider;
-
-/**
- * An abstract class for service providers that
- * provide concrete implementations of the
- * {@link java.text.DateFormat DateFormat} class.
- *
- * @since 1.6
- */
-public abstract class DateFormatProvider extends LocaleServiceProvider {
-
- /**
- * Sole constructor. (For invocation by subclass constructors, typically
- * implicit.)
- */
- protected DateFormatProvider() {
- }
-
- /**
- * Returns a new <code>DateFormat</code> instance which formats time
- * with the given formatting style for the specified locale.
- * @param style the given formatting style. Either one of
- * {@link java.text.DateFormat#SHORT DateFormat.SHORT},
- * {@link java.text.DateFormat#MEDIUM DateFormat.MEDIUM},
- * {@link java.text.DateFormat#LONG DateFormat.LONG}, or
- * {@link java.text.DateFormat#FULL DateFormat.FULL}.
- * @param locale the desired locale.
- * @exception IllegalArgumentException if <code>style</code> is invalid,
- * or if <code>locale</code> isn't
- * one of the locales returned from
- * {@link java.util.spi.LocaleServiceProvider#getAvailableLocales()
- * getAvailableLocales()}.
- * @exception NullPointerException if <code>locale</code> is null
- * @return a time formatter.
- * @see java.text.DateFormat#getTimeInstance(int, java.util.Locale)
- */
- public abstract DateFormat getTimeInstance(int style, Locale locale);
-
- /**
- * Returns a new <code>DateFormat</code> instance which formats date
- * with the given formatting style for the specified locale.
- * @param style the given formatting style. Either one of
- * {@link java.text.DateFormat#SHORT DateFormat.SHORT},
- * {@link java.text.DateFormat#MEDIUM DateFormat.MEDIUM},
- * {@link java.text.DateFormat#LONG DateFormat.LONG}, or
- * {@link java.text.DateFormat#FULL DateFormat.FULL}.
- * @param locale the desired locale.
- * @exception IllegalArgumentException if <code>style</code> is invalid,
- * or if <code>locale</code> isn't
- * one of the locales returned from
- * {@link java.util.spi.LocaleServiceProvider#getAvailableLocales()
- * getAvailableLocales()}.
- * @exception NullPointerException if <code>locale</code> is null
- * @return a date formatter.
- * @see java.text.DateFormat#getDateInstance(int, java.util.Locale)
- */
- public abstract DateFormat getDateInstance(int style, Locale locale);
-
- /**
- * Returns a new <code>DateFormat</code> instance which formats date and time
- * with the given formatting style for the specified locale.
- * @param dateStyle the given date formatting style. Either one of
- * {@link java.text.DateFormat#SHORT DateFormat.SHORT},
- * {@link java.text.DateFormat#MEDIUM DateFormat.MEDIUM},
- * {@link java.text.DateFormat#LONG DateFormat.LONG}, or
- * {@link java.text.DateFormat#FULL DateFormat.FULL}.
- * @param timeStyle the given time formatting style. Either one of
- * {@link java.text.DateFormat#SHORT DateFormat.SHORT},
- * {@link java.text.DateFormat#MEDIUM DateFormat.MEDIUM},
- * {@link java.text.DateFormat#LONG DateFormat.LONG}, or
- * {@link java.text.DateFormat#FULL DateFormat.FULL}.
- * @param locale the desired locale.
- * @exception IllegalArgumentException if <code>dateStyle</code> or
- * <code>timeStyle</code> is invalid,
- * or if <code>locale</code> isn't
- * one of the locales returned from
- * {@link java.util.spi.LocaleServiceProvider#getAvailableLocales()
- * getAvailableLocales()}.
- * @exception NullPointerException if <code>locale</code> is null
- * @return a date/time formatter.
- * @see java.text.DateFormat#getDateTimeInstance(int, int, java.util.Locale)
- */
- public abstract DateFormat
- getDateTimeInstance(int dateStyle, int timeStyle, Locale locale);
-}
diff --git a/ojluni/src/main/java/java/text/spi/DateFormatSymbolsProvider.java b/ojluni/src/main/java/java/text/spi/DateFormatSymbolsProvider.java
deleted file mode 100644
index bc3a8fb..0000000
--- a/ojluni/src/main/java/java/text/spi/DateFormatSymbolsProvider.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package java.text.spi;
-
-import java.text.DateFormatSymbols;
-import java.util.Locale;
-import java.util.spi.LocaleServiceProvider;
-
-/**
- * An abstract class for service providers that
- * provide instances of the
- * {@link java.text.DateFormatSymbols DateFormatSymbols} class.
- *
- * @since 1.6
- */
-public abstract class DateFormatSymbolsProvider extends LocaleServiceProvider {
-
- /**
- * Sole constructor. (For invocation by subclass constructors, typically
- * implicit.)
- */
- protected DateFormatSymbolsProvider() {
- }
-
- /**
- * Returns a new <code>DateFormatSymbols</code> instance for the
- * specified locale.
- *
- * @param locale the desired locale
- * @exception NullPointerException if <code>locale</code> is null
- * @exception IllegalArgumentException if <code>locale</code> isn't
- * one of the locales returned from
- * {@link java.util.spi.LocaleServiceProvider#getAvailableLocales()
- * getAvailableLocales()}.
- * @return a <code>DateFormatSymbols</code> instance.
- * @see java.text.DateFormatSymbols#getInstance(java.util.Locale)
- */
- public abstract DateFormatSymbols getInstance(Locale locale);
-}
diff --git a/ojluni/src/main/java/java/text/spi/DecimalFormatSymbolsProvider.java b/ojluni/src/main/java/java/text/spi/DecimalFormatSymbolsProvider.java
deleted file mode 100644
index d1d078c..0000000
--- a/ojluni/src/main/java/java/text/spi/DecimalFormatSymbolsProvider.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package java.text.spi;
-
-import java.text.DecimalFormatSymbols;
-import java.util.Locale;
-import java.util.spi.LocaleServiceProvider;
-
-/**
- * An abstract class for service providers that
- * provide instances of the
- * {@link java.text.DecimalFormatSymbols DecimalFormatSymbols} class.
- *
- * <p>The requested {@code Locale} may contain an <a
- * href="../../util/Locale.html#def_locale_extension"> extension</a> for
- * specifying the desired numbering system. For example, {@code "ar-u-nu-arab"}
- * (in the BCP 47 language tag form) specifies Arabic with the Arabic-Indic
- * digits and symbols, while {@code "ar-u-nu-latn"} specifies Arabic with the
- * Latin digits and symbols. Refer to the <em>Unicode Locale Data Markup
- * Language (LDML)</em> specification for numbering systems.
- *
- * @since 1.6
- * @see Locale#forLanguageTag(String)
- * @see Locale#getExtension(char)
- */
-public abstract class DecimalFormatSymbolsProvider extends LocaleServiceProvider {
-
- /**
- * Sole constructor. (For invocation by subclass constructors, typically
- * implicit.)
- */
- protected DecimalFormatSymbolsProvider() {
- }
-
- /**
- * Returns a new <code>DecimalFormatSymbols</code> instance for the
- * specified locale.
- *
- * @param locale the desired locale
- * @exception NullPointerException if <code>locale</code> is null
- * @exception IllegalArgumentException if <code>locale</code> isn't
- * one of the locales returned from
- * {@link java.util.spi.LocaleServiceProvider#getAvailableLocales()
- * getAvailableLocales()}.
- * @return a <code>DecimalFormatSymbols</code> instance.
- * @see java.text.DecimalFormatSymbols#getInstance(java.util.Locale)
- */
- public abstract DecimalFormatSymbols getInstance(Locale locale);
-}
diff --git a/ojluni/src/main/java/java/text/spi/NumberFormatProvider.java b/ojluni/src/main/java/java/text/spi/NumberFormatProvider.java
deleted file mode 100644
index a375b69..0000000
--- a/ojluni/src/main/java/java/text/spi/NumberFormatProvider.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package java.text.spi;
-
-import java.text.NumberFormat;
-import java.util.Locale;
-import java.util.spi.LocaleServiceProvider;
-
-/**
- * An abstract class for service providers that
- * provide concrete implementations of the
- * {@link java.text.NumberFormat NumberFormat} class.
- *
- * @since 1.6
- */
-public abstract class NumberFormatProvider extends LocaleServiceProvider {
-
- /**
- * Sole constructor. (For invocation by subclass constructors, typically
- * implicit.)
- */
- protected NumberFormatProvider() {
- }
-
- /**
- * Returns a new <code>NumberFormat</code> instance which formats
- * monetary values for the specified locale.
- *
- * @param locale the desired locale.
- * @exception NullPointerException if <code>locale</code> is null
- * @exception IllegalArgumentException if <code>locale</code> isn't
- * one of the locales returned from
- * {@link java.util.spi.LocaleServiceProvider#getAvailableLocales()
- * getAvailableLocales()}.
- * @return a currency formatter
- * @see java.text.NumberFormat#getCurrencyInstance(java.util.Locale)
- */
- public abstract NumberFormat getCurrencyInstance(Locale locale);
-
- /**
- * Returns a new <code>NumberFormat</code> instance which formats
- * integer values for the specified locale.
- * The returned number format is configured to
- * round floating point numbers to the nearest integer using
- * half-even rounding (see {@link java.math.RoundingMode#HALF_EVEN HALF_EVEN})
- * for formatting, and to parse only the integer part of
- * an input string (see {@link
- * java.text.NumberFormat#isParseIntegerOnly isParseIntegerOnly}).
- *
- * @param locale the desired locale
- * @exception NullPointerException if <code>locale</code> is null
- * @exception IllegalArgumentException if <code>locale</code> isn't
- * one of the locales returned from
- * {@link java.util.spi.LocaleServiceProvider#getAvailableLocales()
- * getAvailableLocales()}.
- * @return a number format for integer values
- * @see java.text.NumberFormat#getIntegerInstance(java.util.Locale)
- */
- public abstract NumberFormat getIntegerInstance(Locale locale);
-
- /**
- * Returns a new general-purpose <code>NumberFormat</code> instance for
- * the specified locale.
- *
- * @param locale the desired locale
- * @exception NullPointerException if <code>locale</code> is null
- * @exception IllegalArgumentException if <code>locale</code> isn't
- * one of the locales returned from
- * {@link java.util.spi.LocaleServiceProvider#getAvailableLocales()
- * getAvailableLocales()}.
- * @return a general-purpose number formatter
- * @see java.text.NumberFormat#getNumberInstance(java.util.Locale)
- */
- public abstract NumberFormat getNumberInstance(Locale locale);
-
- /**
- * Returns a new <code>NumberFormat</code> instance which formats
- * percentage values for the specified locale.
- *
- * @param locale the desired locale
- * @exception NullPointerException if <code>locale</code> is null
- * @exception IllegalArgumentException if <code>locale</code> isn't
- * one of the locales returned from
- * {@link java.util.spi.LocaleServiceProvider#getAvailableLocales()
- * getAvailableLocales()}.
- * @return a percent formatter
- * @see java.text.NumberFormat#getPercentInstance(java.util.Locale)
- */
- public abstract NumberFormat getPercentInstance(Locale locale);
-}
diff --git a/ojluni/src/main/java/java/text/spi/package.html b/ojluni/src/main/java/java/text/spi/package.html
deleted file mode 100644
index fa08ec1..0000000
--- a/ojluni/src/main/java/java/text/spi/package.html
+++ /dev/null
@@ -1,50 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<html>
-<head>
-<!--
-Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
-DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-
-This code is free software; you can redistribute it and/or modify it
-under the terms of the GNU General Public License version 2 only, as
-published by the Free Software Foundation. Oracle designates this
-particular file as subject to the "Classpath" exception as provided
-by Oracle in the LICENSE file that accompanied this code.
-
-This code is distributed in the hope that it will be useful, but WITHOUT
-ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-version 2 for more details (a copy is included in the LICENSE file that
-accompanied this code).
-
-You should have received a copy of the GNU General Public License version
-2 along with this work; if not, write to the Free Software Foundation,
-Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-
-Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-or visit www.oracle.com if you need additional information or have any
-questions.
--->
-
-</head>
-<body bgcolor="white">
-Service provider classes for the classes in the java.text package.
-<!--
-<h2>Package Specification</h2>
-
-##### FILL IN ANY SPECS NEEDED BY JAVA COMPATIBILITY KIT #####
-<ul>
- <li><a href="">##### REFER TO ANY FRAMEMAKER SPECIFICATION HERE #####</a>
-</ul>
-
-<h2>Related Documentation</h2>
-
-For overviews, tutorials, examples, guides, and tool documentation, please see:
-<ul>
- <li><a href="">##### REFER TO NON-SPEC DOCUMENTATION HERE #####</a>
-</ul>
--->
-
-@since 1.6
-</body>
-</html>
diff --git a/ojluni/src/main/java/java/util/Locale.java b/ojluni/src/main/java/java/util/Locale.java
index fa29e1d..fa691a6 100644
--- a/ojluni/src/main/java/java/util/Locale.java
+++ b/ojluni/src/main/java/java/util/Locale.java
@@ -46,13 +46,9 @@
import java.io.ObjectOutputStream;
import java.io.ObjectStreamField;
import java.io.Serializable;
-import java.security.AccessController;
import java.text.MessageFormat;
-import java.util.spi.LocaleNameProvider;
import libcore.icu.ICU;
-import sun.security.action.GetPropertyAction;
-import sun.util.LocaleServiceProviderPool;
import sun.util.locale.BaseLocale;
import sun.util.locale.InternalLocaleBuilder;
import sun.util.locale.LanguageTag;
@@ -61,7 +57,6 @@
import sun.util.locale.LocaleSyntaxException;
import sun.util.locale.LocaleUtils;
import sun.util.locale.ParseStatus;
-import sun.util.locale.UnicodeLocaleExtension;
/**
* A <code>Locale</code> object represents a specific geographical, political,
@@ -945,7 +940,7 @@
setDefault(Category.DISPLAY, newLocale);
setDefault(Category.FORMAT, newLocale);
defaultLocale = newLocale;
- // Android-added
+ // Android-added: Keep ICU state in sync with java.util.
ICU.setDefaultLocale(newLocale.toLanguageTag());
}
@@ -999,18 +994,15 @@
}
}
+ // Android-changed: Removed references to LocaleServiceProvider.
/**
* Returns an array of all installed locales.
- * The returned array represents the union of locales supported
- * by the Java runtime environment and by installed
- * {@link java.util.spi.LocaleServiceProvider LocaleServiceProvider}
- * implementations. It must contain at least a <code>Locale</code>
- * instance equal to {@link java.util.Locale#US Locale.US}.
*
* @return An array of installed locales.
*/
public static Locale[] getAvailableLocales() {
- return LocaleServiceProviderPool.getAllAvailableLocales();
+ // Android-changed: Removed used of LocaleServiceProviderPool. Switched to use ICU.
+ return ICU.getAvailableLocales();
}
/**
@@ -1025,7 +1017,7 @@
* @return An array of ISO 3166 two-letter country codes.
*/
public static String[] getISOCountries() {
- // Android-changed: Use ICU.
+ // Android-changed: Switched to use ICU.
return ICU.getISOCountries();
}
@@ -1046,7 +1038,7 @@
* @return Am array of ISO 639 two-letter language codes.
*/
public static String[] getISOLanguages() {
- // Android-changed: Use ICU.
+ // Android-changed: Switched to use ICU.
return ICU.getISOLanguages();
}
diff --git a/ojluni/src/main/java/java/util/ResourceBundle.java b/ojluni/src/main/java/java/util/ResourceBundle.java
index bf73b03..886ffc1 100644
--- a/ojluni/src/main/java/java/util/ResourceBundle.java
+++ b/ojluni/src/main/java/java/util/ResourceBundle.java
@@ -58,7 +58,6 @@
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.jar.JarEntry;
-import java.util.spi.ResourceBundleControlProvider;
import dalvik.system.VMStack;
import sun.reflect.CallerSensitive;
@@ -66,6 +65,7 @@
import sun.util.locale.LocaleObjectCache;
+// Android-changed: Removed reference to ResourceBundleControlProvider.
/**
*
* Resource bundles contain locale-specific objects. When your program needs a
@@ -205,17 +205,6 @@
* {@link #getBundle(String, Locale, ClassLoader, Control) getBundle}
* factory method for details.
*
- * <p><a name="modify_default_behavior">For the {@code getBundle} factory</a>
- * methods that take no {@link Control} instance, their <a
- * href="#default_behavior"> default behavior</a> of resource bundle loading
- * can be modified with <em>installed</em> {@link
- * ResourceBundleControlProvider} implementations. Any installed providers are
- * detected at the {@code ResourceBundle} class loading time. If any of the
- * providers provides a {@link Control} for the given base name, that {@link
- * Control} will be used instead of the default {@link Control}. If there is
- * more than one service provider installed for supporting the same base name,
- * the first one returned from {@link ServiceLoader} will be used.
- *
* <h3>Cache Management</h3>
*
* Resource bundle instances created by the <code>getBundle</code> factory
@@ -371,6 +360,7 @@
*/
private volatile Set<String> keySet;
+ /* Android-changed: Removed used of ResourceBundleControlProvider.
private static final List<ResourceBundleControlProvider> providers;
static {
@@ -385,6 +375,7 @@
}
providers = list;
}
+ */
/**
* Sole constructor. (For invocation by subclass constructors, typically
@@ -906,19 +897,14 @@
control);
}
+ // Android-changed: Removed references to ResourceBundleControlProvider.
/**
* Gets a resource bundle using the specified base name, locale, and class
* loader.
*
* <p>This method behaves the same as calling
* {@link #getBundle(String, Locale, ClassLoader, Control)} passing a
- * default instance of {@link Control} unless another {@link Control} is
- * provided with the {@link ResourceBundleControlProvider} SPI. Refer to the
- * description of <a href="#modify_default_behavior">modifying the default
- * behavior</a>.
- *
- * <p><a name="default_behavior">The following describes the default
- * behavior</a>.
+ * default instance of {@link Control}.
*
* <p><code>getBundle</code> uses the base name, the specified locale, and
* the default locale (obtained from {@link java.util.Locale#getDefault()
@@ -1314,14 +1300,7 @@
}
private static Control getDefaultControl(String baseName) {
- if (providers != null) {
- for (ResourceBundleControlProvider provider : providers) {
- Control control = provider.getControl(baseName);
- if (control != null) {
- return control;
- }
- }
- }
+ // Android-changed: Removed used of ResourceBundleControlProvider.
return Control.INSTANCE;
}
diff --git a/ojluni/src/main/java/java/util/spi/CurrencyNameProvider.java b/ojluni/src/main/java/java/util/spi/CurrencyNameProvider.java
deleted file mode 100644
index a0694bc..0000000
--- a/ojluni/src/main/java/java/util/spi/CurrencyNameProvider.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package java.util.spi;
-
-import java.util.Arrays;
-import java.util.Currency;
-import java.util.List;
-import java.util.Locale;
-
-/**
- * An abstract class for service providers that
- * provide localized currency symbols and display names for the
- * {@link java.util.Currency Currency} class.
- * Note that currency symbols are considered names when determining
- * behaviors described in the
- * {@link java.util.spi.LocaleServiceProvider LocaleServiceProvider}
- * specification.
- *
- * @since 1.6
- */
-public abstract class CurrencyNameProvider extends LocaleServiceProvider {
-
- /**
- * Sole constructor. (For invocation by subclass constructors, typically
- * implicit.)
- */
- protected CurrencyNameProvider() {
- }
-
- /**
- * Gets the symbol of the given currency code for the specified locale.
- * For example, for "USD" (US Dollar), the symbol is "$" if the specified
- * locale is the US, while for other locales it may be "US$". If no
- * symbol can be determined, null should be returned.
- *
- * @param currencyCode the ISO 4217 currency code, which
- * consists of three upper-case letters between 'A' (U+0041) and
- * 'Z' (U+005A)
- * @param locale the desired locale
- * @return the symbol of the given currency code for the specified locale, or null if
- * the symbol is not available for the locale
- * @exception NullPointerException if <code>currencyCode</code> or
- * <code>locale</code> is null
- * @exception IllegalArgumentException if <code>currencyCode</code> is not in
- * the form of three upper-case letters, or <code>locale</code> isn't
- * one of the locales returned from
- * {@link java.util.spi.LocaleServiceProvider#getAvailableLocales()
- * getAvailableLocales()}.
- * @see java.util.Currency#getSymbol(java.util.Locale)
- */
- public abstract String getSymbol(String currencyCode, Locale locale);
-
- /**
- * Returns a name for the currency that is appropriate for display to the
- * user. The default implementation returns null.
- *
- * @param currencyCode the ISO 4217 currency code, which
- * consists of three upper-case letters between 'A' (U+0041) and
- * 'Z' (U+005A)
- * @param locale the desired locale
- * @return the name for the currency that is appropriate for display to the
- * user, or null if the name is not available for the locale
- * @exception IllegalArgumentException if <code>currencyCode</code> is not in
- * the form of three upper-case letters, or <code>locale</code> isn't
- * one of the locales returned from
- * {@link java.util.spi.LocaleServiceProvider#getAvailableLocales()
- * getAvailableLocales()}.
- * @exception NullPointerException if <code>currencyCode</code> or
- * <code>locale</code> is <code>null</code>
- * @since 1.7
- */
- public String getDisplayName(String currencyCode, Locale locale) {
- if (currencyCode == null || locale == null) {
- throw new NullPointerException();
- }
-
- // Check whether the currencyCode is valid
- char[] charray = currencyCode.toCharArray();
- if (charray.length != 3) {
- throw new IllegalArgumentException("The currencyCode is not in the form of three upper-case letters.");
- }
- for (char c : charray) {
- if (c < 'A' || c > 'Z') {
- throw new IllegalArgumentException("The currencyCode is not in the form of three upper-case letters.");
- }
- }
-
- // Check whether the locale is valid
- List<Locale> avail = Arrays.asList(getAvailableLocales());
- if (!avail.contains(locale)) {
- throw new IllegalArgumentException("The locale is not available");
- }
-
- return null;
- }
-}
diff --git a/ojluni/src/main/java/java/util/spi/LocaleNameProvider.java b/ojluni/src/main/java/java/util/spi/LocaleNameProvider.java
deleted file mode 100644
index 499aa0d..0000000
--- a/ojluni/src/main/java/java/util/spi/LocaleNameProvider.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package java.util.spi;
-
-import java.util.Locale;
-
-/**
- * An abstract class for service providers that
- * provide localized names for the
- * {@link java.util.Locale Locale} class.
- *
- * @since 1.6
- */
-public abstract class LocaleNameProvider extends LocaleServiceProvider {
-
- /**
- * Sole constructor. (For invocation by subclass constructors, typically
- * implicit.)
- */
- protected LocaleNameProvider() {
- }
-
- /**
- * Returns a localized name for the given <a href="http://www.rfc-editor.org/rfc/bcp/bcp47.txt">
- * IETF BCP47</a> language code and the given locale that is appropriate for
- * display to the user.
- * For example, if <code>languageCode</code> is "fr" and <code>locale</code>
- * is en_US, getDisplayLanguage() will return "French"; if <code>languageCode</code>
- * is "en" and <code>locale</code> is fr_FR, getDisplayLanguage() will return "anglais".
- * If the name returned cannot be localized according to <code>locale</code>,
- * (say, the provider does not have a Japanese name for Croatian),
- * this method returns null.
- * @param languageCode the language code string in the form of two to eight
- * lower-case letters between 'a' (U+0061) and 'z' (U+007A)
- * @param locale the desired locale
- * @return the name of the given language code for the specified locale, or null if it's not
- * available.
- * @exception NullPointerException if <code>languageCode</code> or <code>locale</code> is null
- * @exception IllegalArgumentException if <code>languageCode</code> is not in the form of
- * two or three lower-case letters, or <code>locale</code> isn't
- * one of the locales returned from
- * {@link java.util.spi.LocaleServiceProvider#getAvailableLocales()
- * getAvailableLocales()}.
- * @see java.util.Locale#getDisplayLanguage(java.util.Locale)
- */
- public abstract String getDisplayLanguage(String languageCode, Locale locale);
-
- /**
- * Returns a localized name for the given <a href="http://www.rfc-editor.org/rfc/bcp/bcp47.txt">
- * IETF BCP47</a> script code and the given locale that is appropriate for
- * display to the user.
- * For example, if <code>scriptCode</code> is "Latn" and <code>locale</code>
- * is en_US, getDisplayScript() will return "Latin"; if <code>scriptCode</code>
- * is "Cyrl" and <code>locale</code> is fr_FR, getDisplayScript() will return "cyrillique".
- * If the name returned cannot be localized according to <code>locale</code>,
- * (say, the provider does not have a Japanese name for Cyrillic),
- * this method returns null. The default implementation returns null.
- * @param scriptCode the four letter script code string in the form of title-case
- * letters (the first letter is upper-case character between 'A' (U+0041) and
- * 'Z' (U+005A) followed by three lower-case character between 'a' (U+0061)
- * and 'z' (U+007A)).
- * @param locale the desired locale
- * @return the name of the given script code for the specified locale, or null if it's not
- * available.
- * @exception NullPointerException if <code>scriptCode</code> or <code>locale</code> is null
- * @exception IllegalArgumentException if <code>scriptCode</code> is not in the form of
- * four title case letters, or <code>locale</code> isn't
- * one of the locales returned from
- * {@link java.util.spi.LocaleServiceProvider#getAvailableLocales()
- * getAvailableLocales()}.
- * @see java.util.Locale#getDisplayScript(java.util.Locale)
- * @since 1.7
- */
- public String getDisplayScript(String scriptCode, Locale locale) {
- return null;
- }
-
- /**
- * Returns a localized name for the given <a href="http://www.rfc-editor.org/rfc/bcp/bcp47.txt">
- * IETF BCP47</a> region code (either ISO 3166 country code or UN M.49 area
- * codes) and the given locale that is appropriate for display to the user.
- * For example, if <code>countryCode</code> is "FR" and <code>locale</code>
- * is en_US, getDisplayCountry() will return "France"; if <code>countryCode</code>
- * is "US" and <code>locale</code> is fr_FR, getDisplayCountry() will return "Etats-Unis".
- * If the name returned cannot be localized according to <code>locale</code>,
- * (say, the provider does not have a Japanese name for Croatia),
- * this method returns null.
- * @param countryCode the country(region) code string in the form of two
- * upper-case letters between 'A' (U+0041) and 'Z' (U+005A) or the UN M.49 area code
- * in the form of three digit letters between '0' (U+0030) and '9' (U+0039).
- * @param locale the desired locale
- * @return the name of the given country code for the specified locale, or null if it's not
- * available.
- * @exception NullPointerException if <code>countryCode</code> or <code>locale</code> is null
- * @exception IllegalArgumentException if <code>countryCode</code> is not in the form of
- * two upper-case letters or three digit letters, or <code>locale</code> isn't
- * one of the locales returned from
- * {@link java.util.spi.LocaleServiceProvider#getAvailableLocales()
- * getAvailableLocales()}.
- * @see java.util.Locale#getDisplayCountry(java.util.Locale)
- */
- public abstract String getDisplayCountry(String countryCode, Locale locale);
-
- /**
- * Returns a localized name for the given variant code and the given locale that
- * is appropriate for display to the user.
- * If the name returned cannot be localized according to <code>locale</code>,
- * this method returns null.
- * @param variant the variant string
- * @param locale the desired locale
- * @return the name of the given variant string for the specified locale, or null if it's not
- * available.
- * @exception NullPointerException if <code>variant</code> or <code>locale</code> is null
- * @exception IllegalArgumentException if <code>locale</code> isn't
- * one of the locales returned from
- * {@link java.util.spi.LocaleServiceProvider#getAvailableLocales()
- * getAvailableLocales()}.
- * @see java.util.Locale#getDisplayVariant(java.util.Locale)
- */
- public abstract String getDisplayVariant(String variant, Locale locale);
-}
diff --git a/ojluni/src/main/java/java/util/spi/LocaleServiceProvider.java b/ojluni/src/main/java/java/util/spi/LocaleServiceProvider.java
deleted file mode 100644
index f2d89c7..0000000
--- a/ojluni/src/main/java/java/util/spi/LocaleServiceProvider.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package java.util.spi;
-
-import java.util.Locale;
-
-/**
- * <p>
- * This is the super class of all the locale sensitive service provider
- * interfaces (SPIs).
- * <p>
- * Locale sensitive service provider interfaces are interfaces that
- * correspond to locale sensitive classes in the <code>java.text</code>
- * and <code>java.util</code> packages. The interfaces enable the
- * construction of locale sensitive objects and the retrieval of
- * localized names for these packages. Locale sensitive factory methods
- * and methods for name retrieval in the <code>java.text</code> and
- * <code>java.util</code> packages use implementations of the provider
- * interfaces to offer support for locales beyond the set of locales
- * supported by the Java runtime environment itself.
- * <p>
- * <h4>Packaging of Locale Sensitive Service Provider Implementations</h4>
- * Implementations of these locale sensitive services are packaged using the
- * <a href="{@docRoot}openjdk-redirect.html?v=8&path=/technotes/guides/extensions/index.html">Java Extension Mechanism</a>
- * as installed extensions. A provider identifies itself with a
- * provider-configuration file in the resource directory META-INF/services,
- * using the fully qualified provider interface class name as the file name.
- * The file should contain a list of fully-qualified concrete provider class names,
- * one per line. A line is terminated by any one of a line feed ('\n'), a carriage
- * return ('\r'), or a carriage return followed immediately by a line feed. Space
- * and tab characters surrounding each name, as well as blank lines, are ignored.
- * The comment character is '#' ('\u0023'); on each line all characters following
- * the first comment character are ignored. The file must be encoded in UTF-8.
- * <p>
- * If a particular concrete provider class is named in more than one configuration
- * file, or is named in the same configuration file more than once, then the
- * duplicates will be ignored. The configuration file naming a particular provider
- * need not be in the same jar file or other distribution unit as the provider itself.
- * The provider must be accessible from the same class loader that was initially
- * queried to locate the configuration file; this is not necessarily the class loader
- * that loaded the file.
- * <p>
- * For example, an implementation of the
- * {@link java.text.spi.DateFormatProvider DateFormatProvider} class should
- * take the form of a jar file which contains the file:
- * <pre>
- * META-INF/services/java.text.spi.DateFormatProvider
- * </pre>
- * And the file <code>java.text.spi.DateFormatProvider</code> should have
- * a line such as:
- * <pre>
- * <code>com.foo.DateFormatProviderImpl</code>
- * </pre>
- * which is the fully qualified class name of the class implementing
- * <code>DateFormatProvider</code>.
- * <h4>Invocation of Locale Sensitive Services</h4>
- * <p>
- * Locale sensitive factory methods and methods for name retrieval in the
- * <code>java.text</code> and <code>java.util</code> packages invoke
- * service provider methods when needed to support the requested locale.
- * The methods first check whether the Java runtime environment itself
- * supports the requested locale, and use its support if available.
- * Otherwise, they call the <code>getAvailableLocales()</code> methods of
- * installed providers for the appropriate interface to find one that
- * supports the requested locale. If such a provider is found, its other
- * methods are called to obtain the requested object or name. When checking
- * whether a locale is supported, the locale's extensions are ignored.
- * If neither the Java runtime environment itself nor an installed provider
- * supports the requested locale, the methods go through a list of candidate
- * locales and repeat the availability check for each until a match is found.
- * The algorithm used for creating a list of candidate locales is same as
- * the one used by <code>ResourceBunlde</code> by default (see
- * {@link java.util.ResourceBundle.Control#getCandidateLocales getCandidateLocales}
- * for the details). Even if a locale is resolved from the candidate list,
- * methods that return requested objects or names are invoked with the original
- * requested locale including extensions. The Java runtime environment must
- * support the root locale for all locale sensitive services in order to
- * guarantee that this process terminates.
- * <p>
- * Providers of names (but not providers of other objects) are allowed to
- * return null for some name requests even for locales that they claim to
- * support by including them in their return value for
- * <code>getAvailableLocales</code>. Similarly, the Java runtime
- * environment itself may not have all names for all locales that it
- * supports. This is because the sets of objects for which names are
- * requested can be large and vary over time, so that it's not always
- * feasible to cover them completely. If the Java runtime environment or a
- * provider returns null instead of a name, the lookup will proceed as
- * described above as if the locale was not supported.
- *
- * @since 1.6
- */
-public abstract class LocaleServiceProvider {
-
- /**
- * Sole constructor. (For invocation by subclass constructors, typically
- * implicit.)
- */
- protected LocaleServiceProvider() {
- }
-
- /**
- * Returns an array of all locales for which this locale service provider
- * can provide localized objects or names.
- * <p>
- * <b>Note:</b> Extensions in a <code>Locale</code> are ignored during
- * service provider lookup. So the array returned by this method should
- * not include two or more <code>Locale</code> objects only differing in
- * their extensions.
- *
- * @return An array of all locales for which this locale service provider
- * can provide localized objects or names.
- */
- public abstract Locale[] getAvailableLocales();
-}
diff --git a/ojluni/src/main/java/java/util/spi/ResourceBundleControlProvider.java b/ojluni/src/main/java/java/util/spi/ResourceBundleControlProvider.java
deleted file mode 100644
index e731f0f..0000000
--- a/ojluni/src/main/java/java/util/spi/ResourceBundleControlProvider.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package java.util.spi;
-
-import java.util.ResourceBundle;
-
-/**
- * An interface for service providers that provide implementations of {@link
- * java.util.ResourceBundle.Control}. The <a
- * href="../ResourceBundle.html#default_behavior">default resource bundle loading
- * behavior</a> of the {@code ResourceBundle.getBundle} factory methods that take
- * no {@link java.util.ResourceBundle.Control} instance can be modified with {@code
- * ResourceBundleControlProvider} implementations.
- *
- * <p>Provider implementations must be packaged using the <a
- * href="{@docRoot}openjdk-redirect.html?v=8&path=/technotes/guides/extensions/index.html">Java Extension
- * Mechanism</a> as installed extensions. Refer to {@link java.util.ServiceLoader}
- * for the extension packaging. Any installed {@code
- * ResourceBundleControlProvider} implementations are loaded using {@link
- * java.util.ServiceLoader} at the {@code ResourceBundle} class loading time.
- *
- * @author Masayoshi Okutsu
- * @since 1.8
- * @see ResourceBundle#getBundle(String, java.util.Locale, ClassLoader, ResourceBundle.Control)
- * ResourceBundle.getBundle
- * @see java.util.ServiceLoader#loadInstalled(Class)
- */
-public interface ResourceBundleControlProvider {
- /**
- * Returns a {@code ResourceBundle.Control} instance that is used
- * to handle resource bundle loading for the given {@code
- * baseName}. This method must return {@code null} if the given
- * {@code baseName} isn't handled by this provider.
- *
- * @param baseName the base name of the resource bundle
- * @return a {@code ResourceBundle.Control} instance,
- * or {@code null} if the given {@code baseName} is not
- * applicable to this provider.
- * @throws NullPointerException if {@code baseName} is {@code null}
- */
- public ResourceBundle.Control getControl(String baseName);
-}
diff --git a/ojluni/src/main/java/java/util/spi/TimeZoneNameProvider.java b/ojluni/src/main/java/java/util/spi/TimeZoneNameProvider.java
deleted file mode 100644
index 730b507..0000000
--- a/ojluni/src/main/java/java/util/spi/TimeZoneNameProvider.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package java.util.spi;
-
-import java.util.Locale;
-
-/**
- * An abstract class for service providers that
- * provide localized time zone names for the
- * {@link java.util.TimeZone TimeZone} class.
- * The localized time zone names available from the implementations of
- * this class are also the source for the
- * {@link java.text.DateFormatSymbols#getZoneStrings()
- * DateFormatSymbols.getZoneStrings()} method.
- *
- * @since 1.6
- */
-public abstract class TimeZoneNameProvider extends LocaleServiceProvider {
-
- /**
- * Sole constructor. (For invocation by subclass constructors, typically
- * implicit.)
- */
- protected TimeZoneNameProvider() {
- }
-
- /**
- * Returns a name for the given time zone ID that's suitable for
- * presentation to the user in the specified locale. The given time
- * zone ID is "GMT" or one of the names defined using "Zone" entries
- * in the "tz database", a public domain time zone database at
- * <a href="ftp://elsie.nci.nih.gov/pub/">ftp://elsie.nci.nih.gov/pub/</a>.
- * The data of this database is contained in a file whose name starts with
- * "tzdata", and the specification of the data format is part of the zic.8
- * man page, which is contained in a file whose name starts with "tzcode".
- * <p>
- * If <code>daylight</code> is true, the method should return a name
- * appropriate for daylight saving time even if the specified time zone
- * has not observed daylight saving time in the past.
- *
- * @param ID a time zone ID string
- * @param daylight if true, return the daylight saving name.
- * @param style either {@link java.util.TimeZone#LONG TimeZone.LONG} or
- * {@link java.util.TimeZone#SHORT TimeZone.SHORT}
- * @param locale the desired locale
- * @return the human-readable name of the given time zone in the
- * given locale, or null if it's not available.
- * @exception IllegalArgumentException if <code>style</code> is invalid,
- * or <code>locale</code> isn't one of the locales returned from
- * {@link java.util.spi.LocaleServiceProvider#getAvailableLocales()
- * getAvailableLocales()}.
- * @exception NullPointerException if <code>ID</code> or <code>locale</code>
- * is null
- * @see java.util.TimeZone#getDisplayName(boolean, int, java.util.Locale)
- */
- public abstract String getDisplayName(String ID, boolean daylight, int style, Locale locale);
-}
diff --git a/ojluni/src/main/java/java/util/spi/package.html b/ojluni/src/main/java/java/util/spi/package.html
deleted file mode 100644
index ce49fb2..0000000
--- a/ojluni/src/main/java/java/util/spi/package.html
+++ /dev/null
@@ -1,50 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<html>
-<head>
-<!--
-Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
-DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-
-This code is free software; you can redistribute it and/or modify it
-under the terms of the GNU General Public License version 2 only, as
-published by the Free Software Foundation. Oracle designates this
-particular file as subject to the "Classpath" exception as provided
-by Oracle in the LICENSE file that accompanied this code.
-
-This code is distributed in the hope that it will be useful, but WITHOUT
-ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-version 2 for more details (a copy is included in the LICENSE file that
-accompanied this code).
-
-You should have received a copy of the GNU General Public License version
-2 along with this work; if not, write to the Free Software Foundation,
-Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-
-Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-or visit www.oracle.com if you need additional information or have any
-questions.
--->
-
-</head>
-<body bgcolor="white">
-Service provider classes for the classes in the java.util package.
-<!--
-<h2>Package Specification</h2>
-
-##### FILL IN ANY SPECS NEEDED BY JAVA COMPATIBILITY KIT #####
-<ul>
- <li><a href="">##### REFER TO ANY FRAMEMAKER SPECIFICATION HERE #####</a>
-</ul>
-
-<h2>Related Documentation</h2>
-
-For overviews, tutorials, examples, guides, and tool documentation, please see:
-<ul>
- <li><a href="">##### REFER TO NON-SPEC DOCUMENTATION HERE #####</a>
-</ul>
--->
-
-@since 1.6
-</body>
-</html>
diff --git a/ojluni/src/main/java/sun/util/LocaleServiceProviderPool.java b/ojluni/src/main/java/sun/util/LocaleServiceProviderPool.java
deleted file mode 100644
index cbab860..0000000
--- a/ojluni/src/main/java/sun/util/LocaleServiceProviderPool.java
+++ /dev/null
@@ -1,547 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.util;
-
-import java.security.AccessController;
-import java.security.PrivilegedActionException;
-import java.security.PrivilegedExceptionAction;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.IllformedLocaleException;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Locale;
-import java.util.Locale.Builder;
-import java.util.Map;
-import java.util.ResourceBundle.Control;
-import java.util.ServiceLoader;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-import java.util.spi.LocaleServiceProvider;
-import libcore.icu.ICU;
-
-import sun.util.logging.PlatformLogger;
-import sun.util.resources.OpenListResourceBundle;
-
-/**
- * An instance of this class holds a set of the third party implementations of a particular
- * locale sensitive service, such as {@link java.util.spi.LocaleNameProvider}.
- *
- */
-public final class LocaleServiceProviderPool {
-
- /**
- * A Map that holds singleton instances of this class. Each instance holds a
- * set of provider implementations of a particular locale sensitive service.
- */
- private static ConcurrentMap<Class<? extends LocaleServiceProvider>, LocaleServiceProviderPool> poolOfPools =
- new ConcurrentHashMap<>();
-
- /**
- * A Set containing locale service providers that implement the
- * specified provider SPI
- */
- private Set<LocaleServiceProvider> providers =
- new LinkedHashSet<LocaleServiceProvider>();
-
- /**
- * A Map that retains Locale->provider mapping
- */
- private Map<Locale, LocaleServiceProvider> providersCache =
- new ConcurrentHashMap<Locale, LocaleServiceProvider>();
-
- /**
- * Available locales for this locale sensitive service. This also contains
- * JRE's available locales
- */
- private Set<Locale> availableLocales = null;
-
- /**
- * Available locales within this JRE. Currently this is declared as
- * static. This could be non-static later, so that they could have
- * different sets for each locale sensitive services.
- */
- private static volatile List<Locale> availableJRELocales = null;
-
- /**
- * Provider locales for this locale sensitive service.
- */
- private Set<Locale> providerLocales = null;
-
- /**
- * Special locale for ja_JP with Japanese calendar
- */
- private static Locale locale_ja_JP_JP = new Locale("ja", "JP", "JP");
-
- /**
- * Special locale for th_TH with Thai numbering system
- */
- private static Locale locale_th_TH_TH = new Locale("th", "TH", "TH");
-
- /**
- * A factory method that returns a singleton instance
- */
- public static LocaleServiceProviderPool getPool(Class<? extends LocaleServiceProvider> providerClass) {
- LocaleServiceProviderPool pool = poolOfPools.get(providerClass);
- if (pool == null) {
- LocaleServiceProviderPool newPool =
- new LocaleServiceProviderPool(providerClass);
- pool = poolOfPools.putIfAbsent(providerClass, newPool);
- if (pool == null) {
- pool = newPool;
- }
- }
-
- return pool;
- }
-
- /**
- * The sole constructor.
- *
- * @param c class of the locale sensitive service
- */
- private LocaleServiceProviderPool (final Class<? extends LocaleServiceProvider> c) {
- try {
- AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
- public Object run() {
- for (LocaleServiceProvider provider : ServiceLoader.loadInstalled(c)) {
- providers.add(provider);
- }
- return null;
- }
- });
- } catch (PrivilegedActionException e) {
- config(e.toString());
- }
- }
-
- private static void config(String message) {
- PlatformLogger logger = PlatformLogger.getLogger("sun.util.LocaleServiceProviderPool");
- logger.config(message);
- }
-
- /**
- * Lazy loaded set of available locales.
- * Loading all locales is a very long operation.
- *
- * We know "providerClasses" contains classes that extends LocaleServiceProvider,
- * but generic array creation is not allowed, thus the "unchecked" warning
- * is suppressed here.
- */
- private static class AllAvailableLocales {
- /**
- * Available locales for all locale sensitive services.
- * This also contains JRE's available locales
- */
- static final Locale[] allAvailableLocales;
-
- static {
- @SuppressWarnings("unchecked")
- Class<LocaleServiceProvider>[] providerClasses =
- (Class<LocaleServiceProvider>[]) new Class<?>[] {
- java.text.spi.BreakIteratorProvider.class,
- java.text.spi.CollatorProvider.class,
- java.text.spi.DateFormatProvider.class,
- java.text.spi.DateFormatSymbolsProvider.class,
- java.text.spi.DecimalFormatSymbolsProvider.class,
- java.text.spi.NumberFormatProvider.class,
- java.util.spi.CurrencyNameProvider.class,
- java.util.spi.LocaleNameProvider.class,
- java.util.spi.TimeZoneNameProvider.class,
- };
-
- // Normalize locales for look up
- Locale[] allLocales = ICU.getAvailableLocales();
- Set<Locale> all = new HashSet<Locale>(allLocales.length);
- for (Locale locale : allLocales) {
- all.add(getLookupLocale(locale));
- }
-
- for (Class<LocaleServiceProvider> providerClass : providerClasses) {
- LocaleServiceProviderPool pool =
- LocaleServiceProviderPool.getPool(providerClass);
- all.addAll(pool.getProviderLocales());
- }
-
- allAvailableLocales = all.toArray(new Locale[0]);
- }
- }
-
- /**
- * Returns an array of available locales for all the provider classes.
- * This array is a merged array of all the locales that are provided by each
- * provider, including the JRE.
- *
- * @return an array of the available locales for all provider classes
- */
- public static Locale[] getAllAvailableLocales() {
- return AllAvailableLocales.allAvailableLocales.clone();
- }
-
- /**
- * Returns an array of available locales. This array is a
- * merged array of all the locales that are provided by each
- * provider, including the JRE.
- *
- * @return an array of the available locales
- */
- public synchronized Locale[] getAvailableLocales() {
- if (availableLocales == null) {
- availableLocales = new HashSet<Locale>(getJRELocales());
- if (hasProviders()) {
- availableLocales.addAll(getProviderLocales());
- }
- }
- Locale[] tmp = new Locale[availableLocales.size()];
- availableLocales.toArray(tmp);
- return tmp;
- }
-
- /**
- * Returns an array of available locales (already normalized
- * for service lookup) from providers.
- * Note that this method does not return a defensive copy.
- *
- * @return list of the provider locales
- */
- private synchronized Set<Locale> getProviderLocales() {
- if (providerLocales == null) {
- providerLocales = new HashSet<Locale>();
- if (hasProviders()) {
- for (LocaleServiceProvider lsp : providers) {
- Locale[] locales = lsp.getAvailableLocales();
- for (Locale locale: locales) {
- providerLocales.add(getLookupLocale(locale));
- }
- }
- }
- }
- return providerLocales;
- }
-
- /**
- * Returns whether any provider for this locale sensitive
- * service is available or not.
- *
- * @return true if any provider is available
- */
- public boolean hasProviders() {
- return !providers.isEmpty();
- }
-
- /**
- * Returns an array of available locales (already normalized for
- * service lookup) supported by the JRE.
- * Note that this method does not return a defensive copy.
- *
- * @return list of the available JRE locales
- */
- private List<Locale> getJRELocales() {
- if (availableJRELocales == null) {
- synchronized (LocaleServiceProviderPool.class) {
- if (availableJRELocales == null) {
- Locale[] allLocales = ICU.getAvailableLocales();
- List<Locale> tmpList = new ArrayList<>(allLocales.length);
- for (Locale locale : allLocales) {
- tmpList.add(getLookupLocale(locale));
- }
- availableJRELocales = tmpList;
- }
- }
- }
- return availableJRELocales;
- }
-
- /**
- * Returns whether the given locale is supported by the JRE.
- *
- * @param locale the locale to test.
- * @return true, if the locale is supported by the JRE. false
- * otherwise.
- */
- private boolean isJRESupported(Locale locale) {
- List<Locale> locales = getJRELocales();
- return locales.contains(getLookupLocale(locale));
- }
-
- /**
- * Returns the provider's localized object for the specified
- * locale.
- *
- * @param getter an object on which getObject() method
- * is called to obtain the provider's instance.
- * @param locale the given locale that is used as the starting one
- * @param params provider specific parameters
- * @return provider's instance, or null.
- */
- public <P, S> S getLocalizedObject(LocalizedObjectGetter<P, S> getter,
- Locale locale,
- Object... params) {
- return getLocalizedObjectImpl(getter, locale, true, null, null, null, params);
- }
-
- /**
- * Returns the provider's localized name for the specified
- * locale.
- *
- * @param getter an object on which getObject() method
- * is called to obtain the provider's instance.
- * @param locale the given locale that is used as the starting one
- * @param bundle JRE resource bundle that contains
- * the localized names, or null for localized objects.
- * @param key the key string if bundle is supplied, otherwise null.
- * @param params provider specific parameters
- * @return provider's instance, or null.
- */
- public <P, S> S getLocalizedObject(LocalizedObjectGetter<P, S> getter,
- Locale locale,
- OpenListResourceBundle bundle,
- String key,
- Object... params) {
- return getLocalizedObjectImpl(getter, locale, false, null, bundle, key, params);
- }
-
- /**
- * Returns the provider's localized name for the specified
- * locale.
- *
- * @param getter an object on which getObject() method
- * is called to obtain the provider's instance.
- * @param locale the given locale that is used as the starting one
- * @param bundleKey JRE specific bundle key. e.g., "USD" is for currency
- symbol and "usd" is for currency display name in the JRE bundle.
- * @param bundle JRE resource bundle that contains
- * the localized names, or null for localized objects.
- * @param key the key string if bundle is supplied, otherwise null.
- * @param params provider specific parameters
- * @return provider's instance, or null.
- */
- public <P, S> S getLocalizedObject(LocalizedObjectGetter<P, S> getter,
- Locale locale,
- String bundleKey,
- OpenListResourceBundle bundle,
- String key,
- Object... params) {
- return getLocalizedObjectImpl(getter, locale, false, bundleKey, bundle, key, params);
- }
-
- private <P, S> S getLocalizedObjectImpl(LocalizedObjectGetter<P, S> getter,
- Locale locale,
- boolean isObjectProvider,
- String bundleKey,
- OpenListResourceBundle bundle,
- String key,
- Object... params) {
- if (hasProviders()) {
- if (bundleKey == null) {
- bundleKey = key;
- }
- Locale bundleLocale = (bundle != null ? bundle.getLocale() : null);
- List<Locale> lookupLocales = getLookupLocales(locale);
- S providersObj = null;
-
- // check whether a provider has an implementation that's closer
- // to the requested locale than the bundle we've found (for
- // localized names), or Java runtime's supported locale
- // (for localized objects)
- Set<Locale> provLoc = getProviderLocales();
- for (int i = 0; i < lookupLocales.size(); i++) {
- Locale current = lookupLocales.get(i);
- if (bundleLocale != null) {
- if (current.equals(bundleLocale)) {
- break;
- }
- } else {
- if (isJRESupported(current)) {
- break;
- }
- }
- if (provLoc.contains(current)) {
- // It is safe to assume that findProvider() returns the instance of type P.
- @SuppressWarnings("unchecked")
- P lsp = (P)findProvider(current);
- if (lsp != null) {
- providersObj = getter.getObject(lsp, locale, key, params);
- if (providersObj != null) {
- return providersObj;
- } else if (isObjectProvider) {
- config(
- "A locale sensitive service provider returned null for a localized objects, which should not happen. provider: " + lsp + " locale: " + locale);
- }
- }
- }
- }
-
- // look up the JRE bundle and its parent chain. Only
- // providers for localized names are checked hereafter.
- while (bundle != null) {
- bundleLocale = bundle.getLocale();
-
- if (bundle.handleGetKeys().contains(bundleKey)) {
- // JRE has it.
- return null;
- } else {
- // It is safe to assume that findProvider() returns the instance of type P.
- @SuppressWarnings("unchecked")
- P lsp = (P)findProvider(bundleLocale);
- if (lsp != null) {
- providersObj = getter.getObject(lsp, locale, key, params);
- if (providersObj != null) {
- return providersObj;
- }
- }
- }
-
- // try parent bundle
- bundle = bundle.getParent();
- }
- }
-
- // not found.
- return null;
- }
-
- /**
- * Returns a locale service provider instance that supports
- * the specified locale.
- *
- * @param locale the given locale
- * @return the provider, or null if there is
- * no provider available.
- */
- private LocaleServiceProvider findProvider(Locale locale) {
- if (!hasProviders()) {
- return null;
- }
-
- if (providersCache.containsKey(locale)) {
- LocaleServiceProvider provider = providersCache.get(locale);
- if (provider != NullProvider.INSTANCE) {
- return provider;
- }
- } else {
- for (LocaleServiceProvider lsp : providers) {
- Locale[] locales = lsp.getAvailableLocales();
- for (Locale available: locales) {
- // normalize
- available = getLookupLocale(available);
- if (locale.equals(available)) {
- LocaleServiceProvider providerInCache =
- providersCache.put(locale, lsp);
- return (providerInCache != null ?
- providerInCache :
- lsp);
- }
- }
- }
- providersCache.put(locale, NullProvider.INSTANCE);
- }
- return null;
- }
-
- /**
- * Returns a list of candidate locales for service look up.
- * @param locale the input locale
- * @return the list of candiate locales for the given locale
- */
- private static List<Locale> getLookupLocales(Locale locale) {
- // Note: We currently use the default implementation of
- // ResourceBundle.Control.getCandidateLocales. The result
- // returned by getCandidateLocales are already normalized
- // (no extensions) for service look up.
- List<Locale> lookupLocales = new Control(){}.getCandidateLocales("", locale);
- return lookupLocales;
- }
-
- /**
- * Returns an instance of Locale used for service look up.
- * The result Locale has no extensions except for ja_JP_JP
- * and th_TH_TH
- *
- * @param locale the locale
- * @return the locale used for service look up
- */
- private static Locale getLookupLocale(Locale locale) {
- Locale lookupLocale = locale;
- Set<Character> extensions = locale.getExtensionKeys();
- if (!extensions.isEmpty()
- && !locale.equals(locale_ja_JP_JP)
- && !locale.equals(locale_th_TH_TH)) {
- // remove extensions
- Builder locbld = new Builder();
- try {
- locbld.setLocale(locale);
- locbld.clearExtensions();
- lookupLocale = locbld.build();
- } catch (IllformedLocaleException e) {
- // A Locale with non-empty extensions
- // should have well-formed fields except
- // for ja_JP_JP and th_TH_TH. Therefore,
- // it should never enter in this catch clause.
- config("A locale(" + locale + ") has non-empty extensions, but has illformed fields.");
-
- // Fallback - script field will be lost.
- lookupLocale = new Locale(locale.getLanguage(), locale.getCountry(), locale.getVariant());
- }
- }
- return lookupLocale;
- }
-
- /**
- * A dummy locale service provider that indicates there is no
- * provider available
- */
- private static class NullProvider extends LocaleServiceProvider {
- private static final NullProvider INSTANCE = new NullProvider();
-
- public Locale[] getAvailableLocales() {
- throw new RuntimeException("Should not get called.");
- }
- }
-
- /**
- * An interface to get a localized object for each locale sensitve
- * service class.
- */
- public interface LocalizedObjectGetter<P, S> {
- /**
- * Returns an object from the provider
- *
- * @param lsp the provider
- * @param locale the locale
- * @param key key string to localize, or null if the provider is not
- * a name provider
- * @param params provider specific params
- * @return localized object from the provider
- */
- public S getObject(P lsp,
- Locale locale,
- String key,
- Object... params);
- }
-}
diff --git a/openjdk_java_files.mk b/openjdk_java_files.mk
index 646f7ce..6a1c3e6 100644
--- a/openjdk_java_files.mk
+++ b/openjdk_java_files.mk
@@ -1172,17 +1172,6 @@
ojluni/src/main/java/java/lang/invoke/MethodTypeForm.java \
ojluni/src/main/java/java/lang/invoke/Stable.java \
ojluni/src/main/java/java/lang/invoke/WrongMethodTypeException.java \
- ojluni/src/main/java/java/text/spi/BreakIteratorProvider.java \
- ojluni/src/main/java/java/text/spi/CollatorProvider.java \
- ojluni/src/main/java/java/text/spi/DateFormatProvider.java \
- ojluni/src/main/java/java/text/spi/DateFormatSymbolsProvider.java \
- ojluni/src/main/java/java/text/spi/DecimalFormatSymbolsProvider.java \
- ojluni/src/main/java/java/text/spi/NumberFormatProvider.java \
- ojluni/src/main/java/java/util/spi/CurrencyNameProvider.java \
- ojluni/src/main/java/java/util/spi/LocaleNameProvider.java \
- ojluni/src/main/java/java/util/spi/LocaleServiceProvider.java \
- ojluni/src/main/java/java/util/spi/ResourceBundleControlProvider.java \
- ojluni/src/main/java/java/util/spi/TimeZoneNameProvider.java \
ojluni/src/main/java/jdk/net/ExtendedSocketOptions.java \
ojluni/src/main/java/jdk/net/NetworkPermission.java \
ojluni/src/main/java/jdk/net/SocketFlow.java \
@@ -1601,7 +1590,6 @@
ojluni/src/main/java/sun/util/locale/LocaleSyntaxException.java \
ojluni/src/main/java/sun/util/locale/LocaleUtils.java \
ojluni/src/main/java/sun/util/locale/ParseStatus.java \
- ojluni/src/main/java/sun/util/LocaleServiceProviderPool.java \
ojluni/src/main/java/sun/util/locale/StringTokenIterator.java \
ojluni/src/main/java/sun/util/locale/UnicodeLocaleExtension.java \
ojluni/src/main/java/sun/util/logging/LoggingProxy.java \