Package java.text

Examples of java.text.CollationElementIterator


    assertEquals(0, iterator.getOffset());
  }

  public void testReset() {
    String text = "abc";
    CollationElementIterator iterator = coll
        .getCollationElementIterator(text);
    int[] orders = new int[text.length()];
    int order = iterator.next();
    int i = 0;
    while (order != CollationElementIterator.NULLORDER) {
      orders[i++] = order;
      order = iterator.next();
    }

    int offset = iterator.getOffset();
    assertEquals(text.length(), offset);

    iterator.reset();
    assertEquals(0, iterator.getOffset());
  }
View Full Code Here


  public void testGetMaxExpansion() {
    String text = "cha";
    RuleBasedCollator rbColl = (RuleBasedCollator) Collator
        .getInstance(new Locale("es", "", "TRADITIONAL"));
    CollationElementIterator iterator = rbColl
        .getCollationElementIterator(text);
    int order = iterator.next();
    while (order != CollationElementIterator.NULLORDER) {
      assertEquals(1, iterator.getMaxExpansion(order));
      order = iterator.next();
    }

  }
View Full Code Here

  public void testPrimaryOrder() {
    RuleBasedCollator rbColl = (RuleBasedCollator) Collator
        .getInstance(new Locale("de", "DE"));
    String text = "\u00e6";
    CollationElementIterator iterator = rbColl
        .getCollationElementIterator(text);
    int order = iterator.next();
    int pOrder = CollationElementIterator.primaryOrder(order);
    CollationElementIterator iterator2 = rbColl
        .getCollationElementIterator("ae");
    int order2 = iterator2.next();
    int pOrder2 = CollationElementIterator.primaryOrder(order2);
    assertEquals(pOrder, pOrder2);
  }
View Full Code Here

  public void testSecondaryOrder() {
    RuleBasedCollator rbColl = (RuleBasedCollator) Collator
        .getInstance(new Locale("fr", "FR"));
    String text = "a\u00e0";
    CollationElementIterator iterator = rbColl
        .getCollationElementIterator(text);
    int order = iterator.next();
    int sOrder1 = CollationElementIterator.secondaryOrder(order);

    order = iterator.next();
    int sOrder2 = CollationElementIterator.secondaryOrder(order);

    assertEquals(sOrder1, sOrder2);
  }
View Full Code Here

  public void testTertiaryOrder() {
    RuleBasedCollator rbColl = (RuleBasedCollator) Collator
        .getInstance(new Locale("fr", "FR"));
    String text = "abAB";
    CollationElementIterator iterator = rbColl
        .getCollationElementIterator(text);
    int order = iterator.next();
    int tOrder1 = CollationElementIterator.tertiaryOrder(order);
    order = iterator.next();
    int tOrder2 = CollationElementIterator.tertiaryOrder(order);
    assertEquals(tOrder1, tOrder2);

    order = iterator.next();
    tOrder1 = CollationElementIterator.tertiaryOrder(order);
    order = iterator.next();
    tOrder2 = CollationElementIterator.tertiaryOrder(order);
    assertEquals(tOrder1, tOrder2);
  }
View Full Code Here

  public void testSetOffset() {
    RuleBasedCollator rbColl = (RuleBasedCollator) Collator
        .getInstance(new Locale("es", "", "TRADITIONAL"));
    String text = "cha";
    CollationElementIterator iterator = rbColl
        .getCollationElementIterator(text);
    iterator.setOffset(1);
    assertEquals(0, iterator.getOffset());
  }
View Full Code Here

   */
  public void testSetTextString() {
    RuleBasedCollator rbColl = (RuleBasedCollator) Collator
        .getInstance(new Locale("es", "", "TRADITIONAL"));
    String text = "caa";
    CollationElementIterator iterator = rbColl
        .getCollationElementIterator(text);
    iterator.setOffset(1);
    assertEquals(1, iterator.getOffset());
    iterator.setText("cha");
    iterator.setOffset(1);
    assertEquals(0, iterator.getOffset());
  }
View Full Code Here

   */
  public void testSetTextCharacterIterator() {
    RuleBasedCollator rbColl = (RuleBasedCollator) Collator
        .getInstance(new Locale("es", "", "TRADITIONAL"));
    String text = "caa";
    CollationElementIterator iterator = rbColl
        .getCollationElementIterator(text);
    iterator.setOffset(1);
    assertEquals(1, iterator.getOffset());
    iterator.setText(new StringCharacterIterator("cha"));
    iterator.setOffset(1);
    assertEquals(0, iterator.getOffset());
  }
View Full Code Here

        {
            Locale locale = new Locale("es", "", "TRADITIONAL");
            RuleBasedCollator coll = (RuleBasedCollator) Collator
                    .getInstance(locale);
            String source = "cha";
            CollationElementIterator iterator = coll
                    .getCollationElementIterator(source);
            int[] e_offset = { 0, 2, 3 };
            int offset = iterator.getOffset();
            int i = 0;
            assertEquals(e_offset[i++], offset);
            while (offset != source.length()) {
                iterator.next();
                offset = iterator.getOffset();
                assertEquals(e_offset[i++], offset);
            }
        }

        {
            Locale locale = new Locale("de", "DE");
            RuleBasedCollator coll = (RuleBasedCollator) Collator
                    .getInstance(locale);
            String source = "\u00E6b";
            CollationElementIterator iterator = coll
                    .getCollationElementIterator(source);
            int[] e_offset = { 0, 1, 1, 2 };
            int offset = iterator.getOffset();
            int i = 0;
            assertEquals(e_offset[i++], offset);
            while (offset != source.length()) {
                iterator.next();
                offset = iterator.getOffset();
                assertEquals(e_offset[i++], offset);
            }
        }
        //Regression for HARMONY-1352
        try {
View Full Code Here

            Locale locale = new Locale("es", "", "TRADITIONAL");
            RuleBasedCollator coll = (RuleBasedCollator) Collator
                    .getInstance(locale);
            String text = "cha";
            StringCharacterIterator source = new StringCharacterIterator(text);
            CollationElementIterator iterator = coll
                    .getCollationElementIterator(source);
            int[] e_offset = { 0, 2, 3 };
            int offset = iterator.getOffset();
            int i = 0;
            assertEquals(e_offset[i++], offset);
            while (offset != text.length()) {
                iterator.next();
                offset = iterator.getOffset();
                // System.out.println(offset);
                assertEquals(e_offset[i++], offset);
            }
        }

        {
            Locale locale = new Locale("de", "DE");
            RuleBasedCollator coll = (RuleBasedCollator) Collator
                    .getInstance(locale);
            String text = "\u00E6b";
            StringCharacterIterator source = new StringCharacterIterator(text);
            CollationElementIterator iterator = coll
                    .getCollationElementIterator(source);
            int[] e_offset = { 0, 1, 1, 2 };
            int offset = iterator.getOffset();
            int i = 0;
            assertEquals(e_offset[i++], offset);
            while (offset != text.length()) {
                iterator.next();
                offset = iterator.getOffset();
                assertEquals(e_offset[i++], offset);
            }
        }
        //Regression for HARMONY-1352
        try {
View Full Code Here

TOP

Related Classes of java.text.CollationElementIterator

Copyright © 2018 www.massapicom. 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.