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


Java RuleBasedCollator.setDecomposition方法代碼示例

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


在下文中一共展示了RuleBasedCollator.setDecomposition方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testEqualsObject

import java.text.RuleBasedCollator; //導入方法依賴的package包/類
public void testEqualsObject() throws ParseException {
    String rule = "< a < b < c < d < e";
    RuleBasedCollator coll = new RuleBasedCollator(rule);

    assertEquals(Collator.TERTIARY, coll.getStrength());
    // This is a harmony test, but it assumes that RuleBasedCollators default to
    // NO_DECOMPOSITION, which isn't true on Android.
    // assertEquals(Collator.NO_DECOMPOSITION, coll.getDecomposition());
    RuleBasedCollator other = new RuleBasedCollator(rule);
    assertTrue(coll.equals(other));

    coll.setStrength(Collator.PRIMARY);
    assertFalse(coll.equals(other));

    coll.setStrength(Collator.TERTIARY);
    coll.setDecomposition(Collator.CANONICAL_DECOMPOSITION);
    other.setDecomposition(Collator.NO_DECOMPOSITION); // See comment above.
    assertFalse(coll.equals(other));
}
 
開發者ID:keplersj,項目名稱:In-the-Box-Fork,代碼行數:20,代碼來源:CollatorTest.java

示例2: testEqualsObject

import java.text.RuleBasedCollator; //導入方法依賴的package包/類
public void testEqualsObject() throws ParseException {
    String rule = "< a < b < c < d < e";
    RuleBasedCollator coll = new RuleBasedCollator(rule);

    assertEquals(Collator.TERTIARY, coll.getStrength());
    assertEquals(Collator.NO_DECOMPOSITION, coll.getDecomposition());
    RuleBasedCollator other = new RuleBasedCollator(rule);
    assertTrue(coll.equals(other));

    coll.setStrength(Collator.PRIMARY);
    assertFalse(coll.equals(other));

    coll.setStrength(Collator.TERTIARY);
    coll.setDecomposition(Collator.CANONICAL_DECOMPOSITION);
    assertFalse(coll.equals(other));
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:17,代碼來源:RuleBasedCollatorTest.java

示例3: testDecomposition

import java.text.RuleBasedCollator; //導入方法依賴的package包/類
public void testDecomposition() {
    RuleBasedCollator coll = (RuleBasedCollator) Collator
            .getInstance(Locale.US);
    for (int i = 0; i < 2; i++) {
        coll.setDecomposition(i);
        assertEquals(i, coll.getDecomposition());
    }
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:9,代碼來源:RuleBasedCollatorTest.java

示例4: ensureCollators

import java.text.RuleBasedCollator; //導入方法依賴的package包/類
/**
 * Ensure that the cached collators are for the current locale.
 */
private static void ensureCollators() {
    final Locale locale = Locale.getDefault();
    if (locale.equals(sCollatorLocale)) {
        return;
    }
    sCollatorLocale = locale;

    sCachedCompressingCollator = (RuleBasedCollator) Collator.getInstance(locale);
    sCachedCompressingCollator.setStrength(Collator.PRIMARY);
    sCachedCompressingCollator.setDecomposition(Collator.CANONICAL_DECOMPOSITION);

    sCachedComplexityCollator = (RuleBasedCollator) Collator.getInstance(locale);
    sCachedComplexityCollator.setStrength(Collator.SECONDARY);
}
 
開發者ID:SilentCircle,項目名稱:silent-contacts-android,代碼行數:18,代碼來源:NameNormalizer.java

示例5: CollatorCache

import java.text.RuleBasedCollator; //導入方法依賴的package包/類
public CollatorCache ()
{
  super (aLocale -> {
    if (aLocale == null)
    {
      s_aLogger.error ("Very weird: no locale passed in. Falling back to system locale.");
      return Collator.getInstance (SystemHelper.getSystemLocale ());
    }

    // Collator.getInstance is synchronized and therefore extremely slow ->
    // that's why we put a cache around it!
    final Collator aCollator = Collator.getInstance (aLocale);
    if (aCollator == null)
    {
      final Locale aSystemLocale = SystemHelper.getSystemLocale ();
      s_aLogger.error ("Failed to get Collator for Locale " +
                       aLocale +
                       " - using Collator for syste locale " +
                       aSystemLocale +
                       "!");
      return Collator.getInstance (aSystemLocale);
    }
    if (!(aCollator instanceof RuleBasedCollator))
    {
      s_aLogger.warn ("Collator.getInstance did not return a RulleBasedCollator but a " +
                      aCollator.getClass ().getName ());
      return aCollator;
    }

    try
    {
      final String sRules = ((RuleBasedCollator) aCollator).getRules ();
      if (!sRules.contains ("<'.'<"))
      {
        // Nothing to replace - use collator as it is
        s_aLogger.warn ("Failed to identify the Collator rule part to be replaced. Locale used: " + aLocale);
        return aCollator;
      }

      final String sNewRules = StringHelper.replaceAll (sRules, "<'.'<", "<' '<'.'<");
      final RuleBasedCollator aNewCollator = new RuleBasedCollator (sNewRules);
      aNewCollator.setStrength (Collator.TERTIARY);
      aNewCollator.setDecomposition (Collator.FULL_DECOMPOSITION);
      return aNewCollator;
    }
    catch (final ParseException ex)
    {
      throw new IllegalStateException ("Failed to parse collator rule set for locale " + aLocale, ex);
    }
  }, 500, CollatorHelper.class.getName ());
}
 
開發者ID:phax,項目名稱:ph-commons,代碼行數:52,代碼來源:CollatorHelper.java


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