Class FullCaseFoldCharSequenceNormalizer
- All Implemented Interfaces:
Serializable,CharSequenceNormalizer,OffsetAwareNormalizer
CharSequenceNormalizer that applies Unicode full case folding for case-insensitive
matching, as defined by the Default Case Algorithms in
Section 3.13 of the
Unicode Standard, using the bundled CaseFolding.txt data of the Unicode Character
Database.
Unlike CaseFoldCharSequenceNormalizer, which lower cases with
Locale.ROOT, this applies the full case foldings (the C common and
F full status mappings), including the expanding folds that plain lower casing does not
perform: the sharp s (U+00DF) to ss, the Latin ligatures (for example U+FB00 to
ff), and the Greek and Armenian multi-character folds. It is therefore an expanding,
offset-changing transform, so it is offset-aware: normalizeAligned(CharSequence) reports
the Alignment from the folded text back to the input.
The S simple and T Turkic status mappings are excluded, so the Turkish and
Azerbaijani dotless-i rule is not applied here. Input is expected in NFC: the fold matches
precomposed code points, so decomposed sequences pass through unchanged.
The folding table is loaded on first use. If the bundled CaseFolding.txt is missing
or cannot be read, every normalize call throws IllegalStateException or
UncheckedIOException.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final charField separator inCaseFolding.txt(<code>; <status>; <mapping>;).private static final BundledUnicodeData.Lazy<Map<Integer, String>> Maps a source code point to its full case folding (one or more code points), for the C and F status rows ofCaseFolding.txt.private static final FullCaseFoldCharSequenceNormalizerprivate static final charSeparates hex code points inside a multi-character mapping field.private static final Stringprivate static final longprivate static final StringCaseFolding.txtstatusC: common mapping shared by simple and full folding.private static final StringCaseFolding.txtstatusF: full mapping that may expand string length.private static final StringCaseFolding.txtstatusS: simple mapping; skipped by this full fold.private static final StringCaseFolding.txtstatusT: Turkic mapping; skipped by this full fold. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the shared, stateless instance.Returns the folding table parsed from the bundledCaseFolding.txtresource.normalize(CharSequence text) Normalizes a sequence of characters.normalizeAligned(CharSequence text) Normalizestextand returns the result together with theAlignmentback to the input.parse(InputStream in) Parses the full-folding mappings, theC(common) andF(full) status rows ofCaseFolding.txt.private ObjectReturns the shared instance, so deserialization keeps the singleton.
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
RESOURCE
- See Also:
-
FIELD_SEPARATOR
private static final char FIELD_SEPARATORField separator inCaseFolding.txt(<code>; <status>; <mapping>;).- See Also:
-
MAPPING_CODE_POINT_SEPARATOR
private static final char MAPPING_CODE_POINT_SEPARATORSeparates hex code points inside a multi-character mapping field. The UnicodeCaseFolding.txtformat uses ASCII space (U+0020), not a general whitespace class.- See Also:
-
STATUS_COMMON
CaseFolding.txtstatusC: common mapping shared by simple and full folding.- See Also:
-
STATUS_FULL
CaseFolding.txtstatusF: full mapping that may expand string length.- See Also:
-
STATUS_SIMPLE
CaseFolding.txtstatusS: simple mapping; skipped by this full fold.- See Also:
-
STATUS_TURKIC
CaseFolding.txtstatusT: Turkic mapping; skipped by this full fold.- See Also:
-
FOLDINGS
Maps a source code point to its full case folding (one or more code points), for the C and F status rows ofCaseFolding.txt. Loaded on first use. -
INSTANCE
-
-
Constructor Details
-
FullCaseFoldCharSequenceNormalizer
private FullCaseFoldCharSequenceNormalizer()Creates the singleton; usegetInstance().
-
-
Method Details
-
getInstance
Returns the shared, stateless instance.- Returns:
- the shared, stateless instance
-
normalize
Normalizes a sequence of characters.- Specified by:
normalizein interfaceCharSequenceNormalizer- Parameters:
text- TheCharSequenceto normalize. Must not benull.- Returns:
- The normalized
CharSequence. - Throws:
IllegalArgumentException- Thrown iftextisnull.IllegalStateException- Thrown if the bundledCaseFolding.txtresource is missing.UncheckedIOException- Thrown if the bundledCaseFolding.txtresource cannot be read.
-
normalizeAligned
Normalizestextand returns the result together with theAlignmentback to the input. The normalized text is identical toCharSequenceNormalizer.normalize(CharSequence): that is,normalizeAligned(text).normalized()equalsnormalize(text).toString().- Specified by:
normalizeAlignedin interfaceOffsetAwareNormalizer- Parameters:
text- TheCharSequenceto normalize.- Returns:
- The normalized text paired with its alignment to
text. - Throws:
IllegalArgumentException- Thrown iftextisnull.IllegalStateException- Thrown if the bundledCaseFolding.txtresource is missing.UncheckedIOException- Thrown if the bundledCaseFolding.txtresource cannot be read.
-
initFoldings
Returns the folding table parsed from the bundledCaseFolding.txtresource.- Returns:
- the folding table parsed from the bundled
CaseFolding.txtresource - Throws:
IllegalStateException- Thrown if the resource is missing.UncheckedIOException- Thrown if the resource cannot be read.
-
parse
Parses the full-folding mappings, theC(common) andF(full) status rows ofCaseFolding.txt. TheS(simple) andT(Turkic) status rows are deliberately skipped so the fold stays language-neutral and full rather than simple. Package-private so the malformed-data handling can be exercised without the bundled resource.- Parameters:
in- the stream to parse, inCaseFolding.txtformat. Must not benull.- Returns:
- the mapping from source code point to its full case folding.
- Throws:
IOException- Thrown if the stream cannot be read.IllegalArgumentException- Thrown if the data is malformed.
-
readResolve
Returns the shared instance, so deserialization keeps the singleton.- Returns:
- the shared instance, so deserialization keeps the singleton
-