Top Description Fields Constructors Methods
com.ibm.icu.text

public final Class CanonicalIterator

extends Object
Class Inheritance
Imports
java.util.ArrayList, .HashSet, .Iterator, .List, .Set, com.ibm.icu.impl.Norm2AllModes, .Normalizer2Impl, .Utility, com.ibm.icu.lang.UCharacter

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
ICU Status
Stable since ICU 2.4.

Field Summary

Modifier and TypeField and Description
private transient StringBuilder
private int[]
private boolean
private final Normalizer2Impl
private final Normalizer2
private String[][]
private static boolean
private static final Set<String>
private static boolean
private String

Constructor Summary

AccessConstructor and Description
public
CanonicalIterator(String
string to get results for
source
)

Construct a CanonicalIterator object

Method Summary

Modifier and TypeMethod and Description
private Set<String>
extract(int comp, String segment, int segmentPos, StringBuffer buf)

See if the decomposition of cp2 is at segment starting at segmentPos (with canonical rearrangment!) If so, take the remainder, and return the equivalents

private String[]
private Set<String>
public String

Returns:

gets the source: NOTE: it is the NFD form of the source originally passed in
getSource
()

Gets the NFD form of the current source we are iterating over.

public String

Returns:

the next string that is canonically equivalent. The value null is returned when the iteration is done.
next
()

Get the next canonically equivalent string.

public static void
permute(String
the string to find permutations for
source
,
boolean
set to true to skip characters with canonical combining class zero
skipZeros
,
Set<String>
the set to add the results to
output
)

Deprecated This API is ICU internal only.
Simple implementation of permutation.
public void
reset()

Resets the iterator so that one can start again from the beginning.

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

Set a new source for this iterator.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

bufferback to summary
private transient StringBuilder buffer
currentback to summary
private int[] current
doneback to summary
private boolean done
nfcImplback to summary
private final Normalizer2Impl nfcImpl
nfdback to summary
private final Normalizer2 nfd
piecesback to summary
private String[][] pieces
PROGRESSback to summary
private static boolean PROGRESS
SET_WITH_NULL_STRINGback to summary
private static final Set<String> SET_WITH_NULL_STRING
SKIP_ZEROSback to summary
private static boolean SKIP_ZEROS
sourceback to summary
private String source

Constructor Detail

CanonicalIteratorback to summary
public CanonicalIterator(String source)

Construct a CanonicalIterator object

Parameters
source:String

string to get results for

ICU Status
Stable since ICU 2.4.

Method Detail

extractback to summary
private Set<String> extract(int comp, String segment, int segmentPos, StringBuffer buf)

See if the decomposition of cp2 is at segment starting at segmentPos (with canonical rearrangment!) If so, take the remainder, and return the equivalents

getEquivalentsback to summary
private String[] getEquivalents(String segment)
getEquivalents2back to summary
private Set<String> getEquivalents2(String segment)
getSourceback to summary
public String getSource()

Gets the NFD form of the current source we are iterating over.

Returns:String

gets the source: NOTE: it is the NFD form of the source originally passed in

ICU Status
Stable since ICU 2.4.
nextback to summary
public String next()

Get the next canonically equivalent string.

Warning

The strings are not guaranteed to be in any particular order.

Returns:String

the next string that is canonically equivalent. The value null is returned when the iteration is done.

ICU Status
Stable since ICU 2.4.
permuteback to summary
public static void permute(String source, boolean skipZeros, Set<String> output)

Deprecated

This API is ICU internal only.

Simple implementation of permutation.

Warning

The strings are not guaranteed to be in any particular order.

Parameters
source:String

the string to find permutations for

skipZeros:boolean

set to true to skip characters with canonical combining class zero

output:Set<String>

the set to add the results to

Annotations
@Deprecated
ICU Status
Internal ICU component.
resetback to summary
public void reset()

Resets the iterator so that one can start again from the beginning.

ICU Status
Stable since ICU 2.4.
setSourceback to summary
public void setSource(String newSource)

Set a new source for this iterator. Allows object reuse.

Parameters
newSource:String

the source string to iterate against. This allows the same iterator to be used while changing the source string, saving object creation.

ICU Status
Stable since ICU 2.4.