本文整理汇总了Java中com.ibm.icu.text.RuleBasedCollator.setStrength方法的典型用法代码示例。如果您正苦于以下问题:Java RuleBasedCollator.setStrength方法的具体用法?Java RuleBasedCollator.setStrength怎么用?Java RuleBasedCollator.setStrength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.ibm.icu.text.RuleBasedCollator
的用法示例。
在下文中一共展示了RuleBasedCollator.setStrength方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setCollatorStrength
import com.ibm.icu.text.RuleBasedCollator; //导入方法依赖的package包/类
private static void setCollatorStrength(RuleBasedCollator collator, CollationSpecifier specifier) {
if (specifier.caseSensitive() && specifier.accentSensitive()) {
collator.setStrength(Collator.TERTIARY);
collator.setCaseLevel(false);
}
else if (specifier.caseSensitive() && !specifier.accentSensitive()) {
collator.setCaseLevel(true);
collator.setStrength(Collator.PRIMARY);
}
else if (!specifier.caseSensitive() && specifier.accentSensitive()) {
collator.setStrength(Collator.SECONDARY);
collator.setCaseLevel(false);
}
else {
collator.setStrength(Collator.PRIMARY);
collator.setCaseLevel(false);
}
}
示例2: KeyComparator
import com.ibm.icu.text.RuleBasedCollator; //导入方法依赖的package包/类
public KeyComparator(int strength, Map<String, CollationKey> cache, boolean alternateHandlingShifted) {
try {
collator = (RuleBasedCollator)Collator.getInstance(Locale.ROOT).clone();
} catch (CloneNotSupportedException e) {
throw new RuntimeException(e);
}
collator.setStrength(strength);
collator.setAlternateHandlingShifted(alternateHandlingShifted);
this.cache = cache;
}
示例3: BlobDescriptorList
import com.ibm.icu.text.RuleBasedCollator; //导入方法依赖的package包/类
BlobDescriptorList(Application app, DescriptorStore<BlobDescriptor> store, int maxSize) {
this.app = app;
this.store = store;
this.maxSize = maxSize;
this.list = new ArrayList<BlobDescriptor>();
this.filteredList = new ArrayList<BlobDescriptor>();
this.dataSetObservable = new DataSetObservable();
this.filter = "";
keyComparator = Slob.Strength.QUATERNARY.comparator;
nameComparatorAsc = new Comparator<BlobDescriptor>() {
@Override
public int compare(BlobDescriptor b1, BlobDescriptor b2) {
return keyComparator.compare(b1.key, b2.key);
}
};
nameComparatorDesc = Collections.reverseOrder(nameComparatorAsc);
timeComparatorAsc = new Comparator<BlobDescriptor>() {
@Override
public int compare(BlobDescriptor b1, BlobDescriptor b2) {
return Util.compare(b1.createdAt, b2.createdAt);
}
};
timeComparatorDesc = Collections.reverseOrder(timeComparatorAsc);
lastAccessComparator = new Comparator<BlobDescriptor>() {
@Override
public int compare(BlobDescriptor b1, BlobDescriptor b2) {
return Util.compare(b2.lastAccess, b1.lastAccess);
}
};
order = SortOrder.TIME;
ascending = false;
setSort(order, ascending);
try {
filterCollator = (RuleBasedCollator) Collator.getInstance(Locale.ROOT).clone();
} catch (CloneNotSupportedException e) {
throw new RuntimeException(e);
}
filterCollator.setStrength(Collator.PRIMARY);
filterCollator.setAlternateHandlingShifted(true);
handler = new Handler(Looper.getMainLooper());
}
示例4: makeCheck
import com.ibm.icu.text.RuleBasedCollator; //导入方法依赖的package包/类
@Override
protected void makeCheck(Placeholder target, ImmutableList<String> tokenizedInput, ULocale locale,
String message) {
if (tokenizedInput.size() < 2) {
// Test passed. Nothing to sort.
return;
}
int strength = Collator.SECONDARY;
if (!target.isLenient()) {
if (!target.isStrict()) {
strength = Collator.TERTIARY;
} else {
strength = Collator.IDENTICAL;
}
}
// Init collators.
Collator collator = Collator.getInstance(locale);
ImmutableList.Builder<Collator> collators = ImmutableList.builder();
collators.add(collator);
try {
Collator collator2 = (RuleBasedCollator) collator.clone();
collator2.setStrength(strength);
collators.add(collator2);
RuleBasedCollator collator3 = (RuleBasedCollator) collator.clone();
collator3.setStrength(strength);
collator3.setAlternateHandlingShifted(true);
collators.add(collator3);
RuleBasedCollator collator4 = (RuleBasedCollator) collator.clone();
collator4.setStrength(strength);
collator4.setNumericCollation(true);
collators.add(collator4);
RuleBasedCollator collator5 = (RuleBasedCollator) collator.clone();
collator5.setStrength(strength);
collator5.setAlternateHandlingShifted(true);
collator5.setNumericCollation(true);
collators.add(collator5);
} catch (CloneNotSupportedException e) {
// Do nothing.
}
makeCheck(collators.build(), tokenizedInput, locale, message);
}
示例5: createCollator
import com.ibm.icu.text.RuleBasedCollator; //导入方法依赖的package包/类
private Collator createCollator() {
ULocale locale = ULocale.forLanguageTag(this.locale);
if ("search".equals(usage)) {
// "search" usage cannot be set through unicode extensions (u-co-search), handle here:
locale = locale.setKeywordValue("collation", "search");
}
RuleBasedCollator collator = (RuleBasedCollator) Collator.getInstance(locale);
collator.setDecomposition(Collator.CANONICAL_DECOMPOSITION);
collator.setNumericCollation(numeric);
switch (caseFirst) {
case "upper":
collator.setUpperCaseFirst(true);
break;
case "lower":
collator.setLowerCaseFirst(true);
break;
case "false":
if (collator.isLowerCaseFirst()) {
collator.setLowerCaseFirst(false);
}
if (collator.isUpperCaseFirst()) {
collator.setUpperCaseFirst(false);
}
break;
default:
throw new AssertionError();
}
switch (sensitivity) {
case "base":
collator.setStrength(Collator.PRIMARY);
break;
case "accent":
collator.setStrength(Collator.SECONDARY);
break;
case "case":
collator.setStrength(Collator.PRIMARY);
collator.setCaseLevel(true);
break;
case "variant":
collator.setStrength(Collator.TERTIARY);
break;
default:
throw new AssertionError();
}
collator.setAlternateHandlingShifted(ignorePunctuation);
return collator;
}