Package java.text

Examples of java.text.CollationElementIterator


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

    public String substringBefore(String s1, String s2) {
        CollationElementIterator iter1 = collator.getCollationElementIterator(s1);
        CollationElementIterator iter2 = collator.getCollationElementIterator(s2);
        int[] ib = new int[2];
        boolean bb = collationContains(iter1, iter2, ib, false);
        if (bb) {
            return s1.substring(0, ib[0]);
        } else {
View Full Code Here


        RuleBasedCollator collator = new RuleBasedCollator(rules);

        for (int i=0; i<args.length; i++) {
            System.err.println(args[i]);
            FastStringBuffer sb = new FastStringBuffer(FastStringBuffer.MEDIUM);
            CollationElementIterator iter = collator.getCollationElementIterator(args[i]);
            while (true) {
                int e = iter.next();
                if (e==-1) {
                    break;
                }
                sb.append(e+" ");
            }
View Full Code Here

                dynamicError("The collation for " + getDisplayName(context.getController().getNamePool()) +
                        " must be a RuleBaseCollator", context);
                return null;
            }
            RuleBasedCollator rbc = (RuleBasedCollator)collator;
            CollationElementIterator iter0 = rbc.getCollationElementIterator(s0);
            CollationElementIterator iter1 = rbc.getCollationElementIterator(s1);

            switch (operation) {
                case STARTSWITH:
                    return BooleanValue.get( collationStartsWith(iter0, iter1) );
                case CONTAINS:
View Full Code Here

    boolean hasSingleCollationElement() throws StandardException {
        if (stringData.isNull()) {
            return false;
        }

        CollationElementIterator cei =
            collatorForCharacterDatatypes.getCollationElementIterator(
                stringData.getString());

        // First call next() to see that there is at least one element, and
        // then call next() to see that there is no more than one element.
        return cei.next() != CollationElementIterator.NULLORDER &&
                cei.next() == CollationElementIterator.NULLORDER;
    }
View Full Code Here



  private final int[] getFirstCaseDiff(final String text, final String pattern, final Locale locale){

        final CollationElementIterator targIter = m_collator.getCollationElementIterator(text);
        final CollationElementIterator patIter = m_collator.getCollationElementIterator(pattern);
        int startTarg = -1;
        int endTarg = -1;
        int startPatt = -1;
        int endPatt = -1;
        final int done = getElement(CollationElementIterator.NULLORDER);
        int patternElement = 0, targetElement = 0;
        boolean getPattern = true, getTarget = true;

        while (true) {
            if (getPattern){
                 startPatt = patIter.getOffset();
                 patternElement = getElement(patIter.next());
                 endPatt = patIter.getOffset();
            }
            if ((getTarget)){
                 startTarg  = targIter.getOffset();
                 targetElement   = getElement(targIter.next());
                 endTarg  = targIter.getOffset();
View Full Code Here

    }
       

    collationElementsForString = new int[stringData.getLength()];

    CollationElementIterator cei =
            collatorForCharacterDatatypes.getCollationElementIterator(
                stringData.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 hasSingleCollationElement() throws StandardException {
        if (stringData.isNull()) {
            return false;
        }

        CollationElementIterator cei =
            collatorForCharacterDatatypes.getCollationElementIterator(
                stringData.getString());

        // First call next() to see that there is at least one element, and
        // then call next() to see that there is no more than one element.
        return cei.next() != CollationElementIterator.NULLORDER &&
                cei.next() == CollationElementIterator.NULLORDER;
    }
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

    coll = (RuleBasedCollator) Collator.getInstance(Locale.US);
  }

  public void testGetOffset() {
    String text = "abc";
    CollationElementIterator iterator = coll
        .getCollationElementIterator(text);
    int[] offsets = { 0, 1, 2, 3 };
    int offset = iterator.getOffset();
    int i = 0;
    assertEquals(offsets[i++], offset);
    while (offset != text.length()) {
      iterator.next();
      offset = iterator.getOffset();
      assertEquals(offsets[i++], offset);
    }
  }
View Full Code Here

    }
  }

  public void testNext() {
    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);
    order = iterator.previous();

    while (order != CollationElementIterator.NULLORDER) {
      assertEquals(orders[--i], order);
      order = iterator.previous();
    }

    assertEquals(0, iterator.getOffset());
  }
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.