本文整理汇总了Java中java.text.Collator.PRIMARY属性的典型用法代码示例。如果您正苦于以下问题:Java Collator.PRIMARY属性的具体用法?Java Collator.PRIMARY怎么用?Java Collator.PRIMARY使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类java.text.Collator
的用法示例。
在下文中一共展示了Collator.PRIMARY属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: compareTo
public int compareTo(Object o) {
final String pattern = ((StringComparable)o).toString();
if(m_text.equals(pattern)){//Code-point equals
return 0;
}
final int savedStrength = m_collator.getStrength();
int comp = 0;
// Is there difference more significant than case-order?
if(((savedStrength == Collator.PRIMARY) || (savedStrength == Collator.SECONDARY))){
comp = m_collator.compare(m_text, pattern );
}else{// more than SECONDARY
m_collator.setStrength(Collator.SECONDARY);
comp = m_collator.compare(m_text, pattern );
m_collator.setStrength(savedStrength);
}
if(comp != 0){//Difference more significant than case-order
return comp ;
}
// No difference more significant than case-order.
// Find case difference
comp = getCaseDiff(m_text, pattern);
if(comp != 0){
return comp;
}else{// No case differences. Less significant difference could exist
return m_collator.compare(m_text, pattern );
}
}
示例2: getMask
private static final int getMask(final int strength) {
switch (strength) {
case Collator.PRIMARY:
return 0xFFFF0000;
case Collator.SECONDARY:
return 0xFFFFFF00;
default:
return 0xFFFFFFFF;
}
}