Search in sources :

Example 1 with CollationElementIterator

use of java.text.CollationElementIterator in project robovm by robovm.

the class OldCollationElementIteratorTest method testPrevious.

public void testPrevious() {
    RuleBasedCollator coll = (RuleBasedCollator) Collator.getInstance(Locale.US);
    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());
}
Also used : RuleBasedCollator(java.text.RuleBasedCollator) CollationElementIterator(java.text.CollationElementIterator)

Aggregations

CollationElementIterator (java.text.CollationElementIterator)1 RuleBasedCollator (java.text.RuleBasedCollator)1