Java Code Examples for com.ibm.icu.util.UResourceBundle#INT

The following examples show how to use com.ibm.icu.util.UResourceBundle#INT . 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: ZoneMeta.java    From fitnotifications with Apache License 2.0 6 votes vote down vote up
/**
 * 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 2
Source File: ZoneMeta.java    From fitnotifications with Apache License 2.0 5 votes vote down vote up
/**
 * 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 3
Source File: ICUResourceBundleReader.java    From fitnotifications with Apache License 2.0 5 votes vote down vote up
@Override
public int getInt() {
    if (RES_GET_TYPE(res) != UResourceBundle.INT) {
        throw new UResourceTypeMismatchException("");
    }
    return RES_GET_INT(res);
}
 
Example 4
Source File: ICUResourceBundleReader.java    From fitnotifications with Apache License 2.0 5 votes vote down vote up
@Override
public int getUInt() {
    if (RES_GET_TYPE(res) != UResourceBundle.INT) {
        throw new UResourceTypeMismatchException("");
    }
    return RES_GET_UINT(res);
}
 
Example 5
Source File: UResource.java    From fitnotifications with Apache License 2.0 5 votes vote down vote up
/**
 * Only for debugging.
 */
@Override
public String toString() {
    switch(getType()) {
    case UResourceBundle.STRING:
        return getString();
    case UResourceBundle.INT:
        return Integer.toString(getInt());
    case UResourceBundle.INT_VECTOR:
        int[] iv = getIntVector();
        StringBuilder sb = new StringBuilder("[");
        sb.append(iv.length).append("]{");
        if (iv.length != 0) {
            sb.append(iv[0]);
            for (int i = 1; i < iv.length; ++i) {
                sb.append(", ").append(iv[i]);
            }
        }
        return sb.append('}').toString();
    case UResourceBundle.BINARY:
        return "(binary blob)";
    case UResourceBundle.ARRAY:
        return "(array)";
    case UResourceBundle.TABLE:
        return "(table)";
    default:  // should not occur
        return "???";
    }
}
 
Example 6
Source File: ICUResourceBundleReader.java    From trekarta with GNU General Public License v3.0 5 votes vote down vote up
@Override
public int getInt() {
    if (RES_GET_TYPE(res) != UResourceBundle.INT) {
        throw new UResourceTypeMismatchException("");
    }
    return RES_GET_INT(res);
}
 
Example 7
Source File: ICUResourceBundleReader.java    From trekarta with GNU General Public License v3.0 5 votes vote down vote up
@Override
public int getUInt() {
    if (RES_GET_TYPE(res) != UResourceBundle.INT) {
        throw new UResourceTypeMismatchException("");
    }
    return RES_GET_UINT(res);
}
 
Example 8
Source File: UResource.java    From trekarta with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Only for debugging.
 */
@Override
public String toString() {
    switch(getType()) {
    case UResourceBundle.STRING:
        return getString();
    case UResourceBundle.INT:
        return Integer.toString(getInt());
    case UResourceBundle.INT_VECTOR:
        int[] iv = getIntVector();
        StringBuilder sb = new StringBuilder("[");
        sb.append(iv.length).append("]{");
        if (iv.length != 0) {
            sb.append(iv[0]);
            for (int i = 1; i < iv.length; ++i) {
                sb.append(", ").append(iv[i]);
            }
        }
        return sb.append('}').toString();
    case UResourceBundle.BINARY:
        return "(binary blob)";
    case UResourceBundle.ARRAY:
        return "(array)";
    case UResourceBundle.TABLE:
        return "(table)";
    default:  // should not occur
        return "???";
    }
}