Home | History | Annotate | Download | only in collator

Lines Matching defs:collator

16 package android.icu.dev.test.collator;
35 import android.icu.text.Collator;
36 import android.icu.text.Collator.CollatorFactory;
51 * - Collator.getCollationKey
59 Collator col = Collator.getInstance();
60 col.setStrength(Collator.TERTIARY);
99 col = Collator.getInstance();
101 errln("Collator.getInstance() failed");
103 if (col.getStrength() != Collator.TERTIARY){
108 col.setStrength(Collator.IDENTICAL);
124 col.setStrength(Collator.SECONDARY);
194 * This tests the comparison convenience methods of a collator object.
202 Collator col = Collator.getInstance(Locale.ENGLISH);
211 col.setStrength(Collator.SECONDARY);
217 col.setStrength(Collator.PRIMARY);
230 Collator en_US = null, el_GR = null, vi_VN = null;
232 en_US = Collator.getInstance(new Locale("en", "US"));
233 el_GR = Collator.getInstance(new Locale("el", "GR"));
234 vi_VN = Collator.getInstance(new Locale("vi", "VN"));
238 if (vi_VN.getDecomposition() != Collator.CANONICAL_DECOMPOSITION)
243 if (el_GR.getDecomposition() != Collator.CANONICAL_DECOMPOSITION)
248 if (en_US.getDecomposition() != Collator.NO_DECOMPOSITION)
255 * This tests the duplication of a collator object.
260 Collator col1 = Collator.getInstance(Locale.ENGLISH);
262 // Collator col2 = (Collator)col1.clone();
289 Collator col = Collator.getInstance(Locale.ENGLISH);
399 * This tests the hashCode method of a collator object.
404 Collator col1 = Collator.getInstance(Locale.ENGLISH);
406 Collator col2 = null;
409 col2 = Collator.getInstance(dk);
415 Collator col3 = null;
417 col3 = Collator.getInstance(Locale.ENGLISH);
423 logln("Collator.hashCode() testing ...");
445 * This tests the properties of a collator object.
462 Collator col = Collator.getInstance(Locale.ENGLISH);
486 logln("testing Collator.getStrength() method ...");
487 doAssert((col.getStrength() == Collator.TERTIARY), "collation object has the wrong strength");
488 doAssert((col.getStrength() != Collator.PRIMARY), "collation object's strength is primary difference");
490 logln("testing Collator.setStrength() method ...");
491 col.setStrength(Collator.SECONDARY);
492 doAssert((col.getStrength() != Collator.TERTIARY), "collation object's strength is secondary difference");
493 doAssert((col.getStrength() != Collator.PRIMARY), "collation object's strength is primary difference");
494 doAssert((col.getStrength() == Collator.SECONDARY), "collation object has the wrong strength");
496 logln("testing Collator.setDecomposition() method ...");
497 col.setDecomposition(Collator.NO_DECOMPOSITION);
498 doAssert((col.getDecomposition() != Collator.CANONICAL_DECOMPOSITION), "Decomposition mode != Collator.CANONICAL_DECOMPOSITION");
499 doAssert((col.getDecomposition() == Collator.NO_DECOMPOSITION), "Decomposition mode = Collator.NO_DECOMPOSITION");
503 // RuleBasedCollator rcol = (RuleBasedCollator)Collator.getInstance(new Locale("da", "DK"));
508 col = Collator.getInstance(Locale.FRENCH);
514 col.setStrength(Collator.PRIMARY);
515 logln("testing Collator.getStrength() method again ...");
516 doAssert((col.getStrength() != Collator.TERTIARY), "collation object has the wrong strength");
517 doAssert((col.getStrength() == Collator.PRIMARY), "collation object's strength is not primary difference");
519 logln("testing French Collator.setStrength() method ...");
520 col.setStrength(Collator.TERTIARY);
521 doAssert((col.getStrength() == Collator.TERTIARY), "collation object's strength is not tertiary difference");
522 doAssert((col.getStrength() != Collator.PRIMARY), "collation object's strength is primary difference");
523 doAssert((col.getStrength() != Collator.SECONDARY), "collation object's strength is secondary difference");
532 Collator junk = Collator.getInstance(abcd);
533 Collator col = Collator.getInstance();
540 Collator frCol = null;
542 frCol = Collator.getInstance(Locale.CANADA_FRENCH);
544 errln("Creating fr_CA collator failed.");
548 doAssert(!(frCol.equals(junk)), "The junk is the same as the fr_CA collator.");
549 logln("Collator property test ended.");
570 warnln("RuleBased Collator creation failed.");
577 errln("RuleBased Collator creation failed.");
584 errln("Failure: Empty rules for the collator should fail");
589 logln("PASS: Empty rules for the collator failed as expected");
594 col3 = (RuleBasedCollator)Collator.getInstance(locale);
596 errln("Fallback Collator creation failed.: %s");
601 col3 = (RuleBasedCollator)Collator.getInstance();
603 errln("Default Collator creation failed.: %s");
611 doAssert(!rule1.equals(rule2), "Default collator getRules failed");
612 doAssert(!rule2.equals(rule3), "Default collator getRules failed");
613 doAssert(!rule1.equals(rule3), "Default collator getRules failed");
618 errln("RuleBased Collator creation failed.");
623 doAssert(rule2.equals(rule4), "Default collator getRules failed");
631 Collator.getInstance(Locale.ENGLISH);
649 errln("RuleBased Collator creation failed for ! modifier.");
660 RuleBasedCollator coll = (RuleBasedCollator)Collator.getInstance(new Locale("","","")); //root
661 // logln("PASS: RuleBased Collator creation passed");
675 // one default collator & two complex ones
677 (RuleBasedCollator)Collator.getInstance(Locale.ENGLISH),
678 (RuleBasedCollator)Collator.getInstance(Locale.KOREA),
679 (RuleBasedCollator)Collator.getInstance(Locale.JAPAN)
691 errln("Error cloning collator");
694 someClonedCollators[index].setStrength(Collator.TERTIARY);
695 someCollators[index].setStrength(Collator.PRIMARY);
726 logln("Instantiating a collator from "+rules[i]);
740 warnln("Couldn't open collator with rules "+ rules[i]);
746 * Simple test to see if Collator is subclassable.
752 class TestCollator extends Collator
826 Collator col1 = new TestCollator();
827 Collator col2 = new TestCollator();
861 col1.setStrength(Collator.SECONDARY);
862 assertNotEquals("getStrength()", Collator.PRIMARY, col1.getStrength());
867 assertNotEquals("setStrength2().getStrength()", Collator.PRIMARY,
868 col1.setStrength2(Collator.IDENTICAL).getStrength());
872 col1.setDecomposition(Collator.CANONICAL_DECOMPOSITION);
879 col1.setMaxVariable(Collator.ReorderCodes.CURRENCY);
894 assertFalse("getDisplayName()", Collator.getDisplayName(Locale.GERMAN).isEmpty());
895 assertFalse("getDisplayName()", Collator.getDisplayName(Locale.GERMAN, Locale.ITALIAN).isEmpty());
899 // Cover Collator.setLocale() which is only package-visible.
900 Object token = Collator.registerInstance(new TestCollator(), new ULocale("de-Japn-419"));
901 Collator.unregister(token);
911 col2.setStrength(Collator.PRIMARY);
913 fail("(frozen Collator).setStrength() should throw an exception");
918 Collator col3 = col2.cloneAsThawed();
925 * Simple test the collator setter and getters.
931 RuleBasedCollator collator = (RuleBasedCollator)Collator.getInstance();
932 int decomp = collator.getDecomposition();
933 int strength = collator.getStrength();
934 boolean alt = collator.isAlternateHandlingShifted();
935 boolean caselevel = collator.isCaseLevel();
936 boolean french = collator.isFrenchCollation();
937 boolean hquart = collator.isHiraganaQuaternary();
938 boolean lowercase = collator.isLowerCaseFirst();
939 boolean uppercase = collator.isUpperCaseFirst();
941 collator.setDecomposition(Collator.CANONICAL_DECOMPOSITION);
942 if (collator.getDecomposition() != Collator.CANONICAL_DECOMPOSITION) {
945 collator.setStrength(Collator.QUATERNARY);
946 if (collator.getStrength() != Collator.QUATERNARY) {
949 collator.setAlternateHandlingShifted(!alt);
950 if (collator.isAlternateHandlingShifted() == alt) {
953 collator.setCaseLevel(!caselevel);
954 if (collator.isCaseLevel() == caselevel) {
957 collator.setFrenchCollation(!french);
958 if (collator.isFrenchCollation() == french) {
961 collator.setHiraganaQuaternary(!hquart);
962 if (collator.isHiraganaQuaternary() != hquart) {
965 collator.setLowerCaseFirst(!lowercase);
966 if (collator.isLowerCaseFirst() == lowercase) {
969 collator.setUpperCaseFirst(!uppercase);
970 if (collator.isUpperCaseFirst() == uppercase) {
973 collator.setDecompositionDefault();
974 if (collator.getDecomposition() != decomp) {
977 collator.setStrengthDefault();
978 if (collator.getStrength() != strength) {
981 collator.setAlternateHandlingDefault();
982 if (collator.isAlternateHandlingShifted() != alt) {
985 collator.setCaseLevelDefault();
986 if (collator.isCaseLevel() != caselevel) {
989 collator.setFrenchCollationDefault();
990 if (collator.isFrenchCollation() != french) {
993 collator.setHiraganaQuaternaryDefault();
994 if (collator.isHiraganaQuaternary() != hquart) {
997 collator.setCaseFirstDefault();
998 if (collator.isLowerCaseFirst() != lowercase
999 || collator.isUpperCaseFirst() != uppercase) {
1006 // Use the root collator, not the default collator.
1008 RuleBasedCollator coll = (RuleBasedCollator)Collator.getInstance(ULocale.ROOT);
1051 RuleBasedCollator coll = (RuleBasedCollator)Collator.getInstance(ULocale.ROOT);
1054 coll.setMaxVariable(Collator.ReorderCodes.OTHERS);
1059 coll.setMaxVariable(Collator.ReorderCodes.CURRENCY);
1061 if(Collator.ReorderCodes.CURRENCY != coll.getMaxVariable()) {
1075 Collator coll = Collator.getInstance(new ULocale("root"));
1078 errln("Collator.getInstance(\"root\").getLocale(actual) != ULocale.ROOT; " +
1082 coll = Collator.getInstance(new ULocale(""));
1085 errln("Collator.getInstance(\"\").getLocale(actual) != ULocale.ROOT; " +
1124 coll = Collator.getInstance(new ULocale(requestedLocale));
1126 errln(String.format("Failed to open collator for %s with %s", requestedLocale, e));
1141 // If we open a collator for the actual locale, we should get an equivalent one again.
1142 Collator coll2;
1144 coll2 = Collator.getInstance(locale);
1146 errln(String.format("Failed to open collator for actual locale \"%s\" with %s",
1156 errln(String.format("[Coll actual \"%s\"]: Got different collator than before",
1161 /* completely non-existent locale for collator should get a root collator */
1164 coll = Collator.getInstance(new ULocale("blahaha"));
1166 errln("Failed to open collator with " + e);
1172 errln("Valid locale for nonexisting locale collator is \"" + name + "\" not root");
1177 errln("Actual locale for nonexisting locale collator is \"" + name + "\" not root");
1181 /* collator instantiated from rules should have all locales null */
1190 errln(String.format("For collator instantiated from rules, valid locale %s is not bogus",
1195 errln(String.format("For collator
1203 Collator coll = Collator.getInstance(new Locale("sh", ""));
1280 Collator.SECONDARY);
1284 Collator.SECONDARY);
1302 Collator.SECONDARY);
1304 Collator.SECONDARY);
1319 Locale[] list = Collator.getAvailableLocales();
1327 logln(" ...... Or display as: " + Collator.getDisplayName(list[i]));
1329 Collator.getDisplayName(list[i],Locale.CHINA));
1402 * The "collv2" builder omits mappings if the collator maps their
1430 coll = (RuleBasedCollator)Collator.getInstance(new ULocale(tests[i][0]));
1457 RuleBasedCollator c0 = (RuleBasedCollator)Collator.getInstance();
1458 c0.setStrength(Collator.TERTIARY);
1462 RuleBasedCollator c1 = (RuleBasedCollator)Collator.getInstance();
1463 c1.setStrength(Collator.TERTIARY);
1478 errln("Could not clone the collator");
1495 // It should have been possible to reproduce this with the root collator
1515 Collator c = Collator.getInstance();
1517 errln("Collator.setStrength(int) is suppose to return "
1534 Collator c = Collator.getInstance();
1536 errln("Collator.setDecomposition(int) is suppose to return "
1548 // The following class override public Collator createCollator(Locale loc)
1560 public Collator createCollator(ULocale c) {
1564 // The following class override public Collator createCollator(ULocale loc)
1576 public Collator createCollator(Locale c) {
1586 * Tests the method public Collator createCollator(Locale loc) using TestCreateCollator1 class
1592 errln("Collator.createCollator(Locale) was not suppose to " + "return an exception.");
1596 * Tests the method public Collator createCollator(ULocale loc) using TestCreateCollator1 class
1602 errln("Collator
1612 errln("Collator.getDisplayName(Locale,Locale) was not suppose to return an exception.");
1622 errln("Collator.getDisplayName(ULocale,ULocale) was not suppose to return an exception.");
1635 Collator c = Collator.getInstance();
1638 errln("Collator.getKeywordValues(String) is suppose to return " +
1653 Collator.getInstance(new ULocale(localeID));
1654 errln("Collator.getInstance(" + localeID + ") did not fail as expected");
1657 errln("Collator.getInstance(" + localeID + ") did not fail as expected - " + other);
1663 Collator.getInstance(new ULocale(localeID));
1664 errln("Collator.getInstance(" + localeID + ") did not fail as expected");
1667 errln("Collator.getInstance(" + localeID + ") did not fail as expected - " + other);
1672 Collator.getInstance(new ULocale(localeID));
1673 errln("Collator.getInstance(" + localeID + ") did not fail as expected");
1676 errln("Collator.getInstance(" + localeID + ") did not fail as expected - " + other);
1704 Collator coll = new RuleBasedCollator("&[before 1]\uFDD1?<*\u4E00-\u9FFF");