src/java.base/share/classes/sun/util/locale/provider/DateFormatProviderImpl.java
Print this page
rev 10528 : 8038436: Re-examine the mechanism to determine available localedata and cldrdata
Reviewed-by:
*** 1,7 ****
/*
! * Copyright (c) 1999, 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
--- 1,7 ----
/*
! * Copyright (c) 1999, 2014, 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
*** 40,54 ****
* @author Naoto Sato
* @author Masayoshi Okutsu
*/
public class DateFormatProviderImpl extends DateFormatProvider implements AvailableLanguageTags {
private final LocaleProviderAdapter.Type type;
! private final Set<String> langtags;
! public DateFormatProviderImpl(LocaleProviderAdapter.Type type, Set<String> langtags) {
this.type = type;
- this.langtags = langtags;
}
/**
* Returns an array of all locales for which this locale service provider
* can provide localized objects or names.
--- 40,53 ----
* @author Naoto Sato
* @author Masayoshi Okutsu
*/
public class DateFormatProviderImpl extends DateFormatProvider implements AvailableLanguageTags {
private final LocaleProviderAdapter.Type type;
! private static Set<String> langtags;
! public DateFormatProviderImpl(LocaleProviderAdapter.Type type) {
this.type = type;
}
/**
* Returns an array of all locales for which this locale service provider
* can provide localized objects or names.
*** 56,71 ****
* @return An array of all locales for which this locale service provider
* can provide localized objects or names.
*/
@Override
public Locale[] getAvailableLocales() {
! return LocaleProviderAdapter.toLocaleArray(langtags);
}
@Override
public boolean isSupportedLocale(Locale locale) {
! return LocaleProviderAdapter.isSupportedLocale(locale, type, langtags);
}
/**
* Returns a new <code>DateFormat</code> instance which formats time
* with the given formatting style for the specified locale.
--- 55,70 ----
* @return An array of all locales for which this locale service provider
* can provide localized objects or names.
*/
@Override
public Locale[] getAvailableLocales() {
! return LocaleProviderAdapter.toLocaleArray(getLangTags(type));
}
@Override
public boolean isSupportedLocale(Locale locale) {
! return LocaleProviderAdapter.isSupportedLocale(locale, type, getLangTags(type));
}
/**
* Returns a new <code>DateFormat</code> instance which formats time
* with the given formatting style for the specified locale.
*** 162,169 ****
--- 161,179 ----
return sdf;
}
@Override
public Set<String> getAvailableLanguageTags() {
+ return getLangTags(type);
+ }
+
+ /**
+ * Available language tags for FormatData resources. Shared with other "format"
+ * provider implementations.
+ * */
+ static Set<String> getLangTags(LocaleProviderAdapter.Type t) {
+ if (langtags == null) {
+ langtags = ((JRELocaleProviderAdapter)LocaleProviderAdapter.forType(t)).getLanguageTagSet("FormatData");
+ }
return langtags;
}
}