Java Code Examples for com.ibm.icu.util.UResourceBundle#get()
The following examples show how to use
com.ibm.icu.util.UResourceBundle#get() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NumberingSystem.java From fitnotifications with Apache License 2.0 | 6 votes |
private static NumberingSystem lookupInstanceByName(String name) { int radix; boolean isAlgorithmic; String description; try { UResourceBundle numberingSystemsInfo = UResourceBundle.getBundleInstance(ICUData.ICU_BASE_NAME, "numberingSystems"); UResourceBundle nsCurrent = numberingSystemsInfo.get("numberingSystems"); UResourceBundle nsTop = nsCurrent.get(name); description = nsTop.getString("desc"); UResourceBundle nsRadixBundle = nsTop.get("radix"); UResourceBundle nsAlgBundle = nsTop.get("algorithmic"); radix = nsRadixBundle.getInt(); int algorithmic = nsAlgBundle.getInt(); isAlgorithmic = ( algorithmic == 1 ); } catch (MissingResourceException ex) { return null; } return getInstance(name, radix, isAlgorithmic, description); }
Example 2
Source File: NumberingSystem.java From fitnotifications with Apache License 2.0 | 6 votes |
/** * Returns a string array containing a list of the names of numbering systems * currently known to ICU. * @stable ICU 4.2 */ public static String [] getAvailableNames() { UResourceBundle numberingSystemsInfo = UResourceBundle.getBundleInstance(ICUData.ICU_BASE_NAME, "numberingSystems"); UResourceBundle nsCurrent = numberingSystemsInfo.get("numberingSystems"); UResourceBundle temp; String nsName; ArrayList<String> output = new ArrayList<String>(); UResourceBundleIterator it = nsCurrent.getIterator(); while (it.hasNext()) { temp = it.next(); nsName = temp.getKey(); output.add(nsName); } return output.toArray(new String[output.size()]); }
Example 3
Source File: ZoneMeta.java From fitnotifications with Apache License 2.0 | 6 votes |
/** * Returns an ID in the equivalency group that includes the given * ID. An equivalency group contains zones that behave * identically to the given zone. * * <p>The given index must be in the range 0..n-1, where n is the * value returned by <code>countEquivalentIDs(id)</code>. For * some value of 'index', the returned value will be equal to the * given id. If the given id is not a valid system time zone, or * if 'index' is out of range, then returns an empty string. * @param id a system time zone ID * @param index a value from 0 to n-1, where n is the value * returned by <code>countEquivalentIDs(id)</code> * @return the ID of the index-th zone in the equivalency group * containing 'id', or an empty string if 'id' is not a valid * system ID or 'index' is out of range * @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 } if (zoneIdx >= 0) { String tmp = getZoneID(zoneIdx); if (tmp != null) { result = tmp; } } } } return result; }
Example 4
Source File: ZoneMeta.java From fitnotifications with Apache License 2.0 | 6 votes |
/** * Return the region code for this tzid. * If tzid is not a system zone ID, this method returns null. */ public static String getRegion(String tzid) { String region = REGION_CACHE.get(tzid); if (region == null) { int zoneIdx = getZoneIndex(tzid); if (zoneIdx >= 0) { try { UResourceBundle top = UResourceBundle.getBundleInstance( ICUData.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) { REGION_CACHE.put(tzid, region); } } } return region; }
Example 5
Source File: ZoneMeta.java From fitnotifications with Apache License 2.0 | 6 votes |
/** * Given an ID and the top-level resource of the zoneinfo resource, * open the appropriate resource for the given time zone. * Dereference links if necessary. * @param top the top level resource of the zoneinfo resource or null. * @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( ICUData.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; } } return res; }
Example 6
Source File: ZoneMeta.java From fitnotifications with Apache License 2.0 | 6 votes |
private static String getShortIDFromCanonical(String canonicalID) { String shortID = null; String tzidKey = canonicalID.replace('/', ':'); try { // First, try check if the given ID is canonical UResourceBundle keyTypeData = UResourceBundle.getBundleInstance(ICUData.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; }
Example 7
Source File: TimeZoneNamesImpl.java From fitnotifications with Apache License 2.0 | 6 votes |
@Override protected Map<String, String> createInstance(String key, String data) { Map<String, String> map = null; UResourceBundle bundle = UResourceBundle.getBundleInstance(ICUData.ICU_BASE_NAME, "metaZones"); UResourceBundle mapTimezones = bundle.get("mapTimezones"); try { UResourceBundle regionMap = mapTimezones.get(key); Set<String> regions = regionMap.keySet(); map = new HashMap<String, String>(regions.size()); for (String region : regions) { String tzID = regionMap.getString(region).intern(); map.put(region.intern(), tzID); } } catch (MissingResourceException e) { map = Collections.emptyMap(); } return map; }
Example 8
Source File: ICUDataVersion.java From fitnotifications with Apache License 2.0 | 5 votes |
/** * This function retrieves the data version from icuver and returns a VersionInfo object with that version information. * * @return Current icu data version */ public static VersionInfo getDataVersion() { UResourceBundle icudatares = null; try { icudatares = UResourceBundle.getBundleInstance( ICUData.ICU_BASE_NAME, ICUDataVersion.U_ICU_VERSION_BUNDLE, ICUResourceBundle.ICU_DATA_CLASS_LOADER); icudatares = icudatares.get(ICUDataVersion.U_ICU_DATA_KEY); } catch (MissingResourceException ex) { return null; } return VersionInfo.getInstance(icudatares.getString()); }
Example 9
Source File: ZoneMeta.java From fitnotifications with Apache License 2.0 | 5 votes |
/** * Returns the number of IDs in the equivalency group that * includes the given ID. An equivalency group contains zones * that behave identically to the given zone. * * <p>If there are no equivalent zones, then this method returns * 0. This means either the given ID is not a valid zone, or it * is and there are no other equivalent zones. * @param id a system time zone ID * @return the number of zones in the equivalency group containing * 'id', or zero if there are no equivalent zones. * @see #getEquivalentID */ public static synchronized int countEquivalentIDs(String id) { int count = 0; UResourceBundle res = openOlsonResource(null, id); if (res != null) { try { UResourceBundle links = res.get("links"); int[] v = links.getIntVector(); count = v.length; } catch (MissingResourceException ex) { // throw away } } return count; }
Example 10
Source File: ZoneMeta.java From fitnotifications with Apache License 2.0 | 5 votes |
/** * Return the canonical id for this tzid defined by CLDR, which might be * the id itself. If the given tzid is not known, return null. * * Note: This internal API supports all known system IDs and "Etc/Unknown" (which is * NOT a system ID). */ public static String getCanonicalCLDRID(String tzid) { String canonical = CANONICAL_ID_CACHE.get(tzid); if (canonical == null) { canonical = findCLDRCanonicalID(tzid); if (canonical == null) { // Resolve Olson link and try it again if necessary try { int zoneIdx = getZoneIndex(tzid); if (zoneIdx >= 0) { UResourceBundle top = UResourceBundle.getBundleInstance(ICUData.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; } } } catch (MissingResourceException e) { // fall through } } if (canonical != null) { CANONICAL_ID_CACHE.put(tzid, canonical); } } return canonical; }
Example 11
Source File: TimeZoneNamesImpl.java From fitnotifications with Apache License 2.0 | 5 votes |
static Set<String> _getAvailableMetaZoneIDs() { if (METAZONE_IDS == null) { synchronized (TimeZoneNamesImpl.class) { if (METAZONE_IDS == null) { UResourceBundle bundle = UResourceBundle.getBundleInstance(ICUData.ICU_BASE_NAME, "metaZones"); UResourceBundle mapTimezones = bundle.get("mapTimezones"); Set<String> keys = mapTimezones.keySet(); METAZONE_IDS = Collections.unmodifiableSet(keys); } } } return METAZONE_IDS; }
Example 12
Source File: TimeZoneNamesImpl.java From fitnotifications with Apache License 2.0 | 5 votes |
@Override protected List<MZMapEntry> createInstance(String key, String data) { List<MZMapEntry> mzMaps = null; UResourceBundle bundle = UResourceBundle.getBundleInstance(ICUData.ICU_BASE_NAME, "metaZones"); UResourceBundle metazoneInfoBundle = bundle.get("metazoneInfo"); String tzkey = data.replace('/', ':'); try { UResourceBundle zoneBundle = metazoneInfoBundle.get(tzkey); mzMaps = new ArrayList<MZMapEntry>(zoneBundle.getSize()); for (int idx = 0; idx < zoneBundle.getSize(); idx++) { UResourceBundle mz = zoneBundle.get(idx); String mzid = mz.getString(0); String fromStr = "1970-01-01 00:00"; String toStr = "9999-12-31 23:59"; if (mz.getSize() == 3) { fromStr = mz.getString(1); toStr = mz.getString(2); } long from, to; from = parseDate(fromStr); to = parseDate(toStr); mzMaps.add(new MZMapEntry(mzid, from, to)); } } catch (MissingResourceException mre) { mzMaps = Collections.emptyList(); } return mzMaps; }
Example 13
Source File: ZoneMeta.java From fitnotifications with Apache License 2.0 | 4 votes |
/** * Return the canonical country code for this tzid. If we have none, or if the time zone * is not associated with a country or unknown, return null. When the given zone is the * primary zone of the country, true is set to isPrimary. */ public static String getCanonicalCountry(String tzid, Output<Boolean> isPrimary) { isPrimary.value = Boolean.FALSE; String country = getRegion(tzid); if (country != null && country.equals(kWorld)) { return null; } // Check the cache Boolean singleZone = SINGLE_COUNTRY_CACHE.get(tzid); if (singleZone == null) { Set<String> ids = TimeZone.getAvailableIDs(SystemTimeZoneType.CANONICAL_LOCATION, country, null); assert(ids.size() >= 1); singleZone = Boolean.valueOf(ids.size() <= 1); SINGLE_COUNTRY_CACHE.put(tzid, singleZone); } if (singleZone) { isPrimary.value = Boolean.TRUE; } else { // 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(ICUData.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); if (canonicalID != null && canonicalID.equals(primaryZone)) { isPrimary.value = Boolean.TRUE; } } } catch (MissingResourceException e) { // ignore } } return country; }
Example 14
Source File: OlsonTimeZone.java From fitnotifications with Apache License 2.0 | 4 votes |
private static UResourceBundle loadRule(UResourceBundle top, String ruleid) { UResourceBundle r = top.get("Rules"); r = r.get(ruleid); return r; }