Package com.ibm.icu.util

Examples of com.ibm.icu.util.UResourceBundle


   * @see #countEquivalentIDs
   */
  public static synchronized String getEquivalentID(String id, int index) {
    String result = "";
    if (index >= 0) {
      UResourceBundle res = openOlsonResource(null, id);
      if (res != null) {
        int zoneIdx = -1;
        try {
          UResourceBundle links = res.get("links");
          int[] zones = links.getIntVector();
          if (index < zones.length) {
            zoneIdx = zones[index];
          }
        } catch (MissingResourceException ex) {
          // throw away
View Full Code Here


   * ICU frequently refers the zone ID array in zoneinfo resource
   */
  private static synchronized String[] getZoneIDs() {
    if (ZONEIDS == null) {
      try {
        UResourceBundle top = UResourceBundle.getBundleInstance(ICUResourceBundle.ICU_BASE_NAME, ZONEINFORESNAME,
            ICUResourceBundle.ICU_DATA_CLASS_LOADER);
        UResourceBundle names = top.get(kNAMES);
        ZONEIDS = names.getStringArray();
      } catch (MissingResourceException ex) {
        // throw away..
      }
    }
    if (ZONEIDS == null) {
View Full Code Here

      if (canonical == null) {
        // Resolve Olson link and try it again if necessary
        try {
          int zoneIdx = getZoneIndex(tzid);
          if (zoneIdx >= 0) {
            UResourceBundle top = UResourceBundle.getBundleInstance(ICUResourceBundle.ICU_BASE_NAME, ZONEINFORESNAME,
                ICUResourceBundle.ICU_DATA_CLASS_LOADER);
            UResourceBundle zones = top.get(kZONES);
            UResourceBundle zone = zones.get(zoneIdx);
            if (zone.getType() == UResourceBundle.INT) {
              // It's a link - resolve link and lookup
              tzid = getZoneID(zone.getInt());
              canonical = findCLDRCanonicalID(tzid);
            }
            if (canonical == null) {
              canonical = tzid;
            }
View Full Code Here

    String canonical = null;
    String tzidKey = tzid.replace('/', ':');

    try {
      // First, try check if the given ID is canonical
      UResourceBundle keyTypeData = UResourceBundle.getBundleInstance(ICUResourceBundle.ICU_BASE_NAME, "keyTypeData",
          ICUResourceBundle.ICU_DATA_CLASS_LOADER);
      UResourceBundle typeMap = keyTypeData.get("typeMap");
      UResourceBundle typeKeys = typeMap.get("timezone");
      try {
        /* UResourceBundle canonicalEntry = */typeKeys.get(tzidKey);
        // The given tzid is available in the canonical list
        canonical = tzid;
      } catch (MissingResourceException e) {
        // fall through
      }
      if (canonical == null) {
        // Try alias map
        UResourceBundle typeAlias = keyTypeData.get("typeAlias");
        UResourceBundle aliasesForKey = typeAlias.get("timezone");
        canonical = aliasesForKey.getString(tzidKey);
      }
    } catch (MissingResourceException e) {
      // fall through
    }
    return canonical;
View Full Code Here

    String region = REGION_CACHE.get(tzid);
    if (region == null) {
      int zoneIdx = getZoneIndex(tzid);
      if (zoneIdx >= 0) {
        try {
          UResourceBundle top = UResourceBundle.getBundleInstance(ICUResourceBundle.ICU_BASE_NAME, ZONEINFORESNAME,
              ICUResourceBundle.ICU_DATA_CLASS_LOADER);
          UResourceBundle regions = top.get(kREGIONS);
          if (zoneIdx < regions.getSize()) {
            region = regions.getString(zoneIdx);
          }
        } catch (MissingResourceException e) {
          // throw away
        }
        if (region != null) {
View Full Code Here

      // Note: We may cache the primary zone map in future.

      // Even a country has multiple zones, one of them might be
      // dominant and treated as a primary zone.
      try {
        UResourceBundle bundle = UResourceBundle.getBundleInstance(ICUResourceBundle.ICU_BASE_NAME, "metaZones");
        UResourceBundle primaryZones = bundle.get("primaryZones");
        String primaryZone = primaryZones.getString(country);
        if (tzid.equals(primaryZone)) {
          isPrimary.value = Boolean.TRUE;
        } else {
          // The given ID might not be a canonical ID
          String canonicalID = getCanonicalCLDRID(tzid);
View Full Code Here

   * @param id
   *            zone id
   * @return the corresponding zone resource or null if not found
   */
  public static UResourceBundle openOlsonResource(UResourceBundle top, String id) {
    UResourceBundle res = null;
    int zoneIdx = getZoneIndex(id);
    if (zoneIdx >= 0) {
      try {
        if (top == null) {
          top = UResourceBundle.getBundleInstance(ICUResourceBundle.ICU_BASE_NAME, ZONEINFORESNAME,
              ICUResourceBundle.ICU_DATA_CLASS_LOADER);
        }
        UResourceBundle zones = top.get(kZONES);
        UResourceBundle zone = zones.get(zoneIdx);
        if (zone.getType() == UResourceBundle.INT) {
          // resolve link
          zone = zones.get(zone.getInt());
        }
        res = zone;
      } catch (MissingResourceException e) {
        res = null;
      }
View Full Code Here

    String shortID = null;
    String tzidKey = canonicalID.replace('/', ':');

    try {
      // First, try check if the given ID is canonical
      UResourceBundle keyTypeData = UResourceBundle.getBundleInstance(ICUResourceBundle.ICU_BASE_NAME, "keyTypeData",
          ICUResourceBundle.ICU_DATA_CLASS_LOADER);
      UResourceBundle typeMap = keyTypeData.get("typeMap");
      UResourceBundle typeKeys = typeMap.get("timezone");
      shortID = typeKeys.getString(tzidKey);
    } catch (MissingResourceException e) {
      // fall through
    }

    return shortID;
View Full Code Here

     */
    @Override
    protected OlsonTimeZone createInstance(String key, String data) {
      OlsonTimeZone tz = null;
      try {
        UResourceBundle top = UResourceBundle.getBundleInstance(ICUResourceBundle.ICU_BASE_NAME, ZONEINFORESNAME,
            ICUResourceBundle.ICU_DATA_CLASS_LOADER);
        UResourceBundle res = openOlsonResource(top, data);
        if (res != null) {
          tz = new OlsonTimeZone(top, res, data);
          tz.freeze();
        }
      } catch (MissingResourceException e) {
View Full Code Here

        //}
        //non existent locale check
        if(rb.getLoadingStatus()==ICUResourceBundle.FROM_DEFAULT && ! locale.equals(ULocale.getDefault())){
            return null;
        }
        UResourceBundle sub = rb.get(kLocaleScript);
       
        int[] result = new int[sub.getSize()];
        int w = 0;
        for (int i = 0; i < result.length; ++i) {
            int code = UCharacter.getPropertyValueEnum(UProperty.SCRIPT,
                                                       sub.getString(i));
            result[w++] = code;

        }

        if (w < result.length) {
View Full Code Here

TOP

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

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.