Examples of RuleBasedCollator


Examples of java.text.RuleBasedCollator

  {"pqr", "xyz", "<"},
      },
    };

    try {
      RuleBasedCollator r = new RuleBasedCollator(TEST_RULES);
      for (int i = 0; i < TESTS.length; i++) {
  r.setStrength(i);
  doComparisons(r, TESTS[i]);
      }
    }
    catch (ParseException ex) {
      harness.debug(ex);
View Full Code Here

Examples of java.text.RuleBasedCollator

  {"chat", "dog", "<"},
      },
    };
   
    try {
      RuleBasedCollator r = new RuleBasedCollator(OLD_SPANISH_RULES);
      for (int i = 0; i < TESTS.length; i++) {
  r.setStrength(i);
  doComparisons(r, TESTS[i]);
      }
    }
    catch (ParseException ex) {
      harness.debug(ex);
View Full Code Here

Examples of java.text.RuleBasedCollator

  {"C\u00c6T", "CAB", ">"},
      },
    };
   
    try {
      RuleBasedCollator r = new RuleBasedCollator(OLD_ENGLISH_RULES);
      for (int i = 0; i < TESTS.length; i++) {
  r.setStrength(i);
  doComparisons(r, TESTS[i]);
      }
    }
    catch (ParseException ex) {
      harness.debug(ex);
View Full Code Here

Examples of java.text.RuleBasedCollator

    String SimpleRule = "< a< b< c< d";
   
    boolean pass = false;
    try
      {
        RuleBasedCollator simpleRuleCollator =
          new RuleBasedCollator(SimpleRule);
       
        pass = (simpleRuleCollator.compare("abc", "ABC") < 0);
      }
    catch (ParseException e)
      {
        pass = false;
      }
View Full Code Here

Examples of java.text.RuleBasedCollator

    this.harness.check(pass, "simple rule test");
  }
 
  private void orderComparision()
  {
    RuleBasedCollator c = (RuleBasedCollator)Collator.getInstance(Locale.US);
    CollationElementIterator iter = c.getCollationElementIterator("Foo");

    // given by the 1.5.0 jdk
    int [][] results =
      {
       {5767169, 88, 0, 1},
View Full Code Here

Examples of java.text.RuleBasedCollator

      // Used to get the collator as above, but this assumes that the
      // en_US locale's collation rules are reasonably complete.
      // Since the point of this class is test the iterator, it is
      // better to use a collator with hard-wired collation rules of
      // known quality.
      RuleBasedCollator en_USCollator =
        new RuleBasedCollator(JDK_1_4_EN_US_RULES);

      CollationElementIterator iterator =
        en_USCollator.getCollationElementIterator("abcdefg");

      // -------- methods --------
      checkOrder(iterator, 7, PRIMARY, "initial test");

      // reset()
      harness.checkPoint("reset()");
      iterator.reset();
      checkOrder(iterator, 7, PRIMARY, "initial test after reset()");

      // ------- check empty string --------
      iterator = en_USCollator.getCollationElementIterator("");
      harness.check (iterator.next(), CollationElementIterator.NULLORDER,
         "next()");

      // ------- detailed checks of collation orders -------
      for (int i = 0; i < TEST_STRINGS.length; i++) {
  iterator = en_USCollator.getCollationElementIterator(TEST_STRINGS[i]);
  checkOrder(iterator, TEST_STRINGS[i].length(), TEST_ORDERS[i],
       "test string #" + i);
      }

      // ------- detailed checks of collation equivalences -------
View Full Code Here

Examples of java.text.RuleBasedCollator

{
  public void test(TestHarness harness)
  {
    try
      {
  RuleBasedCollator collator = new RuleBasedCollator("<a,A<AB,ab<ABC,abc");
  CollationElementIterator iter;
 
  iter = collator.getCollationElementIterator("abaaABC");
  iter.setOffset(1);
  harness.check(iter.getOffset(), 0);

  iter.setOffset(0);
  iter.next();
View Full Code Here

Examples of java.text.RuleBasedCollator

   *
   * The default is DIN 5007-1, this shows how to tailor a collator to get DIN 5007-2 behavior.
   *  http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4423383
   */
  public void testCustomRules() throws Exception {
    RuleBasedCollator baseCollator = (RuleBasedCollator) Collator.getInstance(new Locale("de", "DE"));

    String DIN5007_2_tailorings =
      "& ae , a\u0308 & AE , A\u0308"+
      "& oe , o\u0308 & OE , O\u0308"+
      "& ue , u\u0308 & UE , u\u0308";

    RuleBasedCollator tailoredCollator = new RuleBasedCollator(baseCollator.getRules() + DIN5007_2_tailorings);
    String tailoredRules = tailoredCollator.getRules();
    //
    // at this point, you would save these tailoredRules to a file,
    // and use the custom parameter.
    //
    String germanUmlaut = "Töne";
View Full Code Here

Examples of java.text.RuleBasedCollator

            // StringDataValue returned for (V AS CLOB) should consider the
            // passed collation type in determining whether we should
            // generate SQLChar vs CollatorSQLChar for instance. Keep in mind
            // that collation applies only to character string types.
            try {
                RuleBasedCollator rbs = ConnectionUtil.getCurrentLCC().getDataValueFactory().
                getCharacterCollator(targetCollationType);
                result = ((StringDataValue)result).getValue(rbs);
            }
            catch( java.sql.SQLException sqle)
            {
View Full Code Here

Examples of java.text.RuleBasedCollator

    }


    @Test
    public void testRuleComparator() {
        RuleBasedCollator comp = (RuleBasedCollator)RuleBasedCollator.getInstance();
        doTest(comp);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.