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