Examples of XPathParts


Examples of org.unicode.cldr.util.XPathParts

  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);
        if (attr == null) {
          continue;
        }
        for (Map.Entry<String, String> entry : attr.entrySet()) {
          map.put(entry.getKey(), entry.getValue());
View Full Code Here

Examples of org.unicode.cldr.util.XPathParts

    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");
      if ("symbol".equalsIgnoreCase(field)) {
        // Don't overwrite symbol with narrow dollar value
        if (currency.getSymbol() == null || !"narrow".equals(parts.getAttributeValue(4, "alt"))) {
          currency.setSymbol(value);
        }
      } else if ("displayName".equalsIgnoreCase(field)) {
        if (attr.get("count") != null) {
          // We don't care about currency "count" names
View Full Code Here

Examples of org.unicode.cldr.util.XPathParts

  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");
      String curCode = attr.get("iso4217");
      if ("ZZ".equals(region) || "false".equals(attr.get("tender")) || "XXX".equals(curCode)) {
        // ZZ is an undefined region, XXX is an unknown currency code (and needs
        // to be special-cased because it is listed as used in Anartica!)
        continue;
View Full Code Here

Examples of org.unicode.cldr.util.XPathParts

      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");
      String literacyPercentStr = parts.findAttributeValue("territory", "literacyPercent");
      String populationStr = parts.findAttributeValue("territory", "population");
      String populationPercentStr =
          parts.findAttributeValue("languagePopulation", "populationPercent");
      String statusStr = parts.findAttributeValue("languagePopulation", "officialStatus");
      double literacyPercent = Double.parseDouble(literacyPercentStr) * .01;
      double population = Double.parseDouble(populationStr);
      double populationPercent = Double.parseDouble(populationPercentStr) * .01;
      double literatePopulation = population * populationPercent * literacyPercent;
      boolean official = "official".equals(statusStr);
View Full Code Here

Examples of org.unicode.cldr.util.XPathParts

   */
  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);
    }

    String value;
    if (attr != null) {
      value = attr.get(attribute);
View Full Code Here

Examples of org.unicode.cldr.util.XPathParts

  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.XPathParts

   */
  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);
      String territories = attr.get("territories");
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.