本文整理汇总了Java中com.ibm.icu.text.RuleBasedCollator.setAlternateHandlingShifted方法的典型用法代码示例。如果您正苦于以下问题:Java RuleBasedCollator.setAlternateHandlingShifted方法的具体用法?Java RuleBasedCollator.setAlternateHandlingShifted怎么用?Java RuleBasedCollator.setAlternateHandlingShifted使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.ibm.icu.text.RuleBasedCollator
的用法示例。
在下文中一共展示了RuleBasedCollator.setAlternateHandlingShifted方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: inform
import com.ibm.icu.text.RuleBasedCollator; //导入方法依赖的package包/类
public void inform(ResourceLoader loader) throws IOException {
if (localeID != null) {
// create from a system collator, based on Locale.
collator = createFromLocale(localeID);
} else {
// create from a custom ruleset
collator = createFromRules(custom, loader);
}
// set the strength flag, otherwise it will be the default.
if (strength != null) {
if (strength.equalsIgnoreCase("primary"))
collator.setStrength(Collator.PRIMARY);
else if (strength.equalsIgnoreCase("secondary"))
collator.setStrength(Collator.SECONDARY);
else if (strength.equalsIgnoreCase("tertiary"))
collator.setStrength(Collator.TERTIARY);
else if (strength.equalsIgnoreCase("quaternary"))
collator.setStrength(Collator.QUATERNARY);
else if (strength.equalsIgnoreCase("identical"))
collator.setStrength(Collator.IDENTICAL);
else
throw new IllegalArgumentException("Invalid strength: " + strength);
}
// set the decomposition flag, otherwise it will be the default.
if (decomposition != null) {
if (decomposition.equalsIgnoreCase("no"))
collator.setDecomposition(Collator.NO_DECOMPOSITION);
else if (decomposition.equalsIgnoreCase("canonical"))
collator.setDecomposition(Collator.CANONICAL_DECOMPOSITION);
else
throw new IllegalArgumentException("Invalid decomposition: " + decomposition);
}
// expert options: concrete subclasses are always a RuleBasedCollator
RuleBasedCollator rbc = (RuleBasedCollator) collator;
if (alternate != null) {
if (alternate.equalsIgnoreCase("shifted")) {
rbc.setAlternateHandlingShifted(true);
} else if (alternate.equalsIgnoreCase("non-ignorable")) {
rbc.setAlternateHandlingShifted(false);
} else {
throw new IllegalArgumentException("Invalid alternate: " + alternate);
}
}
if (caseLevel != null) {
rbc.setCaseLevel(Boolean.parseBoolean(caseLevel));
}
if (caseFirst != null) {
if (caseFirst.equalsIgnoreCase("lower")) {
rbc.setLowerCaseFirst(true);
} else if (caseFirst.equalsIgnoreCase("upper")) {
rbc.setUpperCaseFirst(true);
} else {
throw new IllegalArgumentException("Invalid caseFirst: " + caseFirst);
}
}
if (numeric != null) {
rbc.setNumericCollation(Boolean.parseBoolean(numeric));
}
if (variableTop != null) {
rbc.setVariableTop(variableTop);
}
}
示例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;
}