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

public Class FilteredNormalizer2

extends Normalizer2
Class Inheritance
Imports
java.io.IOException, com.ibm.icu.util.ICUUncheckedIOException

Normalization filtered by a UnicodeSet. Normalizes portions of the text contained in the filter set and leaves portions not contained in the filter set unchanged. Filtering is done via UnicodeSet.span(..., UnicodeSet.SpanCondition.SIMPLE). Not-in-the-filter text is treated as "is normalized" and "quick check yes". This class implements all of (and only) the Normalizer2 API. An instance of this class is unmodifiable/immutable.
Author
Markus W. Scherer
ICU Status
Stable since ICU 4.4.

Field Summary

Modifier and TypeField and Description
private Normalizer2
private UnicodeSet

Constructor Summary

AccessConstructor and Description
public
FilteredNormalizer2(Normalizer2
wrapped Normalizer2 instance
n2
,
UnicodeSet
UnicodeSet which determines the characters to be normalized
filterSet
)

Constructs a filtered normalizer wrapping any Normalizer2 instance and a filter set.

Method Summary

Modifier and TypeMethod and Description
public StringBuilder
append(StringBuilder
string, should be normalized
first
,
CharSequence
string, should be normalized
second
)

Implements abstract com.ibm.icu.text.Normalizer2.append.

Appends the second string to the first string (merging them at the boundary) and returns the first string.
public int
composePair(int
A (normalization starter) code point.
a
,
int
Another code point.
b
)

Overrides com.ibm.icu.text.Normalizer2.composePair.

Performs pairwise composition of a & b and returns the composite if there is one.
public int
getCombiningClass(int
code point
c
)

Overrides com.ibm.icu.text.Normalizer2.getCombiningClass.

Gets the combining class of c.
public String
getDecomposition(int
code point
c
)

Implements abstract com.ibm.icu.text.Normalizer2.getDecomposition.

Gets the decomposition mapping of c.
public String
getRawDecomposition(int
code point
c
)

Overrides com.ibm.icu.text.Normalizer2.getRawDecomposition.

Gets the raw decomposition mapping of c.
public boolean
hasBoundaryAfter(int
character to test
c
)

Implements abstract com.ibm.icu.text.Normalizer2.hasBoundaryAfter.

Tests if the character always has a normalization boundary after it, regardless of context.
public boolean
hasBoundaryBefore(int
character to test
c
)

Implements abstract com.ibm.icu.text.Normalizer2.hasBoundaryBefore.

Tests if the character always has a normalization boundary before it, regardless of context.
public boolean
isInert(int
character to test
c
)

Implements abstract com.ibm.icu.text.Normalizer2.isInert.

Tests if the character is normalization-inert.
public boolean
isNormalized(CharSequence
input string
s
)

Implements abstract com.ibm.icu.text.Normalizer2.isNormalized.

Tests if the string is normalized.
public StringBuilder
normalize(CharSequence
source string
src
,
StringBuilder
destination string; its contents is replaced with normalized src
dest
)

Implements abstract com.ibm.icu.text.Normalizer2.normalize.

Writes the normalized form of the source string to the destination string (replacing its contents) and returns the destination string.
public Appendable
normalize(CharSequence
source string
src
,
Appendable
destination Appendable; gets normalized src appended
dest
)

Implements abstract com.ibm.icu.text.Normalizer2.normalize.

Writes the normalized form of the source string to the destination Appendable and returns the destination Appendable.
private Appendable
public StringBuilder
normalizeSecondAndAppend(StringBuilder
string, should be normalized
first
,
CharSequence
string, will be normalized
second
)

Implements abstract com.ibm.icu.text.Normalizer2.normalizeSecondAndAppend.

Appends the normalized form of the second string to the first string (merging them at the boundary) and returns the first string.
private StringBuilder
normalizeSecondAndAppend(StringBuilder first, CharSequence second, boolean doNormalize)

public Normalizer.QuickCheckResult
quickCheck(CharSequence
input string
s
)

Implements abstract com.ibm.icu.text.Normalizer2.quickCheck.

Tests if the string is normalized.
public int
spanQuickCheckYes(CharSequence
input string
s
)

Implements abstract com.ibm.icu.text.Normalizer2.spanQuickCheckYes.

Returns the end of the normalized substring of the input string.
Inherited from com.ibm.icu.text.Normalizer2:
getInstancegetNFCInstancegetNFDInstancegetNFKCCasefoldInstancegetNFKCInstancegetNFKCSimpleCasefoldInstancegetNFKDInstancenormalize

Field Detail

norm2back to summary
private Normalizer2 norm2
setback to summary
private UnicodeSet set

Constructor Detail

FilteredNormalizer2back to summary
public FilteredNormalizer2(Normalizer2 n2, UnicodeSet filterSet)

Constructs a filtered normalizer wrapping any Normalizer2 instance and a filter set. Both are aliased and must not be modified or deleted while this object is used. The filter set should be frozen; otherwise the performance will suffer greatly.

Parameters
n2:Normalizer2

wrapped Normalizer2 instance

filterSet:UnicodeSet

UnicodeSet which determines the characters to be normalized

ICU Status
Stable since ICU 4.4.

Method Detail

appendback to summary
public StringBuilder append(StringBuilder first, CharSequence second)

Implements abstract com.ibm.icu.text.Normalizer2.append.

Doc from com.ibm.icu.text.Normalizer2.append.

Appends the second string to the first string (merging them at the boundary) and returns the first string. The result is normalized if both the strings were normalized. The first and second strings must be different objects.

Parameters
first:StringBuilder

string, should be normalized

second:CharSequence

string, should be normalized

Returns:StringBuilder

first

Annotations
@Override
ICU Status
Stable since ICU 4.4.
composePairback to summary
public int composePair(int a, int b)

Overrides com.ibm.icu.text.Normalizer2.composePair.

Doc from com.ibm.icu.text.Normalizer2.composePair.

Performs pairwise composition of a & b and returns the composite if there is one.

Returns a composite code point c only if c has a two-way mapping to a+b. In standard Unicode normalization, this means that c has a canonical decomposition to a+b and c does not have the Full_Composition_Exclusion property.

This function is independent of the mode of the Normalizer2. The default implementation returns a negative value.

Parameters
a:int

A (normalization starter) code point.

b:int

Another code point.

Returns:int

The non-negative composite code point if there is one; otherwise a negative value.

Annotations
@Override
ICU Status
Stable since ICU 49.
getCombiningClassback to summary
public int getCombiningClass(int c)

Overrides com.ibm.icu.text.Normalizer2.getCombiningClass.

Doc from com.ibm.icu.text.Normalizer2.getCombiningClass.

Gets the combining class of c. The default implementation returns 0 but all standard implementations return the Unicode Canonical_Combining_Class value.

Parameters
c:int

code point

Returns:int

c's combining class

Annotations
@Override
ICU Status
Stable since ICU 49.
getDecompositionback to summary
public String getDecomposition(int c)

Implements abstract com.ibm.icu.text.Normalizer2.getDecomposition.

Doc from com.ibm.icu.text.Normalizer2.getDecomposition.

Gets the decomposition mapping of c. Roughly equivalent to normalizing the String form of c on a DECOMPOSE Normalizer2 instance, but much faster, and except that this function returns null if c does not have a decomposition mapping in this instance's data. This function is independent of the mode of the Normalizer2.

Parameters
c:int

code point

Returns:String

c's decomposition mapping, if any; otherwise null

Annotations
@Override
ICU Status
Stable since ICU 4.6.
getRawDecompositionback to summary
public String getRawDecomposition(int c)

Overrides com.ibm.icu.text.Normalizer2.getRawDecomposition.

Doc from com.ibm.icu.text.Normalizer2.getRawDecomposition.

Gets the raw decomposition mapping of c.

This is similar to the getDecomposition() method but returns the raw decomposition mapping as specified in UnicodeData.txt or (for custom data) in the mapping files processed by the gennorm2 tool. By contrast, getDecomposition() returns the processed, recursively-decomposed version of this mapping.

When used on a standard NFKC Normalizer2 instance, getRawDecomposition() returns the Unicode Decomposition_Mapping (dm) property.

When used on a standard NFC Normalizer2 instance, it returns the Decomposition_Mapping only if the Decomposition_Type (dt) is Canonical (Can); in this case, the result contains either one or two code points (=1..4 Java chars).

This function is independent of the mode of the Normalizer2. The default implementation returns null.

Parameters
c:int

code point

Returns:String

c's raw decomposition mapping, if any; otherwise null

Annotations
@Override
ICU Status
Stable since ICU 49.
hasBoundaryAfterback to summary
public boolean hasBoundaryAfter(int c)

Implements abstract com.ibm.icu.text.Normalizer2.hasBoundaryAfter.

Doc from com.ibm.icu.text.Normalizer2.hasBoundaryAfter.

Tests if the character always has a normalization boundary after it, regardless of context. If true, then the character does not normalization-interact with following characters. In other words, a string containing this character can be normalized by processing portions up to this character and after this character independently. This is used for iterative normalization. See the class documentation for details.

Note that this operation may be significantly slower than hasBoundaryBefore().

Parameters
c:int

character to test

Returns:boolean

true if c has a normalization boundary after it

Annotations
@Override
ICU Status
Stable since ICU 4.4.
hasBoundaryBeforeback to summary
public boolean hasBoundaryBefore(int c)

Implements abstract com.ibm.icu.text.Normalizer2.hasBoundaryBefore.

Doc from com.ibm.icu.text.Normalizer2.hasBoundaryBefore.

Tests if the character always has a normalization boundary before it, regardless of context. If true, then the character does not normalization-interact with preceding characters. In other words, a string containing this character can be normalized by processing portions before this character and starting from this character independently. This is used for iterative normalization. See the class documentation for details.

Parameters
c:int

character to test

Returns:boolean

true if c has a normalization boundary before it

Annotations
@Override
ICU Status
Stable since ICU 4.4.
isInertback to summary
public boolean isInert(int c)

Implements abstract com.ibm.icu.text.Normalizer2.isInert.

Doc from com.ibm.icu.text.Normalizer2.isInert.

Tests if the character is normalization-inert. If true, then the character does not change, nor normalization-interact with preceding or following characters. In other words, a string containing this character can be normalized by processing portions before this character and after this character independently. This is used for iterative normalization. See the class documentation for details.

Note that this operation may be significantly slower than hasBoundaryBefore().

Parameters
c:int

character to test

Returns:boolean

true if c is normalization-inert

Annotations
@Override
ICU Status
Stable since ICU 4.4.
isNormalizedback to summary
public boolean isNormalized(CharSequence s)

Implements abstract com.ibm.icu.text.Normalizer2.isNormalized.

Doc from com.ibm.icu.text.Normalizer2.isNormalized.

Tests if the string is normalized. Internally, in cases where the quickCheck() method would return "maybe" (which is only possible for the two COMPOSE modes) this method resolves to "yes" or "no" to provide a definitive result, at the cost of doing more work in those cases.

Parameters
s:CharSequence

input string

Returns:boolean

true if s is normalized

Annotations
@Override
ICU Status
Stable since ICU 4.4.
normalizeback to summary
public StringBuilder normalize(CharSequence src, StringBuilder dest)

Implements abstract com.ibm.icu.text.Normalizer2.normalize.

Doc from com.ibm.icu.text.Normalizer2.normalize.

Writes the normalized form of the source string to the destination string (replacing its contents) and returns the destination string. The source and destination strings must be different objects.

Parameters
src:CharSequence

source string

dest:StringBuilder

destination string; its contents is replaced with normalized src

Returns:StringBuilder

dest

Annotations
@Override
ICU Status
Stable since ICU 4.4.
normalizeback to summary
public Appendable normalize(CharSequence src, Appendable dest)

Implements abstract com.ibm.icu.text.Normalizer2.normalize.

Doc from com.ibm.icu.text.Normalizer2.normalize.

Writes the normalized form of the source string to the destination Appendable and returns the destination Appendable. The source and destination strings must be different objects.

Any java.io.IOException is wrapped into a com.ibm.icu.util.ICUUncheckedIOException.

Parameters
src:CharSequence

source string

dest:Appendable

destination Appendable; gets normalized src appended

Returns:Appendable

dest

Annotations
@Override
ICU Status
Stable since ICU 4.6.
normalizeback to summary
private Appendable normalize(CharSequence src, Appendable dest, UnicodeSet.SpanCondition spanCondition)
normalizeSecondAndAppendback to summary
public StringBuilder normalizeSecondAndAppend(StringBuilder first, CharSequence second)

Implements abstract com.ibm.icu.text.Normalizer2.normalizeSecondAndAppend.

Doc from com.ibm.icu.text.Normalizer2.normalizeSecondAndAppend.

Appends the normalized form of the second string to the first string (merging them at the boundary) and returns the first string. The result is normalized if the first string was normalized. The first and second strings must be different objects.

Parameters
first:StringBuilder

string, should be normalized

second:CharSequence

string, will be normalized

Returns:StringBuilder

first

Annotations
@Override
ICU Status
Stable since ICU 4.4.
normalizeSecondAndAppendback to summary
private StringBuilder normalizeSecondAndAppend(StringBuilder first, CharSequence second, boolean doNormalize)
quickCheckback to summary
public Normalizer.QuickCheckResult quickCheck(CharSequence s)

Implements abstract com.ibm.icu.text.Normalizer2.quickCheck.

Doc from com.ibm.icu.text.Normalizer2.quickCheck.

Tests if the string is normalized. For the two COMPOSE modes, the result could be "maybe" in cases that would take a little more work to resolve definitively. Use spanQuickCheckYes() and normalizeSecondAndAppend() for a faster combination of quick check + normalization, to avoid re-checking the "yes" prefix.

Parameters
s:CharSequence

input string

Returns:Normalizer.QuickCheckResult

the quick check result

Annotations
@Override
ICU Status
Stable since ICU 4.4.
spanQuickCheckYesback to summary
public int spanQuickCheckYes(CharSequence s)

Implements abstract com.ibm.icu.text.Normalizer2.spanQuickCheckYes.

Doc from com.ibm.icu.text.Normalizer2.spanQuickCheckYes.

Returns the end of the normalized substring of the input string. In other words, with end=spanQuickCheckYes(s); the substring s.subSequence(0, end) will pass the quick check with a "yes" result.

The returned end index is usually one or more characters before the "no" or "maybe" character: The end index is at a normalization boundary. (See the class documentation for more about normalization boundaries.)

When the goal is a normalized string and most input strings are expected to be normalized already, then call this method, and if it returns a prefix shorter than the input string, copy that prefix and use normalizeSecondAndAppend() for the remainder.

Parameters
s:CharSequence

input string

Returns:int

"yes" span end index

Annotations
@Override
ICU Status
Stable since ICU 4.4.