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

The following examples show how to use com.ibm.icu.util.UResourceBundle#STRING . 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: Collator.java    From fitnotifications with Apache License 2.0 6 votes vote down vote up
@Override
public void put(UResource.Key key, UResource.Value value, boolean noFallback) {
    UResource.Table collations = value.getTable();
    for (int i = 0; collations.getKeyAndValue(i, key, value); ++i) {
        int type = value.getType();
        if (type == UResourceBundle.STRING) {
            if (!hasDefault && key.contentEquals("default")) {
                String defcoll = value.getString();
                if (!defcoll.isEmpty()) {
                    values.remove(defcoll);
                    values.addFirst(defcoll);
                    hasDefault = true;
                }
            }
        } else if (type == UResourceBundle.TABLE && !key.startsWith("private-")) {
            String collkey = key.toString();
            if (!values.contains(collkey)) {
                values.add(collkey);
            }
        }
    }
}
 
Example 2
Source File: CalendarData.java    From fitnotifications with Apache License 2.0 6 votes vote down vote up
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;
        }
    }

    return list.toArray(new String[list.size()]);
}
 
Example 3
Source File: CalendarData.java    From fitnotifications with Apache License 2.0 6 votes vote down vote up
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()]);
}
 
Example 4
Source File: DateIntervalFormat.java    From fitnotifications with Apache License 2.0 5 votes vote down vote up
/**
 * Retrieves the concatenation DateTime pattern from the resource bundle.
 * @param locale Locale to retrieve.
 * @return Concatenation DateTime pattern.
 */
private String getConcatenationPattern(ULocale locale) {
    ICUResourceBundle rb = (ICUResourceBundle) UResourceBundle.getBundleInstance(ICUData.ICU_BASE_NAME, locale);
    ICUResourceBundle dtPatternsRb = rb.getWithFallback("calendar/gregorian/DateTimePatterns");
    ICUResourceBundle concatenationPatternRb = (ICUResourceBundle) dtPatternsRb.get(8);
    if (concatenationPatternRb.getType() == UResourceBundle.STRING) {
        return concatenationPatternRb.getString();
    } else {
        return concatenationPatternRb.getString(0);
    }
}
 
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: 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 "???";
    }
}