Class CollectionElementIterator in Java

digitization, transformation, binary

Class CollectionElementIterator in Java

A RuleBasedCollator object creates an instance of the CollationElementIterator class to iterate through the characters of a string and determine their relative collation sequence.

A CollationElementIterator object performs callbacks to the RuleBasedCollator that created it to get the information it needs to recognize groups of characters that are treated as single
collation characters. For example, a RuleBasedCollator for a Spanish language locale would be set up to treat ‘ch’ as a single letter.

Ads code goes here

A CollationElementIterator object also gets information from its RuleBasedCollator that is used to determine the collation ordering priority for characters.

A collation-ordering priority of a character is a composite integer value that determines how the character is collated. This priority is comprised of:

  • A primary order that distinguishes between different letters. Characters that are considered to be different letters, such as ‘e’ and `f’, have different primary orders. Different forms of the same letter, such as ‘e’ and ‘E’, or an accented form of ‘e’, have the same primary order. Primary orders are short values.
  • A secondary order that distinguishes between accented forms of the same letter. An unaccented ‘e’ has a different secondary order than forms of ‘e’ that have different accents. ‘E’ and ‘e’ have the same secondary order, as do upper- and lowercase forms of ‘e’ that have the same accent. Secondary orders are byte values.
  • A tertiary order that distinguishes between case differences. ‘E’ and ‘e’ have different tertiary orders. Tertiary orders are byte values.
READ  Operators in Java

The next() method returns the collation-ordering priority of the next logical character. Primary, secondary, and tertiary orders are extracted from an ordering priority with the primaryOrder(), secondaryOrder(), and tertiaryOrder() methods.

The structure of the class CollectionElementIterator is given by

public final class java.text.CollationElementIterator extends java.lang.Object {
// Constants
public static final int NULLORDER;
// Class Methods
public static final int primaryOrder(int order);
public static final short secondaryOrder(int order);
public static final short tertiaryOrder(int order);
// Instance Methods
public int next();
public void reset();
}

The details of the class structure are given as follows:

public static final int NULLORDER;

public static final int NULLORDER represents a constant that is returned by next() if the end of the string has been reached.

public static final int primaryOrder(int order);

public static final int primaryOrder(int order) method extracts the primary order value from the given order key.

This method returns the primary order component of the given order key.

Parameter
order – the order in int

public static final short secondaryOrder(int order);

public static final short secondaryOrder(int order) method extracts the secondary order value from the given order key.

This method returns the secondary order component of the given order key.

Parameter
order – the order in int

public static final short tertiaryOrder(int order);

public static final short tertiaryOrder(int order) method extracts the tertiary order value from the given order key.

This method returns the tertiary order component of the given order key.

Parameter
order – the order in int

public int next();

public int next() method returns the order key for the next character in the string. The returned value can be
broken apart using the primaryOrder(), secondaryOrder(), and tertiaryOrder() methods.

READ  Learn Constructor in Java in an Easy and Fast Manner

This method returns the order value of the next character in the string.

public void reset();

public void reset() method resets the position of this CollationElementIterator to the beginning of the
string.

Apart from these CollectionElementIterator class also has inherited methods from class- Object. They are as follows:

  • clone()
  • finalize()
  • hashCode()
  • notifyAll()
  • wait()
  • wait(long, int)
  • equals(Object)
  • getClass()
  • notify()
  • toString()
  • wait(long)

Share and Enjoy !

Leave a Comment

Your email address will not be published. Required fields are marked *