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

pack-priv Class CompoundTransliterator

extends Transliterator
Class Inheritance
Imports
java.util.List, com.ibm.icu.impl.Utility, .UtilityExtensions

A transliterator that is composed of two or more other transliterator objects linked together. For example, if one transliterator transliterates from script A to script B, and another transliterates from script B to script C, the two may be combined to form a new transliterator from A to C.

Composed transliterators may not behave as expected. For example, inverses may not combine to form the identity transliterator. See the class documentation for Transliterator for details.

Copyright © IBM Corporation 1999. All rights reserved.

Author
Alan Liu

Field Summary

Modifier and TypeField and Description
private int
private Transliterator[]
Inherited from com.ibm.icu.text.Transliterator:
DEBUGFORWARDID_DELIMID_SEPREVERSEVARIANT_SEP

Constructor Summary

AccessConstructor and Description
pack-priv
CompoundTransliterator(List<Transliterator> list)

Package private constructor for Transliterator from a vector of transliterators.

pack-priv
CompoundTransliterator(List<Transliterator> list, int numAnonymousRBTs)

pack-priv
CompoundTransliterator(String id, UnicodeFilter filter2, Transliterator[] trans2, int numAnonymousRBTs2)

Internal method for safeClone...

Method Summary

Modifier and TypeMethod and Description
private static void
_smartAppend(StringBuilder buf, char c)

Append c to buf, unless buf is empty or buf already ends in c.

public void
addSourceTargetSet(UnicodeSet filter, 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().
private void
computeMaximumContextLength()

Compute and set the length of the longest context required by this transliterator.

public int

Returns:

number of transliterators in this chain.
getCount
()

Returns the number of transliterators in this chain.

public Transliterator

Returns:

transliterator at the given index
getTransliterator
(int
index into chain, from 0 to getCount() - 1
index
)

Returns the transliterator at the given index in this chain.

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.
index
,
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.
private void
init(List<Transliterator>
a vector of transliterator objects to be adopted. It should NOT be empty. The list should be in declared order. That is, it should be in the FORWARD order; if direction is REVERSE then the list order will be reversed.
list
,
int
either FORWARD or REVERSE
direction
,
boolean
if true, then reconstruct the ID of reverse entries by calling getID() of component entries. Some constructors do not require this because they apply a facade ID anyway.
fixReverseID
)

Finish constructing a transliterator: only to be called by constructors.

public Transliterator
safeClone()

Temporary hack for registry problem.

public String

Returns:

the rule string
toRules
(boolean
if true then convert unprintable character to their hex escape representations, \\uxxxx or \\Uxxxxxxxx. Unprintable characters are those other than U+000A, U+0020..U+007E.
escapeUnprintable
)

Overrides com.ibm.icu.text.Transliterator.toRules.

Override Transliterator: Create a rule string that can be passed to createFromRules() to recreate this transliterator.
Inherited from com.ibm.icu.text.Transliterator:
baseToRulescreateFromRulesfilteredTransliteratefinishTransliterationgetAvailableIDsgetAvailableSourcesgetAvailableTargetsgetAvailableVariantsgetBasicInstancegetDisplayNamegetDisplayNamegetDisplayNamegetElementsgetFiltergetFilterAsUnicodeSetgetIDgetInstancegetInstancegetInversegetMaximumContextLengthgetSourceSetgetTargetSethandleGetSourceSetregisterAliasregisterAnyregisterClassregisterFactoryregisterInstanceregisterInstanceregisterSpecialInversesetFiltersetIDsetMaximumContextLengthtransformtransliteratetransliteratetransliteratetransliteratetransliteratetransliterateunregister

Field Detail

numAnonymousRBTsback to summary
private int numAnonymousRBTs
transback to summary
private Transliterator[] trans

Constructor Detail

CompoundTransliteratorback to summary
pack-priv CompoundTransliterator(List<Transliterator> list)

Package private constructor for Transliterator from a vector of transliterators. The caller is responsible for fixing up the ID.

CompoundTransliteratorback to summary
pack-priv CompoundTransliterator(List<Transliterator> list, int numAnonymousRBTs)
CompoundTransliteratorback to summary
pack-priv CompoundTransliterator(String id, UnicodeFilter filter2, Transliterator[] trans2, int numAnonymousRBTs2)

Internal method for safeClone...

Method Detail

_smartAppendback to summary
private static void _smartAppend(StringBuilder buf, char c)

Append c to buf, unless buf is empty or buf already ends in c.

addSourceTargetSetback to summary
public void addSourceTargetSet(UnicodeSet filter, 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
ICU Status
Internal ICU component.
computeMaximumContextLengthback to summary
private void computeMaximumContextLength()

Compute and set the length of the longest context required by this transliterator. This is preceding context.

getCountback to summary
public int getCount()

Returns the number of transliterators in this chain.

Returns:int

number of transliterators in this chain.

getTransliteratorback to summary
public Transliterator getTransliterator(int index)

Returns the transliterator at the given index in this chain.

Parameters
index:int

index into chain, from 0 to getCount() - 1

Returns:Transliterator

transliterator at the given index

handleTransliterateback to summary
protected void handleTransliterate(Replaceable text, Transliterator.Position index, 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

index: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
initback to summary
private void init(List<Transliterator> list, int direction, boolean fixReverseID)

Finish constructing a transliterator: only to be called by constructors. Before calling init(), set trans and filter to NULL.

Parameters
list:List<Transliterator>

a vector of transliterator objects to be adopted. It should NOT be empty. The list should be in declared order. That is, it should be in the FORWARD order; if direction is REVERSE then the list order will be reversed.

direction:int

either FORWARD or REVERSE

fixReverseID:boolean

if true, then reconstruct the ID of reverse entries by calling getID() of component entries. Some constructors do not require this because they apply a facade ID anyway.

safeCloneback to summary
public Transliterator safeClone()

Temporary hack for registry problem. Needs to be replaced by better architecture.

toRulesback to summary
public String toRules(boolean escapeUnprintable)

Overrides com.ibm.icu.text.Transliterator.toRules.

Override Transliterator: Create a rule string that can be passed to createFromRules() to recreate this transliterator.

Parameters
escapeUnprintable:boolean

if true then convert unprintable character to their hex escape representations, \\uxxxx or \\Uxxxxxxxx. Unprintable characters are those other than U+000A, U+0020..U+007E.

Returns:String

the rule string

Annotations
@Override