当前位置: 首页>>代码示例>>Java>>正文


Java Collator.PRIMARY属性代码示例

本文整理汇总了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 );
     }
}
 
开发者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


注:本文中的java.text.Collator.PRIMARY属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。