@Override public String select(Object context, double number) { FixedDecimal dec = (FixedDecimal) context; assert dec.source == (dec.isNegative ? -number : number); return pluralRules.select(dec); } }
private String getPluralForm(FixedDecimal fixedDecimal) { if (pluralRules == null) { return CompactDecimalDataCache.OTHER; } return pluralRules.select(fixedDecimal); }
/** * Given a number, returns the keyword of the first rule that applies * to the number. * @internal * @deprecated This API is ICU internal only. */ @Deprecated String select(PluralRules.FixedDecimal numberInfo) { return pluralRules.select(numberInfo); }
/** * Given a number, returns the keyword of the first rule that applies * to the number. * @internal * @deprecated This API is ICU internal only. */ @Deprecated String select(double number) { return pluralRules.select(number); }
private Integer getDifferentCategory(List<Integer> ints, String keyword) { for (int i = ints.size() - 1; i >= 0; --i) { Integer other = ints.get(i); String keywordOther = pluralRules.select(other); if (!keywordOther.equals(keyword)) { return other; } } return 37; }
/** * @internal * @deprecated This API is ICU internal only. */ @Deprecated public boolean addSample(String keyword, Number sample, int maxCount, Set<Double> result) { String selectedKeyword = sample instanceof FixedDecimal ? select((FixedDecimal)sample) : select(sample.doubleValue()); if (selectedKeyword.equals(keyword)) { result.add(sample.doubleValue()); if (--maxCount < 0) { return false; } } return true; }
/** * Selects the standard plural form for the number/formatter/rules. */ public static StandardPlural selectPlural(double number, NumberFormat numberFormat, PluralRules rules) { String pluralKeyword; if (numberFormat instanceof DecimalFormat) { pluralKeyword = rules.select(((DecimalFormat) numberFormat).getFixedDecimal(number)); } else { pluralKeyword = rules.select(number); } return StandardPlural.orOtherFromString(pluralKeyword); }
private int addSimpleSamples(PluralRules pluralRules, final int MAX_SAMPLES, Map<String, List<Double>> sampleMap, int keywordsRemaining, double val) { String keyword = pluralRules.select(val); boolean keyIsLimited = _keyLimitedMap.get(keyword); List<Double> list = sampleMap.get(keyword); if (list == null) { list = new ArrayList<Double>(MAX_SAMPLES); sampleMap.put(keyword, list); } else if (!keyIsLimited && list.size() == MAX_SAMPLES) { return keywordsRemaining; } list.add(Double.valueOf(val)); if (!keyIsLimited && list.size() == MAX_SAMPLES) { --keywordsRemaining; } return keywordsRemaining; }
private boolean addIfNotPresent(double d, Set<FixedDecimal> mentioned, Map<String, Set<FixedDecimal>> foundKeywords) { FixedDecimal numberInfo = new FixedDecimal(d); String keyword = pluralRules.select(numberInfo); if (!foundKeywords.containsKey(keyword) || keyword.equals("other")) { addRelation(foundKeywords, keyword, numberInfo); mentioned.add(numberInfo); if (keyword.equals("other")) { if (foundKeywords.get("other").size() > 1) { return true; } } } return false; }
String keyword = pluralRules.select(base); if (keywords.contains(keyword)) { continue;
/** * ResolvePlural (pluralRules, x) * * @param pluralRules * the pluralRules object * @param x * the number value * @return the locale specific plural form */ @SuppressWarnings("deprecation") public static String ResolvePlural(PluralRulesObject pluralRules, double x) { /* steps 1-2 (not applicable) */ /* step 3 */ if (!Double.isFinite(x)) { return "other"; } /* steps 4-8 */ return pluralRules.getPluralRules().select(pluralRules.toFixedDecimal(x)); }
/** * Selects the standard plural form for the number/formatter/rules. */ public static StandardPlural selectPlural( Number number, NumberFormat fmt, PluralRules rules, StringBuffer formattedNumber, FieldPosition pos) { UFieldPosition fpos = new UFieldPosition(pos.getFieldAttribute(), pos.getField()); fmt.format(number, formattedNumber, fpos); // TODO: Long, BigDecimal & BigInteger may not fit into doubleValue(). FixedDecimal fd = new FixedDecimal( number.doubleValue(), fpos.getCountVisibleFractionDigits(), fpos.getFractionDigits()); String pluralKeyword = rules.select(fd); pos.setBeginIndex(fpos.getBeginIndex()); pos.setEndIndex(fpos.getEndIndex()); return StandardPlural.orOtherFromString(pluralKeyword); }
String pluralKeyword = PluralRules.forLocale(locale).select(pluralValue - offset); SoyMsgPluralCaseSpec.Type correctCaseType = new SoyMsgPluralCaseSpec(pluralKeyword).getType();
String pluralKeyword = PluralRules.forLocale(locale).select(pluralValue - offset); SoyMsgPluralCaseSpec.Type correctCaseType = new SoyMsgPluralCaseSpec(pluralKeyword).getType();
String pluralKeyword = PluralRules.forLocale(locale).select(currentPluralRemainderValue); SoyMsgPluralCaseSpec.Type correctCaseType = new SoyMsgPluralCaseSpec(pluralKeyword).getType();