Package com.ibm.icu.util

Examples of com.ibm.icu.util.Currency$ServiceShim


    private static class CurrencyHandler implements Handler
    {
        public Object[] getTestObjects()
        {
            Currency currencies[] = new Currency[places.length];
           
            for (int i = 0; i < places.length; i += 1) {
                currencies[i] = Currency.getInstance(places[i]);
            }
           
View Full Code Here


            return currencies;
        }
       
        public boolean hasSameBehavior(Object a, Object b)
        {
            Currency curr_a = (Currency) a;
            Currency curr_b = (Currency) b;
           
            return curr_a.getCurrencyCode().equals(curr_b.getCurrencyCode());
           
        }
View Full Code Here

     */
    public StringBuffer format(CurrencyAmount currAmt,
                               StringBuffer toAppendTo,
                               FieldPosition pos) {
        // Default implementation -- subclasses may override
        Currency save = getCurrency(), curr = currAmt.getCurrency();
        boolean same = curr.equals(save);
        if (!same) setCurrency(curr);
        format(currAmt.getNumber(), toAppendTo, pos);
        if (!same) setCurrency(save);
        return toAppendTo;
View Full Code Here

     * @return a non-null Currency
     * @internal
     * @deprecated This API is ICU internal only.
     */
    protected Currency getEffectiveCurrency() {
        Currency c = getCurrency();
        if (c == null) {
            ULocale uloc = getLocale(ULocale.VALID_LOCALE);
            if (uloc == null) {
                uloc = ULocale.getDefault();
            }
View Full Code Here

        GlobalizationPreferences gp = new GlobalizationPreferences();

        // Set language only locale - ja
        logln("Set locale - ja");
        gp.setLocale(new ULocale("ja"));
        Currency cur = gp.getCurrency();
        String code = cur.getCurrencyCode();
        if (!code.equals("JPY")) {
            errln("FAIL: Currency is " + code + " - Expected: JPY");
        }

        gp.reset();
        // Set locales with territory
        logln("Set locale - ja_US");
        gp.setLocale(new ULocale("ja_US"));
        cur = gp.getCurrency();
        code = cur.getCurrencyCode();
        if (!code.equals("USD")) {
            errln("FAIL: Currency is " + code + " - Expected: USD");
        }

        // Set locales with territory in the second locale
        logln("Set locales - it, en_US");
        ULocale[] locales = new ULocale[2];
        locales[0] = new ULocale("it");
        locales[1] = new ULocale("en_US");
        gp.setLocales(locales);
        cur = gp.getCurrency();
        code = cur.getCurrencyCode();
        if (!code.equals("USD")) {
            errln("FAIL: Currency is " + code + " - Expected: USD");
        }

        // Set explicit territory
        logln("Set territory - DE");
        gp.setTerritory("DE");
        cur = gp.getCurrency();
        code = cur.getCurrencyCode();
        if (!code.equals("EUR")) {
            errln("FAIL: Currency is " + code + " - Expected: EUR");
        }

        // Set explicit currency
        Currency ecur = Currency.getInstance("BRL");
        gp.setCurrency(ecur);
        logln("Set explicit currency - BRL");
        cur = gp.getCurrency();
        code = cur.getCurrencyCode();
        if (!code.equals("BRL")) {
            errln("FAIL: Currency is " + code + " - Expected: BRL");
        }

        // Set explicit territory again
        logln("Set territory - JP");
        cur = gp.getCurrency();
        code = cur.getCurrencyCode();
        if (!code.equals("BRL")) {
            errln("FAIL: Currency is " + code + " - Expected: BRL");
        }

        // Freeze
        logln("Freeze this object");
        Currency ecur2 = Currency.getInstance("CHF");
        boolean bFrozen = false;
        gp.freeze();
        try {
            gp.setCurrency(ecur2);
        } catch (UnsupportedOperationException uoe) {
View Full Code Here

            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{
View Full Code Here

     */
    public StringBuffer format(CurrencyAmount currAmt,
                               StringBuffer toAppendTo,
                               FieldPosition pos) {
        // Default implementation -- subclasses may override
        Currency save = getCurrency(), curr = currAmt.getCurrency();
        boolean same = curr.equals(save);
        if (!same) setCurrency(curr);
        format(currAmt.getNumber(), toAppendTo, pos);
        if (!same) setCurrency(save);
        return toAppendTo;
View Full Code Here

     * @internal
     * @deprecated This API is ICU internal only.
     */
    @Deprecated
    protected Currency getEffectiveCurrency() {
        Currency c = getCurrency();
        if (c == null) {
            ULocale uloc = getLocale(ULocale.VALID_LOCALE);
            if (uloc == null) {
                uloc = ULocale.getDefault(Category.FORMAT);
            }
View Full Code Here

                    pattern.charAt(i) == CURRENCY_SIGN;
                if (intl) {
                    ++i;
                }
                String s = null;
                Currency currency = getCurrency();
                if (currency != null) {
                    if (!intl) {
                        boolean isChoiceFormat[] = new boolean[1];
                        s = currency.getName(symbols.getULocale(),
                                             Currency.SYMBOL_NAME,
                                             isChoiceFormat);
                        if (isChoiceFormat[0]) {
                            // Two modes here: If doFormat is false, we set up
                            // currencyChoice.  If doFormat is true, we use the
                            // previously created currencyChoice to format the
                            // value in digitList.
                            if (!doFormat) {
                                // If the currency is handled by a ChoiceFormat,
                                // then we're not going to use the expanded
                                // patterns.  Instantiate the ChoiceFormat and
                                // return.
                                if (currencyChoice == null) {
                                    currencyChoice = new ChoiceFormat(s);
                                }
                                // We could almost return null or "" here, since the
                                // expanded affixes are almost not used at all
                                // in this situation.  However, one method --
                                // toPattern() -- still does use the expanded
                                // affixes, in order to set up a padding
                                // pattern.  We use the CURRENCY_SIGN as a
                                // placeholder.
                                s = String.valueOf(CURRENCY_SIGN);
                            } else {
                                FieldPosition pos = new FieldPosition(0); // ignored
                                currencyChoice.format(digitList.getDouble(), buffer, pos);
                                continue;
                            }
                        }
                    } else {
                        s = currency.getCurrencyCode();
                    }
                } else {
                    s = intl ? symbols.getInternationalCurrencySymbol()
                        : symbols.getCurrencySymbol();
                }
View Full Code Here

     * this method should never return null.
     * @internal
     * @deprecated This API is ICU internal only.
     */
    protected Currency getEffectiveCurrency() {
        Currency c = getCurrency();
        if (c == null) {
            c = Currency.getInstance(symbols.getInternationalCurrencySymbol());
        }
        return c;
    }
View Full Code Here

TOP

Related Classes of com.ibm.icu.util.Currency$ServiceShim

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.