当前位置: 首页>>代码示例>>Java>>正文


Java ResourceBundleBasedAdapter类代码示例

本文整理汇总了Java中sun.util.locale.provider.ResourceBundleBasedAdapter的典型用法代码示例。如果您正苦于以下问题:Java ResourceBundleBasedAdapter类的具体用法?Java ResourceBundleBasedAdapter怎么用?Java ResourceBundleBasedAdapter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ResourceBundleBasedAdapter类属于sun.util.locale.provider包,在下文中一共展示了ResourceBundleBasedAdapter类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initialize

import sun.util.locale.provider.ResourceBundleBasedAdapter; //导入依赖的package包/类
/**
 * Initializes the symbols from the FormatData resource bundle.
 */
private void initialize( Locale locale ) {
    this.locale = locale;

    // get resource bundle data
    LocaleProviderAdapter adapter = LocaleProviderAdapter.getAdapter(DecimalFormatSymbolsProvider.class, locale);
    // Avoid potential recursions
    if (!(adapter instanceof ResourceBundleBasedAdapter)) {
        adapter = LocaleProviderAdapter.getResourceBundleBased();
    }
    Object[] data = adapter.getLocaleResources(locale).getDecimalFormatSymbolsData();
    String[] numberElements = (String[]) data[0];

    decimalSeparator = numberElements[0].charAt(0);
    groupingSeparator = numberElements[1].charAt(0);
    patternSeparator = numberElements[2].charAt(0);
    percent = numberElements[3].charAt(0);
    zeroDigit = numberElements[4].charAt(0); //different for Arabic,etc.
    digit = numberElements[5].charAt(0);
    minusSign = numberElements[6].charAt(0);
    exponential = numberElements[7].charAt(0);
    exponentialSeparator = numberElements[7]; //string representation new since 1.6
    perMill = numberElements[8].charAt(0);
    infinity  = numberElements[9];
    NaN = numberElements[10];

    // maybe filled with previously cached values, or null.
    intlCurrencySymbol = (String) data[1];
    currencySymbol = (String) data[2];

    // Currently the monetary decimal separator is the same as the
    // standard decimal separator for all locales that we support.
    // If that changes, add a new entry to NumberElements.
    monetarySeparator = decimalSeparator;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:38,代码来源:DecimalFormatSymbols.java

示例2: getCandidateLocales

import sun.util.locale.provider.ResourceBundleBasedAdapter; //导入依赖的package包/类
@Override
public List<Locale> getCandidateLocales(String baseName, Locale locale) {
    String key = baseName + '-' + locale.toLanguageTag();
    List<Locale> candidates = CANDIDATES_MAP.get(key);
    if (candidates == null) {
        LocaleProviderAdapter.Type type = baseName.contains(DOTCLDR) ? CLDR : JRE;
        LocaleProviderAdapter adapter = LocaleProviderAdapter.forType(type);
        candidates = adapter instanceof ResourceBundleBasedAdapter ?
            ((ResourceBundleBasedAdapter)adapter).getCandidateLocales(baseName, locale) :
            defaultControl.getCandidateLocales(baseName, locale);

        // Weed out Locales which are known to have no resource bundles
        int lastDot = baseName.lastIndexOf('.');
        String category = (lastDot >= 0) ? baseName.substring(lastDot + 1) : baseName;
        Set<String> langtags = ((JRELocaleProviderAdapter)adapter).getLanguageTagSet(category);
        if (!langtags.isEmpty()) {
            for (Iterator<Locale> itr = candidates.iterator(); itr.hasNext();) {
                if (!adapter.isSupportedProviderLocale(itr.next(), langtags)) {
                    itr.remove();
                }
            }
        }
        // Force fallback to Locale.ENGLISH for CLDR time zone names support
        if (locale.getLanguage() != "en"
                && type == CLDR && category.equals("TimeZoneNames")) {
            candidates.add(candidates.size() - 1, Locale.ENGLISH);
        }
        CANDIDATES_MAP.putIfAbsent(key, candidates);
    }
    return candidates;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:32,代码来源:LocaleData.java

示例3: initializeData

import sun.util.locale.provider.ResourceBundleBasedAdapter; //导入依赖的package包/类
private void initializeData(Locale desiredLocale) {
    locale = desiredLocale;

    // Copy values of a cached instance if any.
    SoftReference<DateFormatSymbols> ref = cachedInstances.get(locale);
    DateFormatSymbols dfs;
    if (ref != null && (dfs = ref.get()) != null) {
        copyMembers(dfs, this);
        return;
    }

    // Initialize the fields from the ResourceBundle for locale.
    LocaleProviderAdapter adapter = LocaleProviderAdapter.getAdapter(DateFormatSymbolsProvider.class, locale);
    // Avoid any potential recursions
    if (!(adapter instanceof ResourceBundleBasedAdapter)) {
        adapter = LocaleProviderAdapter.getResourceBundleBased();
    }
    ResourceBundle resource = ((ResourceBundleBasedAdapter)adapter).getLocaleData().getDateFormatData(locale);

    // JRE and CLDR use different keys
    // JRE: Eras, short.Eras and narrow.Eras
    // CLDR: long.Eras, Eras and narrow.Eras
    if (resource.containsKey("Eras")) {
        eras = resource.getStringArray("Eras");
    } else if (resource.containsKey("long.Eras")) {
        eras = resource.getStringArray("long.Eras");
    } else if (resource.containsKey("short.Eras")) {
        eras = resource.getStringArray("short.Eras");
    }
    months = resource.getStringArray("MonthNames");
    shortMonths = resource.getStringArray("MonthAbbreviations");
    ampms = resource.getStringArray("AmPmMarkers");
    localPatternChars = resource.getString("DateTimePatternChars");

    // Day of week names are stored in a 1-based array.
    weekdays = toOneBasedArray(resource.getStringArray("DayNames"));
    shortWeekdays = toOneBasedArray(resource.getStringArray("DayAbbreviations"));

    // Put a clone in the cache
    ref = new SoftReference<>((DateFormatSymbols)this.clone());
    SoftReference<DateFormatSymbols> x = cachedInstances.putIfAbsent(locale, ref);
    if (x != null) {
        DateFormatSymbols y = x.get();
        if (y == null) {
            // Replace the empty SoftReference with ref.
            cachedInstances.put(locale, ref);
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:50,代码来源:DateFormatSymbols.java

示例4: CollationData_zh_HK

import sun.util.locale.provider.ResourceBundleBasedAdapter; //导入依赖的package包/类
public CollationData_zh_HK() {
    ResourceBundle bundle = ((ResourceBundleBasedAdapter)LocaleProviderAdapter.forJRE()).getLocaleData().getCollationData(Locale.TAIWAN);
    setParent(bundle);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:5,代码来源:CollationData_zh_HK.java

示例5: FormatData_zh_HK

import sun.util.locale.provider.ResourceBundleBasedAdapter; //导入依赖的package包/类
public FormatData_zh_HK() {
    ResourceBundle bundle = ((ResourceBundleBasedAdapter)LocaleProviderAdapter.forJRE())
        .getLocaleData().getDateFormatData(Locale.TAIWAN);
    setParent(bundle);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:6,代码来源:FormatData_zh_HK.java

示例6: CurrencyNames_zh_HK

import sun.util.locale.provider.ResourceBundleBasedAdapter; //导入依赖的package包/类
public CurrencyNames_zh_HK() {
    ResourceBundle bundle = ((ResourceBundleBasedAdapter)LocaleProviderAdapter.forJRE()).getLocaleData().getCurrencyNames(Locale.TAIWAN);
    setParent(bundle);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:5,代码来源:CurrencyNames_zh_HK.java

示例7: CurrencyNames_zh_SG

import sun.util.locale.provider.ResourceBundleBasedAdapter; //导入依赖的package包/类
public CurrencyNames_zh_SG() {
    ResourceBundle bundle = ((ResourceBundleBasedAdapter)LocaleProviderAdapter.forJRE()).getLocaleData().getCurrencyNames(Locale.CHINA);
    setParent(bundle);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:5,代码来源:CurrencyNames_zh_SG.java

示例8: TimeZoneNames_zh_HK

import sun.util.locale.provider.ResourceBundleBasedAdapter; //导入依赖的package包/类
public TimeZoneNames_zh_HK() {
    ResourceBundle bundle = ((ResourceBundleBasedAdapter)LocaleProviderAdapter.forJRE()).getLocaleData().getTimeZoneNames(Locale.TAIWAN);
    setParent(bundle);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:5,代码来源:TimeZoneNames_zh_HK.java

示例9: LocaleNames_zh_HK

import sun.util.locale.provider.ResourceBundleBasedAdapter; //导入依赖的package包/类
public LocaleNames_zh_HK() {
    ResourceBundle bundle = ((ResourceBundleBasedAdapter)LocaleProviderAdapter.forJRE()).getLocaleData().getLocaleNames(Locale.TAIWAN);
    setParent(bundle);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:5,代码来源:LocaleNames_zh_HK.java

示例10: initializeData

import sun.util.locale.provider.ResourceBundleBasedAdapter; //导入依赖的package包/类
/**
 * Initializes this DateFormatSymbols with the locale data. This method uses
 * a cached DateFormatSymbols instance for the given locale if available. If
 * there's no cached one, this method creates an uninitialized instance and
 * populates its fields from the resource bundle for the locale, and caches
 * the instance. Note: zoneStrings isn't initialized in this method.
 */
private void initializeData(Locale locale) {
    SoftReference<DateFormatSymbols> ref = cachedInstances.get(locale);
    DateFormatSymbols dfs;
    if (ref == null || (dfs = ref.get()) == null) {
        if (ref != null) {
            // Remove the empty SoftReference
            cachedInstances.remove(locale, ref);
        }
        dfs = new DateFormatSymbols(false);

        // Initialize the fields from the ResourceBundle for locale.
        LocaleProviderAdapter adapter
            = LocaleProviderAdapter.getAdapter(DateFormatSymbolsProvider.class, locale);
        // Avoid any potential recursions
        if (!(adapter instanceof ResourceBundleBasedAdapter)) {
            adapter = LocaleProviderAdapter.getResourceBundleBased();
        }
        ResourceBundle resource
            = ((ResourceBundleBasedAdapter)adapter).getLocaleData().getDateFormatData(locale);

        dfs.locale = locale;
        // JRE and CLDR use different keys
        // JRE: Eras, short.Eras and narrow.Eras
        // CLDR: long.Eras, Eras and narrow.Eras
        if (resource.containsKey("Eras")) {
            dfs.eras = resource.getStringArray("Eras");
        } else if (resource.containsKey("long.Eras")) {
            dfs.eras = resource.getStringArray("long.Eras");
        } else if (resource.containsKey("short.Eras")) {
            dfs.eras = resource.getStringArray("short.Eras");
        }
        dfs.months = resource.getStringArray("MonthNames");
        dfs.shortMonths = resource.getStringArray("MonthAbbreviations");
        dfs.ampms = resource.getStringArray("AmPmMarkers");
        dfs.localPatternChars = resource.getString("DateTimePatternChars");

        // Day of week names are stored in a 1-based array.
        dfs.weekdays = toOneBasedArray(resource.getStringArray("DayNames"));
        dfs.shortWeekdays = toOneBasedArray(resource.getStringArray("DayAbbreviations"));

        // Put dfs in the cache
        ref = new SoftReference<>(dfs);
        SoftReference<DateFormatSymbols> x = cachedInstances.putIfAbsent(locale, ref);
        if (x != null) {
            DateFormatSymbols y = x.get();
            if (y == null) {
                // Replace the empty SoftReference with ref.
                cachedInstances.replace(locale, x, ref);
            } else {
                ref = x;
                dfs = y;
            }
        }
        // If the bundle's locale isn't the target locale, put another cache
        // entry for the bundle's locale.
        Locale bundleLocale = resource.getLocale();
        if (!bundleLocale.equals(locale)) {
            SoftReference<DateFormatSymbols> z
                = cachedInstances.putIfAbsent(bundleLocale, ref);
            if (z != null && z.get() == null) {
                cachedInstances.replace(bundleLocale, z, ref);
            }
        }
    }

    // Copy the field values from dfs to this instance.
    copyMembers(dfs, this);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:76,代码来源:DateFormatSymbols.java

示例11: initializeData

import sun.util.locale.provider.ResourceBundleBasedAdapter; //导入依赖的package包/类
/**
 * Initializes this DateFormatSymbols with the locale data. This method uses
 * a cached DateFormatSymbols instance for the given locale if available. If
 * there's no cached one, this method creates an uninitialized instance and
 * populates its fields from the resource bundle for the locale, and caches
 * the instance. Note: zoneStrings isn't initialized in this method.
 */
private void initializeData(Locale locale) {
    SoftReference<DateFormatSymbols> ref = cachedInstances.get(locale);
    DateFormatSymbols dfs;
    if (ref == null || (dfs = ref.get()) == null) {
        if (ref != null) {
            // Remove the empty SoftReference
            cachedInstances.remove(locale, ref);
        }
        dfs = new DateFormatSymbols(false);

        // Initialize the fields from the ResourceBundle for locale.
        LocaleProviderAdapter adapter
            = LocaleProviderAdapter.getAdapter(DateFormatSymbolsProvider.class, locale);
        // Avoid any potential recursions
        if (!(adapter instanceof ResourceBundleBasedAdapter)) {
            adapter = LocaleProviderAdapter.getResourceBundleBased();
        }
        ResourceBundle resource
            = ((ResourceBundleBasedAdapter)adapter).getLocaleData().getDateFormatData(locale);

        dfs.locale = locale;
        // JRE and CLDR use different keys
        // JRE: Eras, short.Eras and narrow.Eras
        // CLDR: long.Eras, Eras and narrow.Eras
        if (resource.containsKey("Eras")) {
            dfs.eras = resource.getStringArray("Eras");
        } else if (resource.containsKey("long.Eras")) {
            dfs.eras = resource.getStringArray("long.Eras");
        } else if (resource.containsKey("short.Eras")) {
            dfs.eras = resource.getStringArray("short.Eras");
        }
        dfs.months = resource.getStringArray("MonthNames");
        dfs.shortMonths = resource.getStringArray("MonthAbbreviations");
        dfs.ampms = resource.getStringArray("AmPmMarkers");
        dfs.localPatternChars = resource.getString("DateTimePatternChars");

        // Day of week names are stored in a 1-based array.
        dfs.weekdays = toOneBasedArray(resource.getStringArray("DayNames"));
        dfs.shortWeekdays = toOneBasedArray(resource.getStringArray("DayAbbreviations"));

        // Put dfs in the cache
        ref = new SoftReference<>(dfs);
        SoftReference<DateFormatSymbols> x = cachedInstances.putIfAbsent(locale, ref);
        if (x != null) {
            DateFormatSymbols y = x.get();
            if (y == null) {
                // Replace the empty SoftReference with ref.
                cachedInstances.replace(locale, x, ref);
            } else {
                ref = x;
                dfs = y;
            }
        }
    }

    // Copy the field values from dfs to this instance.
    copyMembers(dfs, this);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:66,代码来源:DateFormatSymbols.java


注:本文中的sun.util.locale.provider.ResourceBundleBasedAdapter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。