com.ibm.icu.text
Class CanonicalIterator

java.lang.Object
  |
  +--com.ibm.icu.text.CanonicalIterator

public class CanonicalIterator
extends java.lang.Object

This class allows one to iterate through all the strings that are canonically equivalent to a given string. For example, here are some sample results: Results for: {A WITH RING ABOVE}{d}{DOT ABOVE}{CEDILLA}

1: {A}{RING ABOVE}{d}{DOT ABOVE}{CEDILLA}
2: {A}{RING ABOVE}{d}{CEDILLA}{DOT ABOVE}
3: {A}{RING ABOVE}{d WITH DOT ABOVE}{CEDILLA}
4: {A}{RING ABOVE}{d WITH CEDILLA}{DOT ABOVE}
5: {A WITH RING ABOVE}{d}{DOT ABOVE}{CEDILLA}
6: {A WITH RING ABOVE}{d}{CEDILLA}{DOT ABOVE}
7: {A WITH RING ABOVE}{d WITH DOT ABOVE}{CEDILLA}
8: {A WITH RING ABOVE}{d WITH CEDILLA}{DOT ABOVE}
9: {ANGSTROM SIGN}{d}{DOT ABOVE}{CEDILLA}
10: {ANGSTROM SIGN}{d}{CEDILLA}{DOT ABOVE}
11: {ANGSTROM SIGN}{d WITH DOT ABOVE}{CEDILLA}
12: {ANGSTROM SIGN}{d WITH CEDILLA}{DOT ABOVE}

Note: the code is intended for use with small strings, and is not suitable for larger ones, since it has not been optimized for that situation.

Author:
M. Davis

Constructor Summary
CanonicalIterator(java.lang.String source)
           
 
Method Summary
static UnicodeSet getSafeStart()
           
 java.lang.String getSource()
           
static UnicodeSet getStarts(int cp)
           
 java.lang.String next()
           
static void permute(java.lang.String source, boolean skipZeros, java.util.Set output)
          Simple implementation of permutation.
 void reset()
          Resets the iterator so that one can start again from the beginning.
 void setSource(java.lang.String newSource)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CanonicalIterator

public CanonicalIterator(java.lang.String source)
Parameters:
source - string to get results for
Method Detail

getSource

public java.lang.String getSource()
Returns:
gets the source: NOTE: it is the NFD form of the source originally passed in

reset

public void reset()
Resets the iterator so that one can start again from the beginning.

next

public java.lang.String next()
Returns:
the next string that is canonically equivalent. The value null is returned when the iteration is done.
Warning: The strings are not guaranteed to be in any particular order.

setSource

public void setSource(java.lang.String newSource)
Parameters:
set - the source string to iterate against. This allows the same iterator to be used while changing the source string, saving object creation.

permute

public static void permute(java.lang.String source,
                           boolean skipZeros,
                           java.util.Set output)
Simple implementation of permutation.
Warning: The strings are not guaranteed to be in any particular order.
Parameters:
source - the string to find permutations for
the - set to add the results to

getSafeStart

public static UnicodeSet getSafeStart()
Returns:
the set of "safe starts", characters that are class zero AND are never non-initial in a decomposition.

getStarts

public static UnicodeSet getStarts(int cp)
Returns:
the set of characters whose decompositions start with the given character


Copyright (c) 2001 IBM Corporation and others.