本文整理匯總了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;
}
}