當前位置: 首頁>>代碼示例>>Java>>正文


Java Collator.SECONDARY屬性代碼示例

本文整理匯總了Java中java.text.Collator.SECONDARY屬性的典型用法代碼示例。如果您正苦於以下問題:Java Collator.SECONDARY屬性的具體用法?Java Collator.SECONDARY怎麽用?Java Collator.SECONDARY使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在java.text.Collator的用法示例。


在下文中一共展示了Collator.SECONDARY屬性的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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 );
     }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:28,代碼來源:StringComparable.java

示例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;
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:10,代碼來源:StringComparable.java

示例3: compareStrings

private int compareStrings(boolean caseSensitive, String s1, String s2) {
    if (caseSensitive) {
        if (tertiaryCollator == null) {
            tertiaryCollator = new DocCollator(configuration.locale, Collator.TERTIARY);
        }
        return tertiaryCollator.compare(s1, s2);
    }
    if (secondaryCollator == null) {
        secondaryCollator = new DocCollator(configuration.locale, Collator.SECONDARY);
    }
    return secondaryCollator.compare(s1, s2);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:12,代碼來源:Utils.java


注:本文中的java.text.Collator.SECONDARY屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。