Package java.text

Examples of java.text.CollationElementIterator


  }
 
  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},
       {6356992, 97, 0, 0},
       {6356992, 97, 0, 0}
      };
   
    int element;
    int i = 0;
    while ((element = iter.next()) != CollationElementIterator.NULLORDER)
      {
       
        int primary = CollationElementIterator.primaryOrder(element);
        int secondary = CollationElementIterator.secondaryOrder(element);
        int tertiary = CollationElementIterator.tertiaryOrder(element);
View Full Code Here


      // 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]);
View Full Code Here

  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();
  harness.check(iter.getOffset(), 2);
  iter.next();
  harness.check(iter.getOffset(), 3);
  iter.next();
  harness.check(iter.getOffset(), 4);
  iter.next();
  harness.check(iter.getOffset(), 7);
      }
    catch (ParseException e)
      {
  harness.fail("Unexpected parse error exception");
  harness.debug(e);
View Full Code Here

    }

    Boolean result;

    // get the collation integer representing "_"
    CollationElementIterator cei =
                  collator.getCollationElementIterator("_");
    anyCharInts[0] = cei.next();
    {
      int nextInt;

      // There may be multiple ints representing this character
      while ((nextInt = cei.next()) != CollationElementIterator.NULLORDER)
      {
        int[] temp = new int[anyCharInts.length + 1];
        for (int index = 0; index < anyCharInts.length; index++)
        {
          temp[index] = anyCharInts[index];
        }
        temp[anyCharInts.length] = nextInt;
        anyCharInts = temp;
      }
    }
    // get the collation integer representing "%"
    cei = collator.getCollationElementIterator("%");
    anyStringInts[0] = cei.next();
    {
      int nextInt;

      // There may be multiple ints representing this character
      while ((nextInt = cei.next()) != CollationElementIterator.NULLORDER)
      {
        int[] temp = new int[anyStringInts.length + 1];
        for (int index = 0; index < anyStringInts.length; index++)
        {
          temp[index] = anyStringInts[index];
View Full Code Here

    }

    intArray = new int[getLength()];

    RuleBasedCollator rbc = getLocaleFinder().getCollator();
    CollationElementIterator cei = rbc.getCollationElementIterator(getString());
    int nextInt;
    while ((nextInt = cei.next()) != CollationElementIterator.NULLORDER)
    {
      /* Believe it or not, a String might have more
       * collation elements than characters.
       * So, we handle that case by increasing the int array
       * by 5 and copying array elements.
View Full Code Here

    }

    Boolean result;

    // get the collation integer representing "_"
    CollationElementIterator cei =
                  collator.getCollationElementIterator("_");
    anyCharInts[0] = cei.next();
    {
      int nextInt;

      // There may be multiple ints representing this character
      while ((nextInt = cei.next()) != CollationElementIterator.NULLORDER)
      {
        int[] temp = new int[anyCharInts.length + 1];
        for (int index = 0; index < anyCharInts.length; index++)
        {
          temp[index] = anyCharInts[index];
        }
        temp[anyCharInts.length] = nextInt;
        anyCharInts = temp;
      }
    }
    // get the collation integer representing "%"
    cei = collator.getCollationElementIterator("%");
    anyStringInts[0] = cei.next();
    {
      int nextInt;

      // There may be multiple ints representing this character
      while ((nextInt = cei.next()) != CollationElementIterator.NULLORDER)
      {
        int[] temp = new int[anyStringInts.length + 1];
        for (int index = 0; index < anyStringInts.length; index++)
        {
          temp[index] = anyStringInts[index];
View Full Code Here

     * @param s2 the contained string
     * @return true iff s1 contains s2
     */

    public boolean contains(String s1, String s2) {
        CollationElementIterator iter1 = collator.getCollationElementIterator(s1);
        CollationElementIterator iter2 = collator.getCollationElementIterator(s2);
        return collationContains(iter1, iter2, null, false);
    }
View Full Code Here

     * @param s2 the contained string
     * @return true iff s1 ends with s2
     */

    public boolean endsWith(String s1, String s2) {
        CollationElementIterator iter1 = collator.getCollationElementIterator(s1);
        CollationElementIterator iter2 = collator.getCollationElementIterator(s2);
        return collationContains(iter1, iter2, null, true);
    }
View Full Code Here

     * @param s2 the contained string
     * @return true iff s1 starts with s2
     */

    public boolean startsWith(String s1, String s2) {
        CollationElementIterator iter1 = collator.getCollationElementIterator(s1);
        CollationElementIterator iter2 = collator.getCollationElementIterator(s2);
        return collationStartsWith(iter1, iter2);
    }
View Full Code Here

     * @param s2 the contained string
     * @return the part of s1 that follows the first occurrence of s2
     */

    public String substringAfter(String s1, String s2) {
        CollationElementIterator iter1 = collator.getCollationElementIterator(s1);
        CollationElementIterator iter2 = collator.getCollationElementIterator(s2);
        int[] ia = new int[2];
        boolean ba = collationContains(iter1, iter2, ia, false);
        if (ba) {
            return s1.substring(ia[1]);
        } else {
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.