/** * 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 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."); } }
/** * 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."); } }