Class EscapeTransliterator
- All Implemented Interfaces:
StringTransform
,Transform<String,
String>
Some escape forms actually have two different patterns, one for BMP characters (0..FFFF) and one for supplements (>FFFF). To handle this, a second EscapeTransliterator may be defined that specifies the pattern to be produced for supplementals. An example of a form that requires this is the C form, which uses "\\uFFFF" for BMP characters and "\\U0010FFFF" for supplementals.
This class is package private. It registers several standard variants with the system which are then accessed via their IDs.
-
Nested Class Summary
Nested classes/interfaces inherited from class com.ibm.icu.text.Transliterator
Transliterator.Factory, Transliterator.Position
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate boolean
If true, supplementals are handled as 32-bit code points.private int
The minimum number of digits.private String
The prefix of the escape form; may be empty, but usually isn't.private int
The radix to display the number in.private String
The prefix of the escape form; often empty.private EscapeTransliterator
The form to be used for supplementals.Fields inherited from class com.ibm.icu.text.Transliterator
DEBUG, FORWARD, ID_DELIM, ID_SEP, REVERSE, VARIANT_SEP
-
Constructor Summary
ConstructorsConstructorDescriptionEscapeTransliterator
(String ID, String prefix, String suffix, int radix, int minDigits, boolean grokSupplementals, EscapeTransliterator supplementalHandler) Constructs an escape transliterator with the given ID and parameters. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addSourceTargetSet
(UnicodeSet inputFilter, UnicodeSet sourceSet, UnicodeSet targetSet) Returns the set of all characters that may be generated as replacement text by this transliterator, filtered by BOTH the input filter, and the current getFilter().protected void
handleTransliterate
(Replaceable text, Transliterator.Position pos, boolean incremental) (package private) static void
register()
Registers standard variants with the system.Methods inherited from class com.ibm.icu.text.Transliterator
baseToRules, createFromRules, filteredTransliterate, finishTransliteration, getAvailableIDs, getAvailableSources, getAvailableTargets, getAvailableVariants, getBasicInstance, getDisplayName, getDisplayName, getDisplayName, getElements, getFilter, getFilterAsUnicodeSet, getID, getInstance, getInstance, getInverse, getMaximumContextLength, getSourceSet, getTargetSet, handleGetSourceSet, registerAlias, registerAny, registerClass, registerFactory, registerInstance, registerInstance, registerSpecialInverse, setFilter, setID, setMaximumContextLength, toRules, transform, transliterate, transliterate, transliterate, transliterate, transliterate, transliterate, unregister
-
Field Details
-
prefix
The prefix of the escape form; may be empty, but usually isn't. May not be null. -
suffix
The prefix of the escape form; often empty. May not be null. -
radix
private int radixThe radix to display the number in. Typically 16 or 10. Must be in the range 2 to 36. -
minDigits
private int minDigitsThe minimum number of digits. Typically 1, 4, or 8. Values less than 1 are equivalent to 1. -
grokSupplementals
private boolean grokSupplementalsIf true, supplementals are handled as 32-bit code points. If false, they are handled as two 16-bit code units. -
supplementalHandler
The form to be used for supplementals. If this is null then the same form is used for BMP characters and supplementals. If this is not null and if grokSupplementals is true then the prefix, suffix, radix, and minDigits of this object are used for supplementals.
-
-
Constructor Details
-
EscapeTransliterator
EscapeTransliterator(String ID, String prefix, String suffix, int radix, int minDigits, boolean grokSupplementals, EscapeTransliterator supplementalHandler) Constructs an escape transliterator with the given ID and parameters. See the class member documentation for details.
-
-
Method Details
-
register
static void register()Registers standard variants with the system. Called by Transliterator during initialization. -
handleTransliterate
protected void handleTransliterate(Replaceable text, Transliterator.Position pos, boolean incremental) - Specified by:
handleTransliterate
in classTransliterator
- Parameters:
text
- the buffer holding transliterated and untransliterated textpos
- the indices indicating the start, limit, context start, and context limit of the text.incremental
- if true, assume more text may be inserted atpos.limit
and act accordingly. Otherwise, transliterate all text betweenpos.start
andpos.limit
and movepos.start
up topos.limit
.- See Also:
-
addSourceTargetSet
Description copied from class:Transliterator
Returns the set of all characters that may be generated as replacement text by this transliterator, filtered by BOTH the input filter, and the current getFilter().SHOULD BE OVERRIDDEN BY SUBCLASSES. It is probably an error for any transliterator to NOT override this, but we can't force them to for backwards compatibility.
Other methods vector through this.
When gathering the information on source and target, the compound transliterator makes things complicated. For example, suppose we have:
Global FILTER = [ax] a > b; :: NULL; b > c; x > d;
While the filter just allows a and x, b is an intermediate result, which could produce c. So the source and target sets cannot be gathered independently. What we have to do is filter the sources for the first transliterator according to the global filter, intersect that transliterator's filter. Based on that we get the target. The next transliterator gets as a global filter (global + last target). And so on.There is another complication:
Global FILTER = [ax] a >|b; b >c;
Even though b would be filtered from the input, whenever we have a backup, it could be part of the input. So ideally we will change the global filter as we go.- Overrides:
addSourceTargetSet
in classTransliterator
- Parameters:
targetSet
- TODO- See Also:
-