FileDocCategorySizeDatePackage
CollationElementIterator.javaAPI DocAndroid 1.5 API6755Wed May 06 22:41:04 BST 2009com.ibm.icu4jni.text

CollationElementIterator

public final class CollationElementIterator extends Object
Collation element iterator JNI wrapper. Iterates over the collation elements of a data string. The iterator supports both forward and backwards full iteration, ie if backwards iteration is performed in the midst of a forward iteration, the result is undefined. To perform a backwards iteration in the midst of a forward iteration, reset() has to be called. This will shift the position to either the start or the last character in the data string depending on whether next() is called or previous().
RuleBasedCollator coll = Collator.getInstance();
CollationElementIterator iterator = coll.getCollationElementIterator("abc");
int ce = 0;
while (ce != CollationElementIterator.NULLORDER) {
ce = iterator.next();
}
iterator.reset();
while (ce != CollationElementIterator.NULLORDER) {
ce = iterator.previous();
}
author
syn wee quek
stable
ICU 2.4

Fields Summary
public static final int
NULLORDER
private int
m_collelemiterator_
C collator
private static final int
PRIMARY_ORDER_MASK_
ICU constant primary order mask for collation elements
private static final int
SECONDARY_ORDER_MASK_
ICU constant secondary order mask for collation elements
private static final int
TERTIARY_ORDER_MASK_
ICU constant tertiary order mask for collation elements
private static final int
PRIMARY_ORDER_SHIFT_
ICU constant primary order shift for collation elements
private static final int
SECONDARY_ORDER_SHIFT_
ICU constant secondary order shift for collation elements
private static final int
UNSIGNED_16_BIT_MASK_
Unsigned 16 bit mask
Constructors Summary
CollationElementIterator(int collelemiteratoraddress)
CollationElementIteratorJNI constructor. The only caller of this class should be RuleBasedCollator.getCollationElementIterator().

param
collelemiteratoraddress address of C collationelementiterator

    m_collelemiterator_ = collelemiteratoraddress;
  
Methods Summary
protected voidfinalize()
Garbage collection. Close C collator and reclaim memory.

stable
ICU 2.4

    NativeCollation.closeElements(m_collelemiterator_);
  
public intgetMaxExpansion(int order)
Get the maximum length of any expansion sequences that end with the specified comparison order.

param
order collation order returned by previous or next.
return
maximum size of the expansion sequences ending with the collation element or 1 if collation element does not occur at the end of any expansion sequence
stable
ICU 2.4

    return NativeCollation.getMaxExpansion(m_collelemiterator_, order);
  
public intgetOffset()
Get the offset of the current source character. This is an offset into the text of the character containing the current collation elements.

return
offset of the current source character.
stable
ICU 2.4

    return NativeCollation.getOffset(m_collelemiterator_);
  
public intnext()
Get the ordering priority of the next collation element in the text. A single character may contain more than one collation element.

return
next collation elements ordering, or NULLORDER if the end of the text is reached.
stable
ICU 2.4

    return NativeCollation.next(m_collelemiterator_);
  
public intprevious()
Get the ordering priority of the previous collation element in the text. A single character may contain more than one collation element.

return
previous collation element ordering, or NULLORDER if the end of the text is reached.
stable
ICU 2.4

    return NativeCollation.previous(m_collelemiterator_);
  
public static intprimaryOrder(int order)
Gets the primary order of a collation order.

param
order the collation order
return
the primary order of a collation order.
stable
ICU 2.4

    return ((order & PRIMARY_ORDER_MASK_) >> PRIMARY_ORDER_SHIFT_) &
                                                       UNSIGNED_16_BIT_MASK_;
  
public voidreset()
Reset the collation elements to their initial state. This will move the 'cursor' to the beginning of the text.

stable
ICU 2.4

  
  // public methods -----------------------------------------------
  
                          
    
  
    NativeCollation.reset(m_collelemiterator_);
  
public static intsecondaryOrder(int order)
Gets the secondary order of a collation order.

param
order the collation order
return
the secondary order of a collation order.
stable
ICU 2.4

    return (order & SECONDARY_ORDER_MASK_) >> SECONDARY_ORDER_SHIFT_;
  
public voidsetOffset(int offset)
Set the offset of the current source character. This is an offset into the text of the character to be processed.

param
offset The desired character offset.
stable
ICU 2.4

    NativeCollation.setOffset(m_collelemiterator_, offset);
  
public voidsetText(java.lang.String source)
Set the text containing the collation elements.

param
source text containing the collation elements.
stable
ICU 2.4

    NativeCollation.setText(m_collelemiterator_, source);
  
public voidsetText(java.text.CharacterIterator source)

    NativeCollation.setText(m_collelemiterator_, source.toString());
  
public static inttertiaryOrder(int order)
Gets the tertiary order of a collation order.

param
order the collation order
return
the tertiary order of a collation order.
stable
ICU 2.4

    return order & TERTIARY_ORDER_MASK_;