Class RuleBasedTransliterator
java.lang.Object
com.ibm.icu.text.Transliterator
com.ibm.icu.text.RuleBasedTransliterator
- All Implemented Interfaces:
StringTransform, Transform<String,String>
Deprecated.
This API is ICU internal only.
RuleBasedTransliterator is a transliterator built from a set of rules as defined for
Transliterator.createFromRules(String, String, int). See the class Transliterator
documentation for the rule syntax.- Author:
- Alan Liu
- Status:
- Internal. This API is ICU internal only.
-
Nested Class Summary
Nested classes/interfaces inherited from class Transliterator
Transliterator.Factory, Transliterator.PositionModifier and TypeClassDescriptionstatic interfaceThe factory interface for transliterators.static classPosition structure for incremental transliteration. -
Field Summary
Fields inherited from class Transliterator
FORWARD, REVERSEModifier and TypeFieldDescriptionstatic final intDirection constant indicating the forward direction in a transliterator, e.g., the forward rules of a rule-based Transliterator.static final intDirection constant indicating the reverse direction in a transliterator, e.g., the reverse rules of a rule-based Transliterator. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddSourceTargetSet(UnicodeSet filter, UnicodeSet sourceSet, UnicodeSet targetSet) Deprecated.This API is ICU internal only.protected voidhandleTransliterate(Replaceable text, Transliterator.Position index, boolean incremental) Deprecated.This API is ICU internal only.Deprecated.This API is ICU internal only.toRules(boolean escapeUnprintable) Deprecated.This API is ICU internal only.Methods inherited from class Transliterator
baseToRules, createFromRules, filteredTransliterate, finishTransliteration, getAvailableIDs, getAvailableSources, getAvailableTargets, getAvailableVariants, getDisplayName, getDisplayName, getDisplayName, getElements, getFilter, getFilterAsUnicodeSet, getID, getInstance, getInstance, getInverse, getMaximumContextLength, getSourceSet, getTargetSet, handleGetSourceSet, registerAlias, registerAny, registerClass, registerFactory, registerInstance, setFilter, setID, setMaximumContextLength, transform, transliterate, transliterate, transliterate, transliterate, transliterate, transliterate, unregisterModifier and TypeMethodDescriptionprotected final StringbaseToRules(boolean escapeUnprintable) Returns a rule string for this transliterator.static final TransliteratorcreateFromRules(String ID, String rules, int dir) Returns aTransliteratorobject constructed from the given rule string.voidfilteredTransliterate(Replaceable text, Transliterator.Position index, boolean incremental) Transliterate a substring of text, as specified by index, taking filters into account.final voidfinishTransliteration(Replaceable text, Transliterator.Position index) Finishes any pending transliterations that were waiting for more characters.static final Enumeration<String> Returns an enumeration over the programmatic names of registeredTransliteratorobjects.static final Enumeration<String> Returns an enumeration over the source names of registered transliterators.static final Enumeration<String> getAvailableTargets(String source) Returns an enumeration over the target names of registered transliterators having a given source name.static final Enumeration<String> getAvailableVariants(String source, String target) Returns an enumeration over the variant names of registered transliterators having a given source name and target name.static final StringgetDisplayName(String ID) Returns a name for this transliterator that is appropriate for display to the user in the defaultDISPLAYlocale.static StringgetDisplayName(String id, ULocale inLocale) Returns a name for this transliterator that is appropriate for display to the user in the given locale.static StringgetDisplayName(String id, Locale inLocale) Returns a name for this transliterator that is appropriate for display to the user in the given locale.Return the elements that make up this transliterator.final UnicodeFilterReturns the filter used by this transliterator, ornullif this transliterator uses no filter.getFilterAsUnicodeSet(UnicodeSet externalFilter) Deprecated.This API is ICU internal only.final StringgetID()Returns a programmatic identifier for this transliterator.static final TransliteratorgetInstance(String ID) Returns aTransliteratorobject given its ID.static TransliteratorgetInstance(String ID, int dir) Returns aTransliteratorobject given its ID.final TransliteratorReturns this transliterator's inverse.final intReturns the length of the longest context required by this transliterator.final UnicodeSetReturns the set of all characters that may be modified in the input text by this Transliterator.Returns the set of all characters that may be generated as replacement text by this transliterator.protected UnicodeSetFramework method that returns the set of all characters that may be modified in the input text by this Transliterator, ignoring the effect of this object's filter.static voidregisterAlias(String aliasID, String realID) Register an ID as an alias of another ID.static voidDeprecated.This API is ICU internal only.static voidregisterClass(String ID, Class<? extends Transliterator> transClass, String displayName) Registers a subclass ofTransliteratorwith the system.static voidregisterFactory(String ID, Transliterator.Factory factory) Register a factory object with the given ID.static voidregisterInstance(Transliterator trans) Register a Transliterator object with the given ID.voidsetFilter(UnicodeFilter filter) Changes the filter used by this transliterator.protected final voidSet the programmatic identifier for this transliterator.protected voidsetMaximumContextLength(int a) Method for subclasses to use to set the maximum context length.Implements StringTransform via this method.final voidtransliterate(Replaceable text) Transliterates an entire string in place.final inttransliterate(Replaceable text, int start, int limit) Transliterates a segment of a string, with optional filtering.final voidtransliterate(Replaceable text, Transliterator.Position index) Transliterates the portion of the text buffer that can be transliterated unambiguosly.final voidtransliterate(Replaceable text, Transliterator.Position index, int insertion) Transliterates the portion of the text buffer that can be transliterated unambiguosly after a new character has been inserted, typically as a result of a keyboard event.final voidtransliterate(Replaceable text, Transliterator.Position index, String insertion) Transliterates the portion of the text buffer that can be transliterated unambiguosly after new text has been inserted, typically as a result of a keyboard event.final Stringtransliterate(String text) Transliterate an entire string and returns the result.static voidunregister(String ID) Unregisters a transliterator or class.
-
Method Details
-
handleTransliterate
@Deprecated protected void handleTransliterate(Replaceable text, Transliterator.Position index, boolean incremental) Deprecated.This API is ICU internal only.- Specified by:
handleTransliteratein classTransliterator- Parameters:
text- the buffer holding transliterated and untransliterated textindex- the indices indicating the start, limit, context start, and context limit of the text.incremental- if true, assume more text may be inserted atpos.limitand act accordingly. Otherwise, transliterate all text betweenpos.startandpos.limitand movepos.startup topos.limit.- See Also:
- Status:
- Internal. This API is ICU internal only.
-
toRules
Deprecated.This API is ICU internal only.Return a representation of this transliterator as source rules. These rules will produce an equivalent transliterator if used to construct a new transliterator.- Overrides:
toRulesin classTransliterator- Parameters:
escapeUnprintable- 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:
- rules string
- Status:
- Internal. This API is ICU internal only.
-
addSourceTargetSet
@Deprecated public void addSourceTargetSet(UnicodeSet filter, UnicodeSet sourceSet, UnicodeSet targetSet) Deprecated.This API is ICU internal only.Description copied from class:TransliteratorReturns 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:
addSourceTargetSetin classTransliterator- Parameters:
targetSet- TODO- See Also:
- Status:
- Internal. This API is ICU internal only.
-
safeClone
Deprecated.This API is ICU internal only.Temporary hack for registry problem. Needs to be replaced by better architecture.- Status:
- Internal. This API is ICU internal only.
-