Interface OffsetAwareNormalizer
- All Superinterfaces:
CharSequenceNormalizer, Serializable
A
CharSequenceNormalizer that can additionally report the Alignment from its
normalized output back to the input, so a span found in the normalized text maps to the exact
character offsets of the original.
Length-changing folds move offsets: collapsing a run of whitespace, folding a supplementary
dash to one ASCII hyphen, or stripping invisible controls all shift every later character. A normalizer
that performs such a fold over the cursor-based CharClass engine can record those edits
and expose them through normalizeAligned(CharSequence). A normalizer that delegates to
Normalizer (NFC/NFKC) or to a stemmer cannot report its edits and does not
implement this interface.
Callers check for the capability with normalizer instanceof OffsetAwareNormalizer,
the same way OffsetMappingNameFinder is detected on a name finder.
- Since:
- 3.0.0
-
Method Summary
Modifier and TypeMethodDescriptionnormalizeAligned(CharSequence text) Normalizestextand returns the result together with theAlignmentback to the input.Methods inherited from interface CharSequenceNormalizer
normalize
-
Method Details
-
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().- Parameters:
text- TheCharSequenceto normalize.- Returns:
- The normalized text paired with its alignment to
text. - Throws:
IllegalArgumentException- Thrown iftextisnull.
-