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

pack-priv Class EscapeTransliterator

extends Transliterator
Class Inheritance
Imports
com.ibm.icu.impl.Utility

A transliterator that converts Unicode characters to an escape form. Examples of escape forms are "U+4E01" and "􏿿". Escape forms have a prefix and suffix, either of which may be empty, a radix, typically 16 or 10, a minimum digit count, typically 1, 4, or 8, and a boolean that specifies whether supplemental characters are handled as 32-bit code points or as two 16-bit code units. Most escape forms handle 32-bit code points, but some, such as the Java form, intentionally break them into two surrogate pairs, for backward compatibility.

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.

Author
Alan Liu

Field Summary

Modifier and TypeField and Description
private boolean
grokSupplementals

If true, supplementals are handled as 32-bit code points.

private int
minDigits

The minimum number of digits.

private String
prefix

The prefix of the escape form; may be empty, but usually isn't.

private int
radix

The radix to display the number in. Typically 16 or 10.

private String
suffix

The prefix of the escape form; often empty.

private EscapeTransliterator
supplementalHandler

The form to be used for supplementals.

Inherited from com.ibm.icu.text.Transliterator:
DEBUGFORWARDID_DELIMID_SEPREVERSEVARIANT_SEP

Constructor Summary

AccessConstructor and Description
pack-priv
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.

Method Summary

Modifier and TypeMethod and Description
public void
addSourceTargetSet(UnicodeSet inputFilter, UnicodeSet sourceSet, UnicodeSet
TODO
targetSet
)

Overrides com.ibm.icu.text.Transliterator.addSourceTargetSet.

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
the buffer holding transliterated and untransliterated text
text
,
Transliterator.Position
the indices indicating the start, limit, context start, and context limit of the text.
pos
,
boolean
if true, assume more text may be inserted at pos.limit and act accordingly. Otherwise, transliterate all text between pos.start and pos.limit and move pos.start up to pos.limit.
incremental
)

Implements abstract com.ibm.icu.text.Transliterator.handleTransliterate.

Implements Transliterator#handleTransliterate.
pack-priv static void
register()

Registers standard variants with the system.

Inherited from com.ibm.icu.text.Transliterator:
baseToRulescreateFromRulesfilteredTransliteratefinishTransliterationgetAvailableIDsgetAvailableSourcesgetAvailableTargetsgetAvailableVariantsgetBasicInstancegetDisplayNamegetDisplayNamegetDisplayNamegetElementsgetFiltergetFilterAsUnicodeSetgetIDgetInstancegetInstancegetInversegetMaximumContextLengthgetSourceSetgetTargetSethandleGetSourceSetregisterAliasregisterAnyregisterClassregisterFactoryregisterInstanceregisterInstanceregisterSpecialInversesetFiltersetIDsetMaximumContextLengthtoRulestransformtransliteratetransliteratetransliteratetransliteratetransliteratetransliterateunregister

Field Detail

grokSupplementalsback to summary
private boolean grokSupplementals

If true, supplementals are handled as 32-bit code points. If false, they are handled as two 16-bit code units.

minDigitsback to summary
private int minDigits

The minimum number of digits. Typically 1, 4, or 8. Values less than 1 are equivalent to 1.

prefixback to summary
private String prefix

The prefix of the escape form; may be empty, but usually isn't. May not be null.

radixback to summary
private int radix

The radix to display the number in. Typically 16 or 10. Must be in the range 2 to 36.

suffixback to summary
private String suffix

The prefix of the escape form; often empty. May not be null.

supplementalHandlerback to summary
private EscapeTransliterator 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 Detail

EscapeTransliteratorback to summary
pack-priv 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 Detail

addSourceTargetSetback to summary
public void addSourceTargetSet(UnicodeSet inputFilter, UnicodeSet sourceSet, UnicodeSet targetSet)

Overrides com.ibm.icu.text.Transliterator.addSourceTargetSet.

Doc from com.ibm.icu.text.Transliterator.addSourceTargetSet.

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.
Parameters
targetSet:UnicodeSet

TODO

Annotations
@Override
handleTransliterateback to summary
protected void handleTransliterate(Replaceable text, Transliterator.Position pos, boolean incremental)

Implements abstract com.ibm.icu.text.Transliterator.handleTransliterate.

Implements Transliterator#handleTransliterate.

Parameters
text:Replaceable

Doc from com.ibm.icu.text.Transliterator.handleTransliterate.

the buffer holding transliterated and untransliterated text

pos:Transliterator.Position

Doc from com.ibm.icu.text.Transliterator.handleTransliterate.

the indices indicating the start, limit, context start, and context limit of the text.

incremental:boolean

Doc from com.ibm.icu.text.Transliterator.handleTransliterate.

if true, assume more text may be inserted at pos.limit and act accordingly. Otherwise, transliterate all text between pos.start and pos.limit and move pos.start up to pos.limit.

Annotations
@Override
registerback to summary
pack-priv static void register()

Registers standard variants with the system. Called by Transliterator during initialization.