/** * Try to extract the rule name for "expand ordinal" from the given RuleBasedNumberFormat. * <p> * The rule name is locale sensitive, but usually starts with "%spellout-ordinal". * * @param rbnf * The RuleBasedNumberFormat from where we will try to extract the rule name. * @return The rule name for "ordinal spell out". */ protected static String getOrdinalRuleName(final RuleBasedNumberFormat rbnf) { List<String> l = Arrays.asList(rbnf.getRuleSetNames()); if (l.contains("%spellout-ordinal")) { return "%spellout-ordinal"; } else if (l.contains("%spellout-ordinal-masculine")) { return "%spellout-ordinal-masculine"; } else { for (String string : l) { if (string.startsWith("%spellout-ordinal")) { return string; } } } throw new UnsupportedOperationException("The locale " + rbnf.getLocale(ULocale.ACTUAL_LOCALE) + " doesn't support ordinal spelling."); }
/** * Try to extract the rule name for "expand ordinal" from the given RuleBasedNumberFormat. * <p> * The rule name is locale sensitive, but usually starts with "%spellout-ordinal". * * @param rbnf * The RuleBasedNumberFormat from where we will try to extract the rule name. * @return The rule name for "ordinal spell out". */ protected static String getOrdinalRuleName(final RuleBasedNumberFormat rbnf) { List<String> l = Arrays.asList(rbnf.getRuleSetNames()); if (l.contains("%spellout-ordinal")) { return "%spellout-ordinal"; } else if (l.contains("%spellout-ordinal-masculine")) { return "%spellout-ordinal-masculine"; } else { for (String string : l) { if (string.startsWith("%spellout-ordinal")) { return string; } } } throw new UnsupportedOperationException("The locale " + rbnf.getLocale(ULocale.ACTUAL_LOCALE) + " doesn't supports ordinal spelling."); } }
/** * Try to extract the rule name for "expand year" from the given RuleBasedNumberFormat. * <p> * The rule name is locale sensitive, but usually starts with "%spellout-numbering-year". * * @param rbnf * The RuleBasedNumberFormat from where we will try to extract the rule name. * @return The rule name for "year spell out". */ protected static String getYearRuleName(final RuleBasedNumberFormat rbnf) { List<String> l = Arrays.asList(rbnf.getRuleSetNames()); if (l.contains("%spellout-numbering-year")) { return "%spellout-numbering-year"; } else { for (String string : l) { if (string.startsWith("%spellout-numbering-year")) { return string; } } } throw new UnsupportedOperationException("The locale " + rbnf.getLocale(ULocale.ACTUAL_LOCALE) + " doesn't support year spelling."); }
/** * Try to extract the rule name for "expand ordinal" from the given RuleBasedNumberFormat. * <p> * The rule name is locale sensitive, but usually starts with "%spellout-ordinal". * * @param rbnf * The RuleBasedNumberFormat from where we will try to extract the rule name. * @return The rule name for "ordinal spell out". */ protected static String getOrdinalRuleName(final RuleBasedNumberFormat rbnf) { List<String> l = Arrays.asList(rbnf.getRuleSetNames()); if (l.contains("%spellout-ordinal")) { return "%spellout-ordinal"; } else if (l.contains("%spellout-ordinal-masculine")) { return "%spellout-ordinal-masculine"; } else { for (String string : l) { if (string.startsWith("%spellout-ordinal")) { return string; } } } throw new UnsupportedOperationException("The locale " + rbnf.getLocale(ULocale.ACTUAL_LOCALE) + " doesn't supports ordinal spelling."); } }
/** * Return the rule set display names for the provided locale. These are in the same order * as those returned by getRuleSetNames. The locale is matched against the locales for * which there is display name data, using normal fallback rules. If no locale matches, * the default display names are returned. (These are the internal rule set names minus * the leading '%'.) * @return an array of the locales that have display name information * @see #getRuleSetNames * @stable ICU 3.2 */ public String[] getRuleSetDisplayNames(ULocale loc) { String[] names = getNameListForLocale(loc); if (names != null) { return names.clone(); } names = getRuleSetNames(); for (int i = 0; i < names.length; ++i) { names[i] = names[i].substring(1); } return names; }