/** * Returns all the values that trigger this keyword, or null if the number of such * values is unlimited. * * @param keyword the keyword * @return the values that trigger this keyword, or null. The returned collection * is immutable. It will be empty if the keyword is not defined. * @stable ICU 4.8 */ Collection<Double> getAllKeywordValues(String keyword) { // HACK for now if (!pluralRules.getKeywords().contains(keyword)) { return Collections.<Double>emptyList(); } Collection<Double> result = getKeySamplesMap().get(keyword); // We depend on MAX_SAMPLES here. It's possible for a conjunction // of unlimited rules that 'looks' unlimited to return a limited // number of values. There's no bounds to this limited number, in // general, because you can construct arbitrarily complex rules. Since // we always generate 3 samples if a rule is really unlimited, that's // where we put the cutoff. if (result.size() > 2 && !_keyLimitedMap.get(keyword)) { return null; } return result; } }
if (!pluralRules.getKeywords().contains(keyword)) { return KeywordStatus.INVALID;
/** * [[PluralCategories]] * * @return the plural categories */ public ArrayObject getPluralCategories() { if (pluralCategories == null) { pluralCategories = CreateArrayFromList(realm.defaultContext(), getPluralRules().getKeywords()); } return pluralCategories; }
this.units = otherPluralVariant(pluralAffixes, divisor, debugCreationErrors); this.currencyUnits = otherPluralVariant(pluralAffixes, divisor, debugCreationErrors); if (!pluralRules.getKeywords().equals(this.units.keySet())) { debugCreationErrors.add("Missmatch in pluralCategories, should be: " + pluralRules.getKeywords() + ", was actually " + this.units.keySet());
public PluralSamples(PluralRules pluralRules) { this.pluralRules = pluralRules; Set<String> keywords = pluralRules.getKeywords();
Set<String> keywords = pluralRules.getKeywords(); for (int i = 0; i < timeUnits.length; ++i) {
private void setup() { if (locale == null) { if (format != null) { locale = format.getLocale(null); } else { locale = ULocale.getDefault(Category.FORMAT); } // Needed for getLocale(ULocale.VALID_LOCALE) setLocale(locale, locale); } if (format == null) { format = NumberFormat.getNumberInstance(locale); } pluralRules = PluralRules.forLocale(locale); timeUnitToCountToPatterns = new HashMap<TimeUnit, Map<String, Object[]>>(); Set<String> pluralKeywords = pluralRules.getKeywords(); setup("units/duration", timeUnitToCountToPatterns, FULL_NAME, pluralKeywords); setup("unitsShort/duration", timeUnitToCountToPatterns, ABBREVIATED_NAME, pluralKeywords); isReady = true; }