Moyosoft Products | Services | Download | Contact us    
JavaDocPlus
Products  >  JavaDocPlus  >  Online demo    


Latest release




Get a FREE license !
(Special offer, time limited)

Review JavaDocPlus on your blog and we'll give you a free license.

Open source projects licenced under LGPL, EPL, ASL, BSD or MIT can also obtain a free license.

Contact us to check if your project/blog is eligible.

Online demo
JavaDocPlus Demo  |  Show in full page mode
   
Overview  |  
Classic JavaDoc

Class CollationElementIterator

java.lang.Objectjava.text.CollationElementIterator


public final class CollationElementIterator

The CollationElementIterator class is used as an iterator to walk through 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,


  String testString = "This is a test";
  RuleBasedCollator ruleBasedCollator = (RuleBasedCollator)Collator.getInstance();
  CollationElementIterator collationElementIterator = ruleBasedCollator.getCollationElementIterator(testString);
  int primaryOrder = CollationElementIterator.primaryOrder(collationElementIterator.next());
 

CollationElementIterator.next returns the collation order of the next character. A collation order consists of primary order, secondary order and tertiary order. The data type of the collation order is int. The first 16 bits of a collation order is its primary order; the next 8 bits is the secondary order and the last 8 bits is the tertiary order.

See Also:
Collator, RuleBasedCollator

Version:
1.24 07/27/98

Author:
Helena Shih, Laura Werner, Richard Gillam

Fields

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

Methods

int
getMaxExpansion (int order)
Return the maximum length of any expansion sequences that end with the specified comparison order.
int
getOffset ()
Returns the character offset in the original text corresponding to the next collation element. (That is, getOffset() returns the position in the text corresponding to the collation element that will be returned by the next call to next().) This value will always be the index of the FI ... more >
int
next ()
Get the next collation element in the string. This iterator iterates over a sequence of collation elements that were built from the string. Because there isn't necessarily a one-to-one mapping from characters to collation elements, this doesn't mean the same thing as "return the coll ... more >
int
previous ()
Get the previous collation element in the string. This iterator iterates over a sequence of collation elements that were built from the string. Because there isn't necessarily a one-to-one mapping from characters to collation elements, this doesn't mean the same thing as "return the ... more >
static int
primaryOrder (int order)
Return the primary component of a collation element.
void
reset ()
Resets the cursor to the beginning of the string. The next call to next() will return the first collation element in the string.
static short
secondaryOrder (int order)
Return the secondary component of a collation element.
void
setOffset (int newOffset)
Sets the iterator to point to the collation element corresponding to the specified character (the parameter is a CHARACTER offset in the original string, not an offset into its corresponding sequence of collation elements). The value returned by the next call to next() will be the col ... more >
void
setText (String source)
Set a new string over which to iterate.
void
setText (CharacterIterator source)
Set a new string over which to iterate.
static short
tertiaryOrder (int order)
Return the tertiary component of a collation element.

Inherited methods

Community comments



Powered by JavaDocPlus