All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class java.text.CollationElementIterator

java.lang.Object
   |
   +----java.text.CollationElementIterator

public final class CollationElementIterator
extends Object
The CollationElementIterator class is used as an iterator to walk thru each character of an international string. Use the iterator to return the ordering priority of the positioned character. The ordering priority of a character, which we refer to as a key, defines how a character is collated in the given collation object. For example, consider the following in Spanish:
     "ca" -> the first key is key('c') and second key is key('a').
     "cha" -> the first key is key('ch') and second key is key('a').
 
And in German,
     "äb"-> the first key is key('a'), the second key is key('e'), and
     the third key is key('b').
 
The key of a character, is an integer composed of primary order(short), secondary order(byte), and tertiary order(byte). Java strictly defines the size and signedness of its primitive data types. Therefore, the static functions primaryOrder(), secondaryOrder(), and tertiaryOrder() return int, short, and short respectively to ensure the correctness of the key value.

Example of the iterator usage,

 // get the first key of the string
 CollationElementIterator c =
     new CollationElementIterator("This is a test",
                                  Collation.getDefault())
 int primaryOrder = CollationElementIterator.primaryOrder(c->next());
 

See Also:
Collation, TableCollation

Variable Index

 o NULLORDER
Null order which indicates the end of string is reached by the cursor.

Method Index

 o next()
Get the ordering priority of the next character in the string.
 o primaryOrder(int)
Get the primary order of a collation ordering.
 o reset()
Resets the cursor to the beginning of the string.
 o secondaryOrder(int)
Get the secondary order of a collation ordering.
 o tertiaryOrder(int)
Get the tertiary order of a collation ordering.

Variables

 o NULLORDER
  public final static int NULLORDER
Null order which indicates the end of string is reached by the cursor.

Methods

 o reset
  public void reset()
Resets the cursor to the beginning of the string.

 o next
  public int next()
Get the ordering priority of the next character in the string.

Returns:
the next character's ordering. Returns NULLORDER if the end of string is reached.
 o primaryOrder
  public final static int primaryOrder(int order)
Get the primary order of a collation ordering.

Returns:
the primary order of a collation ordering.
 o secondaryOrder
  public final static short secondaryOrder(int order)
Get the secondary order of a collation ordering.

Returns:
the secondary order of a collation ordering.
 o tertiaryOrder
  public final static short tertiaryOrder(int order)
Get the tertiary order of a collation ordering.

Returns:
the tertiary order of a collation ordering.

All Packages  Class Hierarchy  This Package  Previous  Next  Index