Package com.ibm.icu.util

Examples of com.ibm.icu.util.UResourceBundle$ResourceCacheKey


              b.setLoadingStatus(ICUResourceBundle.FROM_ROOT);
            }
          }
        }
      } else {
        UResourceBundle parent = null;
        localeName = b.getLocaleID();
        int i = localeName.lastIndexOf('_');

        b = (ICUResourceBundle) addToCache(root, fullName, defaultLocale, b);
View Full Code Here


    }
    bundle.baseName = baseName;
    bundle.localeID = localeID;
    bundle.ulocale = new ULocale(localeID);
    bundle.loader = loader;
    UResourceBundle alias = bundle.handleGetImpl("%%ALIAS", null, bundle, null, null); // handleGet will cache the bundle with no parent set
    if (alias != null) {
      return (ICUResourceBundle) UResourceBundle.getBundleInstance(baseName, alias.getString());
    } else {
      return bundle;
    }
  }
View Full Code Here

    lookup = new SimpleCache<Object, UResourceBundle>(ICUCache.WEAK, Math.max(getSize() * 2, MAX_INITIAL_LOOKUP_SIZE));
  }

  @Override
  protected UResourceBundle handleGet(final String resKey, final HashMap<String, String> table, final UResourceBundle requested) {
    UResourceBundle res = null;
    if (lookup != null) {
      res = lookup.get(resKey);
    }
    if (res == null) {
      int[] index = new int[1];
View Full Code Here

    return res;
  }

  @Override
  protected UResourceBundle handleGet(final int index, final HashMap<String, String> table, final UResourceBundle requested) {
    UResourceBundle res = null;
    Integer indexKey = null;
    if (lookup != null) {
      indexKey = Integer.valueOf(index);
      res = lookup.get(indexKey);
    }
    if (res == null) {
      boolean[] alias = new boolean[1];
      res = handleGetImpl(index, table, requested, alias);
      if (res != null && lookup != null && !alias[0]) {
        // We do not want to cache a result from alias entry
        lookup.put(res.getKey(), res);
        lookup.put(indexKey, res);
      }
    }
    return res;
  }
View Full Code Here

    if (!haveMap) {
      Map<String, String> tempLocaleIdToCardinalRulesId;
      Map<String, String> tempLocaleIdToOrdinalRulesId;
      Map<String, ULocale> tempRulesIdToEquivalentULocale;
      try {
        UResourceBundle pluralb = getPluralBundle();
        // Read cardinal-number rules.
        UResourceBundle localeb = pluralb.get("locales");

        // sort for convenience of getAvailableULocales
        tempLocaleIdToCardinalRulesId = new TreeMap<String, String>();
        // not visible
        tempRulesIdToEquivalentULocale = new HashMap<String, ULocale>();

        for (int i = 0; i < localeb.getSize(); ++i) {
          UResourceBundle b = localeb.get(i);
          String id = b.getKey();
          String value = b.getString().intern();
          tempLocaleIdToCardinalRulesId.put(id, value);

          if (!tempRulesIdToEquivalentULocale.containsKey(value)) {
            tempRulesIdToEquivalentULocale.put(value, new ULocale(id));
          }
        }

        // Read ordinal-number rules.
        localeb = pluralb.get("locales_ordinals");
        tempLocaleIdToOrdinalRulesId = new TreeMap<String, String>();
        for (int i = 0; i < localeb.getSize(); ++i) {
          UResourceBundle b = localeb.get(i);
          String id = b.getKey();
          String value = b.getString().intern();
          tempLocaleIdToOrdinalRulesId.put(id, value);
        }
      } catch (MissingResourceException e) {
        // dummy so we don't try again
        tempLocaleIdToCardinalRulesId = Collections.emptyMap();
View Full Code Here

        rules = rulesIdToRules.get(rulesId)// can be null
      }
    }
    if (!hasRules) {
      try {
        UResourceBundle pluralb = getPluralBundle();
        UResourceBundle rulesb = pluralb.get("rules");
        UResourceBundle setb = rulesb.get(rulesId);

        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < setb.getSize(); ++i) {
          UResourceBundle b = setb.get(i);
          if (i > 0) {
            sb.append("; ");
          }
          sb.append(b.getKey());
          sb.append(": ");
          sb.append(b.getString());
        }
        rules = PluralRules.parseDescription(sb.toString());
      } catch (ParseException e) {
      } catch (MissingResourceException e) {
      }
View Full Code Here

  public String[] getDateTimePatterns() {
    ICUResourceBundle bundle = get("DateTimePatterns");
    ArrayList<String> list = new ArrayList<String>();
    UResourceBundleIterator iter = bundle.getIterator();
    while (iter.hasNext()) {
      UResourceBundle patResource = iter.next();
      int resourceType = patResource.getType();
      switch (resourceType) {
      case UResourceBundle.STRING:
        list.add(patResource.getString());
        break;
      case UResourceBundle.ARRAY:
        String[] items = patResource.getStringArray();
        list.add(items[0]);
        break;
      }
    }
View Full Code Here

  public String[] getOverrides() {
    ICUResourceBundle bundle = get("DateTimePatterns");
    ArrayList<String> list = new ArrayList<String>();
    UResourceBundleIterator iter = bundle.getIterator();
    while (iter.hasNext()) {
      UResourceBundle patResource = iter.next();
      int resourceType = patResource.getType();
      switch (resourceType) {
      case UResourceBundle.STRING:
        list.add(null);
        break;
      case UResourceBundle.ARRAY:
        String[] items = patResource.getStringArray();
        list.add(items[1]);
        break;
      }
    }
    return list.toArray(new String[list.size()]);
View Full Code Here

        }
      }
    });

    for (UResourceBundleIterator i = rdb.getIterator(); i.hasNext();) {
      UResourceBundle line = i.next();

      String k = line.getKey();
      String v = line.getString();
      URelativeString rs = new URelativeString(k, v);
      datesSet.add(rs);
    }
    fDates = datesSet.toArray(new URelativeString[0]);
  }
View Full Code Here

        String description = "";
        String[][] localizations = null;

        try {
            description = bundle.getString(rulenames[format-1]);
            UResourceBundle locb = bundle.get(locnames[format-1]);
            localizations = new String[locb.getSize()][];
            for (int i = 0; i < localizations.length; ++i) {
                localizations[i] = locb.get(i).getStringArray();
            }
        }
        catch (MissingResourceException e) {
            // might have description and no localizations, or no description...
        }
View Full Code Here

TOP

Related Classes of com.ibm.icu.util.UResourceBundle$ResourceCacheKey

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.