Package com.google.gwt.i18n.client.impl

Examples of com.google.gwt.i18n.client.impl.CurrencyDataImpl


         String defCurrencyCode = numberConstants.getProperty("defCurrencyCode");
         if (defCurrencyCode == null) {
            defCurrencyCode = "USD";
         }

         CurrencyData defCurrencyData = new CurrencyDataImpl(defCurrencyCode, defCurrencyCode, 2,
                  "");

         for (String currencyCode : currencies) {
            String currencyEntry = currencyData.getProperty(currencyCode);
            String[] currencySplit = currencyEntry.split("\\|");
            String currencySymbol = null;
            if (currencySplit.length > 1 && currencySplit[1].length() > 0) {
               currencySymbol = currencySplit[1];
            }
            int currencyFractionDigits = 2;
            if (currencySplit.length > 2 && currencySplit[2].length() > 0) {
               try {
                  currencyFractionDigits = Integer.valueOf(currencySplit[2]);
               } catch (NumberFormatException e) {
               }
            }

            int currencyFlags = currencyFractionDigits;
            String extraData = currencyExtra.getProperty(currencyCode);
            String portableSymbol = "";
            if (extraData != null) {
               // CurrencyExtra contains up to 3 fields separated by |
               // 0 - portable currency symbol
               // 1 - space-separated flags regarding currency symbol
               // positioning/spacing
               // 2 - override of CLDR-derived currency symbol
               String[] extraSplit = extraData.split("\\|");
               portableSymbol = extraSplit[0];
               if (extraSplit.length > 1) {
                  if (extraSplit[1].contains("SymPrefix")) {
                     currencyFlags |= CurrencyDataImpl.POS_FIXED_FLAG;
                  } else if (extraSplit[1].contains("SymSuffix")) {
                     currencyFlags |= CurrencyDataImpl.POS_FIXED_FLAG
                              | CurrencyDataImpl.POS_SUFFIX_FLAG;
                  }
                  if (extraSplit[1].contains("ForceSpace")) {
                     currencyFlags |= CurrencyDataImpl.SPACING_FIXED_FLAG
                              | CurrencyDataImpl.SPACE_FORCED_FLAG;
                  } else if (extraSplit[1].contains("ForceNoSpace")) {
                     currencyFlags |= CurrencyDataImpl.SPACING_FIXED_FLAG;
                  }
               }
               // If a non-empty override is supplied, use it for the currency
               // symbol.
               if (extraSplit.length > 2 && extraSplit[2].length() > 0) {
                  currencySymbol = extraSplit[2];
               }
               // If we don't have a currency symbol yet, use the portable
               // symbol if
               // supplied.
               if (currencySymbol == null && portableSymbol.length() > 0) {
                  currencySymbol = portableSymbol;
               }
            }
            // If all else fails, use the currency code as the symbol.
            if (currencySymbol == null) {
               currencySymbol = currencyCode;
            }

            if (currencyCode.equals(defCurrencyCode)) {
               return new CurrencyDataImpl(currencyCode, currencySymbol, currencyFlags,
                        portableSymbol);
            }
         }

         return defCurrencyData;
View Full Code Here


   * Return the default currency data for this locale.
   *
   * Generated implementations override this method.
   */
  protected CurrencyData getDefaultJava() {
    return new CurrencyDataImpl("USD", "$", 2, "US$");
  }
View Full Code Here

   *
   * Generated implementations override this method.
   */
  protected HashMap<String, CurrencyData> loadCurrencyMapJava() {
    HashMap<String, CurrencyData> result = new HashMap<String, CurrencyData>();
    result.put("USD", new CurrencyDataImpl("USD", "$", 2));
    result.put("EUR", new CurrencyDataImpl("EUR", "€", 2));
    result.put("GBP", new CurrencyDataImpl("GBP", "UK£", 2));
    result.put("JPY", new CurrencyDataImpl("JPY", "¥", 0));
    return result;
  }
View Full Code Here

TOP

Related Classes of com.google.gwt.i18n.client.impl.CurrencyDataImpl

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.