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


Java ResourceBundle.getStringArray方法代码示例

本文整理汇总了Java中java.util.ResourceBundle.getStringArray方法的典型用法代码示例。如果您正苦于以下问题:Java ResourceBundle.getStringArray方法的具体用法?Java ResourceBundle.getStringArray怎么用?Java ResourceBundle.getStringArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.ResourceBundle的用法示例。


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

示例1: getCalendarNames

import java.util.ResourceBundle; //导入方法依赖的package包/类
String[] getCalendarNames(String key) {
    String[] names = null;
    String cacheKey = CALENDAR_NAMES + key;

    removeEmptyReferences();
    ResourceReference data = cache.get(cacheKey);

    if (data == null || ((names = (String[]) data.get()) == null)) {
        ResourceBundle rb = localeData.getDateFormatData(locale);
        if (rb.containsKey(key)) {
            names = rb.getStringArray(key);
            cache.put(cacheKey,
                      new ResourceReference(cacheKey, (Object) names, referenceQueue));
        }
    }

    return names;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:19,代码来源:LocaleResources.java

示例2: getJavaTimeNames

import java.util.ResourceBundle; //导入方法依赖的package包/类
String[] getJavaTimeNames(String key) {
    String[] names = null;
    String cacheKey = CALENDAR_NAMES + key;

    removeEmptyReferences();
    ResourceReference data = cache.get(cacheKey);

    if (data == null || ((names = (String[]) data.get()) == null)) {
        ResourceBundle rb = getJavaTimeFormatData();
        if (rb.containsKey(key)) {
            names = rb.getStringArray(key);
            cache.put(cacheKey,
                      new ResourceReference(cacheKey, (Object) names, referenceQueue));
        }
    }

    return names;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:19,代码来源:LocaleResources.java

示例3: getNumberPatterns

import java.util.ResourceBundle; //导入方法依赖的package包/类
public String[] getNumberPatterns() {
    String[] numberPatterns = null;

    removeEmptyReferences();
    ResourceReference data = cache.get(NUMBER_PATTERNS_CACHEKEY);

    if (data == null || ((numberPatterns = (String[]) data.get()) == null)) {
        ResourceBundle resource = localeData.getNumberFormatData(locale);
        numberPatterns = resource.getStringArray("NumberPatterns");
        cache.put(NUMBER_PATTERNS_CACHEKEY,
                  new ResourceReference(NUMBER_PATTERNS_CACHEKEY, (Object) numberPatterns, referenceQueue));
    }

    return numberPatterns;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:16,代码来源:LocaleResources.java

示例4: findInBundle

import java.util.ResourceBundle; //导入方法依赖的package包/类
/**
 * Attempt to find an entry in a single resource bundle.  This is
 * a one-sided lookup.  findInStaticStore() performs up to two such
 * lookups, one for the source, and one for the target.
 *
 * Do not perform fallback.  Return 0 on failure.
 *
 * On success, create a new Entry object, populate it, and return it.
 * The caller owns the returned object.
 */
private Object[] findInBundle(Spec specToOpen,
                              Spec specToFind,
                              String variant,
                              int direction) {
    // assert(specToOpen.isLocale());
    ResourceBundle res = specToOpen.getBundle();

    if (res == null) {
        // This means that the bundle's locale does not match
        // the current level of iteration for the spec.
        return null;
    }

    for (int pass=0; pass<2; ++pass) {
        StringBuilder tag = new StringBuilder();
        // First try either TransliteratorTo_xxx or
        // TransliterateFrom_xxx, then try the bidirectional
        // Transliterate_xxx.  This precedence order is arbitrary
        // but must be consistent and documented.
        if (pass == 0) {
            tag.append(direction == Transliterator.FORWARD ?
                       "TransliterateTo" : "TransliterateFrom");
        } else {
            tag.append("Transliterate");
        }
        tag.append(specToFind.get().toUpperCase(Locale.ENGLISH));

        try {
            // The Transliterate*_xxx resource is an array of
            // strings of the format { <v0>, <r0>, ... }.  Each
            // <vi> is a variant name, and each <ri> is a rule.
            String[] subres = res.getStringArray(tag.toString());

            // assert(subres != null);
            // assert(subres.length % 2 == 0);
            int i = 0;
            if (variant.length() != 0) {
                for (i=0; i<subres.length; i+= 2) {
                    if (subres[i].equalsIgnoreCase(variant)) {
                        break;
                    }
                }
            }

            if (i < subres.length) {
                // We have a match, or there is no variant and i == 0.
                // We have succeeded in loading a string from the
                // locale resources.  Return the rule string which
                // will itself become the registry entry.

                // The direction is always forward for the
                // TransliterateTo_xxx and TransliterateFrom_xxx
                // items; those are unidirectional forward rules.
                // For the bidirectional Transliterate_xxx items,
                // the direction is the value passed in to this
                // function.
                int dir = (pass == 0) ? Transliterator.FORWARD : direction;
                return new Object[] { new LocaleEntry(subres[i+1], dir) };
            }

        } catch (MissingResourceException e) {
            ///CLOVER:OFF
            if (DEBUG) System.out.println("missing resource: " + e);
            ///CLOVER:ON
        }
    }

    // If we get here we had a missing resource exception or we
    // failed to find a desired variant.
    return null;
}
 
开发者ID:abhijitvalluri,项目名称:fitnotifications,代码行数:82,代码来源:TransliteratorRegistry.java

示例5: initializeData

import java.util.ResourceBundle; //导入方法依赖的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

示例6: getDecimalFormatSymbolsData

import java.util.ResourceBundle; //导入方法依赖的package包/类
public Object[] getDecimalFormatSymbolsData() {
    Object[] dfsdata;

    removeEmptyReferences();
    ResourceReference data = cache.get(DECIMAL_FORMAT_SYMBOLS_DATA_CACHEKEY);
    if (data == null || ((dfsdata = (Object[]) data.get()) == null)) {
        // Note that only dfsdata[0] is prepared here in this method. Other
        // elements are provided by the caller, yet they are cached here.
        ResourceBundle rb = localeData.getNumberFormatData(locale);
        dfsdata = new Object[3];

        // NumberElements look up. First, try the Unicode extension
        String numElemKey;
        String numberType = locale.getUnicodeLocaleType("nu");
        if (numberType != null) {
            numElemKey = numberType + ".NumberElements";
            if (rb.containsKey(numElemKey)) {
                dfsdata[0] = rb.getStringArray(numElemKey);
            }
        }

        // Next, try DefaultNumberingSystem value
        if (dfsdata[0] == null && rb.containsKey("DefaultNumberingSystem")) {
            numElemKey = rb.getString("DefaultNumberingSystem") + ".NumberElements";
            if (rb.containsKey(numElemKey)) {
                dfsdata[0] = rb.getStringArray(numElemKey);
            }
        }

        // Last resort. No need to check the availability.
        // Just let it throw MissingResourceException when needed.
        if (dfsdata[0] == null) {
            dfsdata[0] = rb.getStringArray("NumberElements");
        }

        cache.put(DECIMAL_FORMAT_SYMBOLS_DATA_CACHEKEY,
                  new ResourceReference(DECIMAL_FORMAT_SYMBOLS_DATA_CACHEKEY, (Object) dfsdata, referenceQueue));
    }

    return dfsdata;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:42,代码来源:LocaleResources.java

示例7: initializeData

import java.util.ResourceBundle; //导入方法依赖的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

示例8: initializeData

import java.util.ResourceBundle; //导入方法依赖的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


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