An AnyTransliterator partitions text into runs of the same script, together with adjacent COMMON or INHERITED characters. After determining the script of each run, it transliterates from that script to the given target/variant. It does so by instantiating a transliterator from the source script to the target/variant. If a run consists only of the target script, COMMON, or INHERITED characters, then the run is not changed.
At startup, all possible AnyTransliterators are registered with the system, as determined by examining the registered script transliterators.
| Modifier and Type | Class and Description |
|---|---|
| private static class | AnyTransliterator.ScriptRunIterator
Returns a series of ranges corresponding to scripts. |
| private static class | AnyTransliterator.WidthFix
Lazily initialize a special Transliterator for handling width characters. |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv static final String | |
| private ConcurrentHashMap | cache
Cache mapping UScriptCode values to Transliterator*. |
| pack-priv static final String | |
| pack-priv static final String | |
| private String | target
The target or target/variant string. |
| pack-priv static final char | |
| private int | targetScript
The target script code. |
| pack-priv static final char |
| Access | Constructor and Description |
|---|---|
| private | AnyTransliterator(String
the ID of the form S-T or S-T/V, where T is theTarget
and V is theVariant. Must not be empty. id, String the target name. Must not be empty, and must
name a script corresponding to theTargetScript. theTarget, String the variant name, or the empty string if
there is no variant theVariant, int the script code corresponding to
theTarget. theTargetScript)Private constructor |
| public | AnyTransliterator(String
the ID of the form S-T or S-T/V, where T is theTarget
and V is theVariant. Must not be empty. id, UnicodeFilter The Unicode filter. filter, String the target name. target2, int the script code corresponding to theTarget. targetScript2, Transliterator Not used. This parameter is deprecated. widthFix2, ConcurrentHashMap<Integer, Transliterator> The Map object for cache. cache2)
|
| Modifier and Type | Method and Description |
|---|---|
| public void | addSourceTargetSet(UnicodeSet inputFilter, UnicodeSet sourceSet, UnicodeSet
TODO targetSet)Overrides com. |
| private Transliterator | getTransliterator(int source)
Returns a transliterator from the given source to our target or target/variant. |
| protected void | handleTransliterate(Replaceable
the buffer holding transliterated and
untransliterated text text, Transliterator.the indices indicating the start, limit, context
start, and context limit of the text. pos,if true, assume more text may be inserted at
isIncremental)pos.limit and act accordingly. Otherwise,
transliterate all text between pos.start and
pos.limit and move pos.start up to
pos.limit.Implements abstract com. Transliterator#handleTransliterate.
|
| private boolean | |
| pack-priv static void | |
| public Transliterator | |
| private static int | scriptNameToCode(String name)
Return the script code for a given name, or UScript.INVALID_CODE if not found. |
| ANY | back to summary |
|---|---|
| pack-priv static final String ANY | |
| cache | back to summary |
|---|---|
| private ConcurrentHashMap<Integer, Transliterator> cache Cache mapping UScriptCode values to Transliterator*. | |
| LATIN_PIVOT | back to summary |
|---|---|
| pack-priv static final String LATIN_PIVOT | |
| NULL_ID | back to summary |
|---|---|
| pack-priv static final String NULL_ID | |
| target | back to summary |
|---|---|
| private String target The target or target/variant string. | |
| TARGET_SEP | back to summary |
|---|---|
| pack-priv static final char TARGET_SEP | |
| targetScript | back to summary |
|---|---|
| private int targetScript The target script code. Never USCRIPT_INVALID_CODE. | |
| VARIANT_SEP | back to summary |
|---|---|
| pack-priv static final char VARIANT_SEP | |
| AnyTransliterator | back to summary |
|---|---|
| private AnyTransliterator(String id, String theTarget, String theVariant, int theTargetScript) Private constructor
| |
| AnyTransliterator | back to summary |
|---|---|
public AnyTransliterator(String id, UnicodeFilter filter, String target2, int targetScript2, Transliterator widthFix2, ConcurrentHashMap<Integer, Transliterator> cache2)
| |
| addSourceTargetSet | back to summary |
|---|---|
| public void addSourceTargetSet(UnicodeSet inputFilter, UnicodeSet sourceSet, UnicodeSet targetSet) Overrides com. Doc from com. 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.
| |
| getTransliterator | back to summary |
|---|---|
| private Transliterator getTransliterator(int source) Returns a transliterator from the given source to our target or target/variant. Returns NULL if the source is the same as our target script, or if the source is USCRIPT_INVALID_CODE. Caches the result and returns the same transliterator the next time. The caller does NOT own the result and must not delete it. | |
| handleTransliterate | back to summary |
|---|---|
| protected void handleTransliterate(Replaceable text, Transliterator. Implements abstract com. Implements
| |
| isWide | back to summary |
|---|---|
| private boolean isWide(int script) | |
| register | back to summary |
|---|---|
| pack-priv static void register() Registers standard transliterators with the system. Called by Transliterator during initialization. Scan all current targets and register those that are scripts T as Any-T/V. | |
| safeClone | back to summary |
|---|---|
| public Transliterator safeClone() Temporary hack for registry problem. Needs to be replaced by better architecture. | |
| scriptNameToCode | back to summary |
|---|---|
| private static int scriptNameToCode(String name) Return the script code for a given name, or UScript.INVALID_CODE if not found. | |
| Modifier and Type | Field and Description |
|---|---|
| public int | limit
The end of the run, exclusive, valid after next() returns. |
| public int | scriptCode
The code of the current run, valid after next() returns. |
| public int | start
The start of the run, inclusive, valid after next() returns. |
| private Replaceable | |
| private int | |
| private int |
| Access | Constructor and Description |
|---|---|
| public | ScriptRunIterator(Replaceable text, int start, int limit)
Constructs a run iterator over the given text from start (inclusive) to limit (exclusive). |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public boolean |
| limit | back to summary |
|---|---|
| public int limit The end of the run, exclusive, valid after next() returns. | |
| scriptCode | back to summary |
|---|---|
| public int scriptCode The code of the current run, valid after next() returns. May be UScript.INVALID_CODE if and only if the entire text is COMMON/INHERITED. | |
| start | back to summary |
|---|---|
| public int start The start of the run, inclusive, valid after next() returns. | |
| text | back to summary |
|---|---|
| private Replaceable text | |
| textLimit | back to summary |
|---|---|
| private int textLimit | |
| textStart | back to summary |
|---|---|
| private int textStart | |
| ScriptRunIterator | back to summary |
|---|---|
| public ScriptRunIterator(Replaceable text, int start, int limit) Constructs a run iterator over the given text from start (inclusive) to limit (exclusive). | |
| adjustLimit | back to summary |
|---|---|
| public void adjustLimit(int delta) Adjusts internal indices for a change in the limit index of the given delta. A positive delta means the limit has increased. | |
| next | back to summary |
|---|---|
| public boolean next() Returns true if there are any more runs. true is always returned at least once. Upon return, the caller should examine scriptCode, start, and limit. | |
| Modifier and Type | Field and Description |
|---|---|
| private static final String | |
| pack-priv static final Transliterator |
| Access | Constructor and Description |
|---|---|
| private |
| ID | back to summary |
|---|---|
| private static final String ID | |
| INSTANCE | back to summary |
|---|---|
| pack-priv static final Transliterator INSTANCE | |
| WidthFix | back to summary |
|---|---|
| private WidthFix() | |