Package com.ibm.icu.impl

Examples of com.ibm.icu.impl.ICUResourceBundle


        // lang (script, country, variant, keyword=value, ...)
        // script, country, variant, keyword=value, ...

        final String[] tableNames = { "Languages", "Scripts", "Countries", "Variants" };

        ICUResourceBundle bundle = (ICUResourceBundle)UResourceBundle.getBundleInstance(ICUResourceBundle.ICU_BASE_NAME, displayLocaleID);

        StringBuffer buf = new StringBuffer();

        IDParser parser = new IDParser(localeID);
        String[] names = parser.getLanguageScriptCountryVariant();
View Full Code Here


     * @throws IndexOutOfBoundsException
     * @throws UResourceTypeMismatchException
     * @stable ICU 3.8
     */
    public String getString(int index) {
        ICUResourceBundle temp = (ICUResourceBundle)get(index);
        if (temp.getType() == STRING) {
            return temp.getString();
        }
        throw new UResourceTypeMismatchException("");
    }
View Full Code Here

        /* try the cache first */
        String[][] data = (String[][]) cachedLocaleData.get(locale);
        String[] numberElements;
        if (data == null) {  /* cache miss */
            data = new String[1][];
            ICUResourceBundle rb = (ICUResourceBundle)UResourceBundle.
                getBundleInstance(ICUResourceBundle.ICU_BASE_NAME, locale);
            data[0] = rb.getStringArray("NumberElements");
            /* update cache */
            cachedLocaleData.put(locale, data);
        }
        numberElements = data[0];
       
        ICUResourceBundle r = (ICUResourceBundle)UResourceBundle.
            getBundleInstance(ICUResourceBundle.ICU_BASE_NAME, locale);
       
        // TODO: Determine actual and valid locale correctly.
        ULocale uloc = r.getULocale();
        setLocale(uloc, uloc);

    // {dlf} clean up below now that we have our own resource data
        decimalSeparator = numberElements[0].charAt(0);
        groupingSeparator = numberElements[1].charAt(0);
        // Temporary hack to support old JDK 1.1 resources
//        patternSeparator = numberElements[2].length() > 0 ?
//            numberElements[2].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);
       
        // Temporary hack to support JDK versions before 1.1.6 (?)
//        exponentSeparator = numberElements.length >= 9 ?
//            numberElements[7] : DecimalFormat.PATTERN_EXPONENT;
//        perMill = numberElements.length >= 9 ?
//            numberElements[8].charAt(0) : '\u2030';
//        infinity  = numberElements.length >= 10 ?
//            numberElements[9] : "\u221e";
//        NaN = numberElements.length >= 11 ?
//            numberElements[10] : "\ufffd";
        exponentSeparator = numberElements[7];
        perMill = numberElements[8].charAt(0);
        infinity = numberElements[9];
        NaN = numberElements[10];
       
        plusSign  =numberElements[11].charAt(0);
        padEscape = DecimalFormat.PATTERN_PAD_ESCAPE;
        sigDigit  = DecimalFormat.PATTERN_SIGNIFICANT_DIGIT;
       
        // Attempt to set the zero digit based on the numbering system for the locale requested
        //
        NumberingSystem ns = NumberingSystem.getInstance(locale);
        if ( ns != null && ns.getRadix() == 10 && !ns.isAlgorithmic()) {
            zeroDigit = ns.getDescription().charAt(0);
        }

        // Obtain currency data from the currency API.  This is strictly
        // for backward compatibility; we don't use DecimalFormatSymbols
        // for currency data anymore.
        String currname = null;
        currency = Currency.getInstance(locale);
        if (currency != null) {
            intlCurrencySymbol = currency.getCurrencyCode();
            boolean[] isChoiceFormat = new boolean[1];
            currname = currency.getName(locale,
                                    Currency.SYMBOL_NAME,
                                    isChoiceFormat);
            // If this is a ChoiceFormat currency, then format an
            // arbitrary value; pick something != 1; more common.
            currencySymbol = isChoiceFormat[0]
                ? new ChoiceFormat(currname).format(2.0)
                : currname;
        } else {
            intlCurrencySymbol = "XXX";
            currencySymbol = "\u00A4"; // 'OX' currency symbol
        }
        // If there is a currency decimal, use it.
        monetarySeparator = decimalSeparator;
        monetaryGroupingSeparator = groupingSeparator;
        Currency curr = Currency.getInstance(locale);
        if(curr!=null){
            String currencyCode = curr.getCurrencyCode();
            if(currencyCode != null) {
                /* An explicit currency was requested */
                ICUResourceBundle resource = (ICUResourceBundle)UResourceBundle.getBundleInstance(ICUResourceBundle.ICU_BASE_NAME, locale);
                ICUResourceBundle currencyRes = resource.getWithFallback("Currencies");
                try{
                    currencyRes = currencyRes.getWithFallback(currencyCode);
                    if(currencyRes.getSize()>2) {
                        currencyRes = (ICUResourceBundle)currencyRes.get(2);
                        currencyPattern = currencyRes.getString(0);
                        monetarySeparator = currencyRes.getString(1).charAt(0);
                        monetaryGroupingSeparator = currencyRes.getString(2).charAt(0);
                    }
                }catch(MissingResourceException ex){
                    /* else An explicit currency was requested and is unknown or locale data is malformed. */
                    /* decimal format API will get the correct value later on. */
                }
            }
            /* else no currency keyword used. */
        }
        //monetarySeparator = numberElements[11].charAt(0);
       
        // Get Currency Spacing data.
        currencySpcBeforeSym = new String[CURRENCY_SPC_INSERT+1];
        currencySpcAfterSym = new String[CURRENCY_SPC_INSERT+1];
        ICUResourceBundle curSpcBundle = (ICUResourceBundle)r.get(CURRENCY_SPACING);
        if (curSpcBundle != null) {
            ICUResourceBundle beforeCurBundle = (ICUResourceBundle)curSpcBundle.get(BEFORE_CURRENCY);
            ICUResourceBundle afterCurBundle = (ICUResourceBundle)curSpcBundle.get(AFTER_CURRENCY);
            for (int i = CURRENCY_SPC_CURRENCY_MATCH; i <= CURRENCY_SPC_INSERT; i++) {
                currencySpcBeforeSym[i] = beforeCurBundle.getStringWithFallback(CURRENCY_SPACING_KEYS[i]);
                currencySpcAfterSym[i] = afterCurBundle.getStringWithFallback(CURRENCY_SPACING_KEYS[i]);
            }
        }
       
    }
View Full Code Here

     *                  value of 'options'.
     * @return          The set of exemplar characters for the given locale.
     * @stable ICU 3.0
     */
    public static UnicodeSet getExemplarSet(ULocale locale, int options) {
        ICUResourceBundle bundle = (ICUResourceBundle)UResourceBundle.getBundleInstance(ICUResourceBundle.ICU_BASE_NAME, locale);
        String pattern = bundle.getString(EXEMPLAR_CHARS);
        return new UnicodeSet(pattern, UnicodeSet.IGNORE_SPACE | options);
    }
View Full Code Here

     * @stable ICU 3.4
     */
    public UnicodeSet getExemplarSet(int options, int extype) {
        String [] exemplarSetTypes = { "ExemplarCharacters", "AuxExemplarCharacters" };
        try{
            ICUResourceBundle stringBundle = (ICUResourceBundle) bundle.get(exemplarSetTypes[extype]);
   
            if ( noSubstitute && (stringBundle.getLoadingStatus() == ICUResourceBundle.FROM_ROOT) )
               return null;
   
            return new UnicodeSet(stringBundle.getString(), UnicodeSet.IGNORE_SPACE | options);
        }catch(MissingResourceException ex){
            if(extype==LocaleData.ES_AUXILIARY){
                return new UnicodeSet();
            }
            throw ex;
View Full Code Here

        String [] delimiterTypes = { "quotationStart",
                                     "quotationEnd",
                                     "alternateQuotationStart",
                                     "alternateQuotationEnd" };

        ICUResourceBundle stringBundle = (ICUResourceBundle) bundle.get("delimiters").get(delimiterTypes[type]);

        if ( noSubstitute && (stringBundle.getLoadingStatus() == ICUResourceBundle.FROM_ROOT) )
           return null;

        return new String (stringBundle.getString());
    }
View Full Code Here

    public String getLocaleDisplayPattern() {
      if (bundle == null) {
        bundle = (ICUResourceBundle)UResourceBundle.getBundleInstance(
                        ICUResourceBundle.ICU_BASE_NAME, ULocale.getDefault());
      }
      ICUResourceBundle locDispBundle = (ICUResourceBundle) bundle.get(LOCALE_DISPLAY_PATTERN);
      String localeDisplayPattern = locDispBundle.getStringWithFallback(PATTERN);
      return localeDisplayPattern;
    }
View Full Code Here

    public String getLocaleSeparator() {
      if (bundle == null) {
        bundle = (ICUResourceBundle)UResourceBundle.getBundleInstance(
                        ICUResourceBundle.ICU_BASE_NAME, ULocale.getDefault());
      }
      ICUResourceBundle locDispBundle = (ICUResourceBundle) bundle.get(LOCALE_DISPLAY_PATTERN);
      String  localeSeparator = locDispBundle.getStringWithFallback(SEPARATOR);
      return localeSeparator;
    }
View Full Code Here

   * @throws UResourceTypeMismatchException
   *             If resource bundle type mismatch.
   * @stable ICU 3.8
   */
  public String getString(int index) {
    ICUResourceBundle temp = (ICUResourceBundle) get(index);
    if (temp.getType() == STRING) {
      return temp.getString();
    }
    throw new UResourceTypeMismatchException("");
  }
View Full Code Here

    /**
     * Helper function to find the code from locale.
     * @param locale The locale.
     */
    private static int[] findCodeFromLocale(ULocale locale) {
        ICUResourceBundle rb;
       
        try {
            rb = (ICUResourceBundle)UResourceBundle.getBundleInstance(ICUResourceBundle.ICU_BASE_NAME, locale);
        } catch (MissingResourceException e) {
            /* This part seems to never be called since "UResourceBundle.getBundleInstance"
             * corrects this by setting to ICUResourceBundle.FROM_DEFAULT
             * when such an invalid locale is passed.
             */
            ///CLOVER:OFF
            return null;
            ///CLOVER:ON
        }
       
        rb = (ICUResourceBundle)UResourceBundle.getBundleInstance(ICUResourceBundle.ICU_BASE_NAME, locale);
       
        // if rb is not a strict fallback of the requested locale, return null
        //if(!LocaleUtility.isFallbackOf(rb.getULocale().toString(), locale.toString())){
        //    return null;
        //}
        //non existent locale check
        if(rb.getLoadingStatus()==ICUResourceBundle.FROM_DEFAULT && ! locale.equals(ULocale.getDefault())){
            return null;
        }
        UResourceBundle sub = rb.get(kLocaleScript);
       
        int[] result = new int[sub.getSize()];
        int w = 0;
        for (int i = 0; i < result.length; ++i) {
            int code = UCharacter.getPropertyValueEnum(UProperty.SCRIPT,
View Full Code Here

TOP

Related Classes of com.ibm.icu.impl.ICUResourceBundle

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.