Examples of CLDRFile


Examples of org.unicode.cldr.util.CLDRFile

      pw.close();
    }
  }

  private void loadLocaleIndependentCurrencyData() {
    CLDRFile supp = cldrFactory.getSupplementalData();

    // load the table of default # of decimal places and rounding for each currency
    defaultCurrencyFraction = 0;
    XPathParts parts = new XPathParts();
    Iterator<String> iterator = supp.iterator("//supplementalData/currencyData/fractions/info");
    while (iterator.hasNext()) {
      String path = iterator.next();
      parts.set(supp.getFullXPath(path));
      Map<String, String> attr = parts.findAttributes("info");
      if (attr == null) {
        continue;
      }
      String curCode = attr.get("iso4217");
      int digits = Integer.valueOf(attr.get("digits"));
      if ("DEFAULT".equalsIgnoreCase(curCode)) {
        defaultCurrencyFraction = digits;
      } else {
        currencyFractions.put(curCode, digits);
      }
      int roundingDigits = Integer.valueOf(attr.get("rounding"));
      if (roundingDigits != 0) {
        rounding.put(curCode, roundingDigits);
      }
    }

    // find which currencies are still in use in some region, everything else
    // should be marked as deprecated
    iterator = supp.iterator("//supplementalData/currencyData/region");
    while (iterator.hasNext()) {
      String path = iterator.next();
      parts.set(supp.getFullXPath(path));
      Map<String, String> attr = parts.findAttributes("currency");
      if (attr == null) {
        continue;
      }
      String region = parts.findAttributeValue("region", "iso3166");
View Full Code Here

Examples of org.unicode.cldr.util.CLDRFile

    if (regionMap != null) {
      return;
    }
    regionMap = new HashMap<String, SortedSet<LanguagePopulation>>();
    languageMap = new HashMap<String, SortedSet<RegionPopulation>>();
    CLDRFile supp = cldrFactory.getSupplementalData();
    XPathParts parts = new XPathParts();
    Iterator<String> iterator = supp.iterator("//supplementalData/territoryInfo/territory");
    while (iterator.hasNext()) {
      String path = iterator.next();
      parts.set(supp.getFullXPath(path));
      String language = parts.findAttributeValue("languagePopulation", "type");
      if (language == null) {
        continue;
      }
      String territory = parts.findAttributeValue("territory", "type");
View Full Code Here

Examples of org.unicode.cldr.util.CLDRFile

   * @param attribute
   */
  public void addAttributeEntry(String category, GwtLocale locale, Factory cldrFactory,
      String path, String tag, String key, String attribute, String defaultValue) {
    Map<String, String> map = getMap(category, locale);
    CLDRFile cldr = cldrFactory.make(allLocales.get(locale), true);
    XPathParts parts = new XPathParts();
    String fullPath = cldr.getFullXPath(path);

    Map<String, String> attr = null;
    if (fullPath != null) {
      parts.set(fullPath);
      attr = parts.findAttributes(tag);
View Full Code Here

Examples of org.unicode.cldr.util.CLDRFile

  }

  public void addEntries(String category, GwtLocale locale, Factory cldrFactory, String prefix,
      String tag, String keyAttribute) {
    Map<String, String> map = getMap(category, locale);
    CLDRFile cldr = cldrFactory.make(allLocales.get(locale), true);
    XPathParts parts = new XPathParts();
    Iterator<String> iterator = cldr.iterator(prefix);
    while (iterator.hasNext()) {
      String path = iterator.next();
      String fullXPath = cldr.getFullXPath(path);
      if (fullXPath == null) {
        fullXPath = path;
      }
      parts.set(fullXPath);
      if (parts.containsAttribute("alt")) {
        // ignore alternate strings
        continue;
      }
      Map<String, String> attr = parts.findAttributes(tag);
      if (attr == null) {
        continue;
      }
      String value = cldr.getStringValue(path);
      boolean draft = parts.containsAttribute("draft");
      String key = keyAttribute != null ? attr.get(keyAttribute) : "value";
      if (!draft || !map.containsKey(key)) {
        map.put(key, value);
      }
View Full Code Here

Examples of org.unicode.cldr.util.CLDRFile

   * @param tag the tag to load
   * @param keyAttribute the attribute in the tag to use as the key
   */
  public void addTerritoryEntries(String category, Factory cldrFactory,
      RegionLanguageData regionLanguageData, String prefix, String tag, String keyAttribute) {
    CLDRFile supp = cldrFactory.getSupplementalData();
    Map<String, String> map = new HashMap<String, String>();
    XPathParts parts = new XPathParts();
    Iterator<String> iterator = supp.iterator(prefix);
    while (iterator.hasNext()) {
      String path = iterator.next();
      parts.set(supp.getFullXPath(path));
      Map<String, String> attr = parts.findAttributes(tag);
      if (attr == null || attr.get("alt") != null) {
        continue;
      }
      String key = attr.get(keyAttribute);
View Full Code Here

Examples of org.unicode.cldr.util.CLDRFile

  }

  public void addVersions(Factory cldrFactory) {
    for (GwtLocale locale : allLocales.keySet()) {
      Map<String, String> map = getMap("version", locale);
      CLDRFile cldr = cldrFactory.make(allLocales.get(locale), true);
      XPathParts parts = new XPathParts();
      Iterator<String> iterator = cldr.iterator("//ldml/identity");
      while (iterator.hasNext()) {
        String path = iterator.next();
        String fullXPath = cldr.getFullXPath(path);
        if (fullXPath == null) {
          fullXPath = path;
        }
        parts.set(fullXPath);
        Map<String, String> attr = parts.getAttributes(2);
View Full Code Here

Examples of org.unicode.cldr.util.CLDRFile

    Map<String, String> defaultMap = null;
    if (!locale.isDefault()) {
      defaultMap = getMap(category, localeFactory.getDefault());
    }
    Map<String, Currency> tempMap = new HashMap<String, Currency>();
    CLDRFile cldr = cldrFactory.make(allLocales.get(locale), true);
    XPathParts parts = new XPathParts();
    Iterator<String> iterator = cldr.iterator("//ldml/numbers/currencies");
    while (iterator.hasNext()) {
      String path = iterator.next();
      String fullPath = cldr.getFullXPath(path);
      if (fullPath == null) {
        fullPath = path;
      }
      parts.set(fullPath);
      Map<String, String> attr = parts.findAttributes("currency");
      if (attr == null) {
        continue;
      }
      String currencyCode = attr.get("type");
      Currency currency = tempMap.get(currencyCode);
      if (currency == null) {
        currency = new Currency(currencyCode);
        if (currencyFractions.containsKey(currencyCode)) {
          currency.setDecimalDigits(currencyFractions.get(currencyCode));
        } else {
          currency.setDecimalDigits(defaultCurrencyFraction);
        }
        currency.setInUse(stillInUse.contains(currencyCode));
        tempMap.put(currencyCode, currency);
        Integer roundingMult = rounding.get(currencyCode);
        if (roundingMult != null) {
          currency.setRounding(roundingMult);
        }
      }
      String field = parts.getElement(4);
      String value = cldr.getStringValue(fullPath);
      attr = parts.findAttributes(field);
      if (attr == null) {
        attr = Collections.emptyMap();
      }
      String draft = attr.get("draft");
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.