For Chinese, the results are not yet optimal, and it is probably best best not to use these index characters. The
- * class can still be used to get the correct sorting order, but the index characters should be suppressed.
*
Additional collation parameters can be passed in as part of the locale name. For example, German plus numeric
* sorting would be "de@kn-true".
*
In the initial version, a limit of 100 buckets is placed on these lists. This may change or become configureable in
@@ -159,7 +157,7 @@ public final class AlphabeticIndex> implements Iterable<
comparator = (RuleBasedCollator) collator;
comparator.setStrength(Collator.PRIMARY);
firstScriptCharacters = FIRST_CHARS_IN_SCRIPTS;
- addIndexCharacters(exemplarChars);
+ addLabels(exemplarChars);
}
/**
@@ -169,7 +167,7 @@ public final class AlphabeticIndex> implements Iterable<
* @draft ICU 4.6
* @provisional This API might change or be removed in a future release.
*/
- public AlphabeticIndex addIndexCharacters(UnicodeSet additions) {
+ public AlphabeticIndex addLabels(UnicodeSet additions) {
initialLabels.addAll(additions);
indexCharacters = null;
return this;
@@ -182,7 +180,7 @@ public final class AlphabeticIndex> implements Iterable<
* @draft ICU 4.6
* @provisional This API might change or be removed in a future release.
*/
- public AlphabeticIndex addIndexCharacters(ULocale... additions) {
+ public AlphabeticIndex addLabels(ULocale... additions) {
for (ULocale addition : additions) {
initialLabels.addAll(getIndexExemplars(addition));
}
@@ -200,6 +198,18 @@ public final class AlphabeticIndex> implements Iterable<
return this;
}
+ /**
+ * Get the default label used in the IndexCharacters' locale for underflow, eg the last item in: X Y Z …
+ *
+ * @return underflow label
+ * @draft ICU 4.6
+ * @provisional This API might change or be removed in a future release.
+ */
+ public String getUnderflowLabel() {
+ return underflowLabel; // TODO get localized version
+ }
+
+
/**
* Set the underflowLabel label
* @param underflowLabel see class description
@@ -210,6 +220,18 @@ public final class AlphabeticIndex> implements Iterable<
return this;
}
+ /**
+ * Get the default label used in the IndexCharacters' locale for overflow, eg the first item in: … A B C
+ *
+ * @return overflow label
+ * @draft ICU 4.6
+ * @provisional This API might change or be removed in a future release.
+ */
+ public String getOverflowLabel() {
+ return overflowLabel; // TODO get localized version
+ }
+
+
/**
* Set the inflowLabel label
* @param inflowLabel see class description
@@ -220,12 +242,51 @@ public final class AlphabeticIndex> implements Iterable<
return this;
}
+ /**
+ * Get the default label used for abbreviated buckets between other labels. For example, consider the labels
+ * for Latin and Greek are used: X Y Z … Α Β Γ.
+ *
+ * @return inflow label
+ * @draft ICU 4.6
+ * @provisional This API might change or be removed in a future release.
+ */
+ public String getInflowLabel() {
+ return inflowLabel; // TODO get localized version
+ }
+
+
+ /**
+ * Get the limit on the number of labels in the index. The number of buckets can be slightly larger: see getBucketCount().
+ *
+ * @return maxLabelCount maximum number of labels.
+ * @draft ICU 4.6
+ * @provisional This API might change or be removed in a future release.
+ */
+ public int getMaxLabelCount() {
+ return maxLabelCount;
+ }
+
+ /**
+ * Set a limit on the number of labels in the index. The number of buckets can be slightly larger: see
+ * getBucketCount().
+ *
+ * @return maxLabelCount label Set the maximum number of labels. Currently, if the number is exceeded, then every
+ * nth item is removed to bring the count down. A more sophisticated mechanism may be available in the
+ * future.
+ * @draft ICU 4.6
+ * @provisional This API might change or be removed in a future release.
+ */
+ public AlphabeticIndex setMaxLabelCount(int maxLabelCount) {
+ this.maxLabelCount = maxLabelCount;
+ return this;
+ }
+
private void initLabels() {
UnicodeSet exemplars = new UnicodeSet(initialLabels);
- // first sort them, with an "best" ordering among items that are the same according
- // to the collator
- // The JDK inexplicably didn't make Collators be Comparator!
+ // First sort them, with an "best" ordering among items that are the same according
+ // to the collator.
+ // Re the warning: the JDK inexplicably didn't make Collators be Comparator!
Set preferenceSorting = new TreeSet(new MultiComparator