Package com.ibm.icu.text
Class TransliteratorRegistry
java.lang.Object
com.ibm.icu.text.TransliteratorRegistry
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static class
(package private) static class
private static class
An internal class that adapts an enumeration over CaseInsensitiveStrings to an enumeration over Strings.(package private) static class
(package private) static class
(package private) static class
A Spec is a string specifying either a source or a target. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final String
private final Set
<CaseInsensitiveString> Vector of public full IDs (CaseInsensitiveString objects).private static final boolean
private static final char
private static final String
private Map
<CaseInsensitiveString, Object[]> Dynamic registry mapping full IDs to Entry objects.DAG of visible IDs by spec. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate Object[]
Convenience method.private Object[]
Top-level find method.private Object[]
findInBundle
(TransliteratorRegistry.Spec specToOpen, TransliteratorRegistry.Spec specToFind, String variant, int direction) Attempt to find an entry in a single resource bundle.private Object[]
findInDynamicStore
(TransliteratorRegistry.Spec src, TransliteratorRegistry.Spec trg, String variant) Attempt to find a source-target/variant in the dynamic registry store.private Object[]
findInStaticStore
(TransliteratorRegistry.Spec src, TransliteratorRegistry.Spec trg, String variant) Attempt to find a source-target/variant in the static locale resource store.get
(String ID, StringBuffer aliasReturn) Given a simple ID (forward direction, no inline filter, not compound) attempt to instantiate it from the registry.Returns an enumeration over the programmatic names of visible registered transliterators.Returns an enumeration over all visible source names.getAvailableTargets
(String source) Returns an enumeration over visible target names for the given source.getAvailableVariants
(String source, String target) Returns an enumeration over visible variant names for the given source and target.private Transliterator
instantiateEntry
(String ID, Object[] entryWrapper, StringBuffer aliasReturn) Given an Entry object, instantiate it.void
put
(String ID, Transliterator.Factory factory, boolean visible) Register an ID and a factory function pointer.void
put
(String ID, Transliterator trans, boolean visible) Register an ID and a Transliterator object.void
put
(String ID, Class<? extends Transliterator> transliteratorSubclass, boolean visible) Register a class.void
Register an ID and an alias ID.void
Register an ID and a resource name.private void
registerEntry
(String ID, Object entry, boolean visible) Convenience method.private void
registerEntry
(String source, String target, String variant, Object entry, boolean visible) Convenience method.private void
registerEntry
(String ID, String source, String target, String variant, Object entry, boolean visible) Register an entry object (adopted) with the given ID, source, target, and variant strings.private void
registerSTV
(String source, String target, String variant) Register a source-target/variant in the specDAG.void
Unregister an ID.private void
Remove a source-target/variant from the specDAG.
-
Field Details
-
LOCALE_SEP
private static final char LOCALE_SEP- See Also:
-
NO_VARIANT
- See Also:
-
ANY
- See Also:
-
registry
Dynamic registry mapping full IDs to Entry objects. This contains both public and internal entities. The visibility is controlled by whether an entry is listed in availableIDs and specDAG or not. Keys are CaseInsensitiveString objects. Values are objects of class Class (subclass of Transliterator), RuleBasedTransliterator.Data, Transliterator.Factory, or one of the entry classes defined here (AliasEntry or ResourceEntry). -
specDAG
DAG of visible IDs by spec. Hashtable: source => (Hashtable: target => (Vector: variant)) The Vector of variants is never empty. For a source-target with no variant, the special variant NO_VARIANT (the empty string) is stored in slot zero of the UVector. Keys are CaseInsensitiveString objects. Values are Hashtable of (CaseInsensitiveString -> Vector of CaseInsensitiveString) -
availableIDs
Vector of public full IDs (CaseInsensitiveString objects). -
DEBUG
private static final boolean DEBUG- See Also:
-
-
Constructor Details
-
TransliteratorRegistry
public TransliteratorRegistry()
-
-
Method Details
-
get
Given a simple ID (forward direction, no inline filter, not compound) attempt to instantiate it from the registry. Return 0 on failure. Return a non-empty aliasReturn value if the ID points to an alias. We cannot instantiate it ourselves because the alias may contain filters or compounds, which we do not understand. Caller should make aliasReturn empty before calling. -
put
Register a class. This adds an entry to the dynamic store, or replaces an existing entry. Any entry in the underlying static locale resource store is masked. -
put
Register an ID and a factory function pointer. This adds an entry to the dynamic store, or replaces an existing entry. Any entry in the underlying static locale resource store is masked. -
put
Register an ID and a resource name. This adds an entry to the dynamic store, or replaces an existing entry. Any entry in the underlying static locale resource store is masked. -
put
Register an ID and an alias ID. This adds an entry to the dynamic store, or replaces an existing entry. Any entry in the underlying static locale resource store is masked. -
put
Register an ID and a Transliterator object. This adds an entry to the dynamic store, or replaces an existing entry. Any entry in the underlying static locale resource store is masked. -
remove
Unregister an ID. This removes an entry from the dynamic store if there is one. The static locale resource store is unaffected. -
getAvailableIDs
Returns an enumeration over the programmatic names of visible registered transliterators.- Returns:
- An
Enumeration
overString
objects
-
getAvailableSources
Returns an enumeration over all visible source names.- Returns:
- An
Enumeration
overString
objects
-
getAvailableTargets
Returns an enumeration over visible target names for the given source.- Returns:
- An
Enumeration
overString
objects
-
getAvailableVariants
Returns an enumeration over visible variant names for the given source and target.- Returns:
- An
Enumeration
overString
objects
-
registerEntry
private void registerEntry(String source, String target, String variant, Object entry, boolean visible) Convenience method. Calls 6-arg registerEntry(). -
registerEntry
Convenience method. Calls 6-arg registerEntry(). -
registerEntry
private void registerEntry(String ID, String source, String target, String variant, Object entry, boolean visible) Register an entry object (adopted) with the given ID, source, target, and variant strings. -
registerSTV
Register a source-target/variant in the specDAG. Variant may be empty, but source and target must not be. If variant is empty then the special variant NO_VARIANT is stored in slot zero of the UVector of variants. -
removeSTV
Remove a source-target/variant from the specDAG. -
findInDynamicStore
private Object[] findInDynamicStore(TransliteratorRegistry.Spec src, TransliteratorRegistry.Spec trg, String variant) Attempt to find a source-target/variant in the dynamic registry store. Return 0 on failure. -
findInStaticStore
private Object[] findInStaticStore(TransliteratorRegistry.Spec src, TransliteratorRegistry.Spec trg, String variant) Attempt to find a source-target/variant in the static locale resource store. Do not perform fallback. Return 0 on failure. On success, create a new entry object, register it in the dynamic store, and return a pointer to it, but do not make it public -- just because someone requested something, we do not expand the available ID list (or spec DAG). -
findInBundle
private Object[] findInBundle(TransliteratorRegistry.Spec specToOpen, TransliteratorRegistry.Spec specToFind, String variant, int direction) Attempt to find an entry in a single resource bundle. This is a one-sided lookup. findInStaticStore() performs up to two such lookups, one for the source, and one for the target. Do not perform fallback. Return 0 on failure. On success, create a new Entry object, populate it, and return it. The caller owns the returned object. -
find
Convenience method. Calls 3-arg find(). -
find
Top-level find method. Attempt to find a source-target/variant in either the dynamic or the static (locale resource) store. Perform fallback. Lookup sequence for ss_SS_SSS-tt_TT_TTT/v: ss_SS_SSS-tt_TT_TTT/v -- in hashtable ss_SS_SSS-tt_TT_TTT/v -- in ss_SS_SSS (no fallback) repeat with t = tt_TT_TTT, tt_TT, tt, and tscript ss_SS_SSS-t/* ss_SS-t/* ss-t/* sscript-t/* Here * matches the first variant listed. Caller does NOT own returned object. Return 0 on failure. -
instantiateEntry
Given an Entry object, instantiate it. Caller owns result. Return 0 on failure. Return a non-empty aliasReturn value if the ID points to an alias. We cannot instantiate it ourselves because the alias may contain filters or compounds, which we do not understand. Caller should make aliasReturn empty before calling. The entry object is assumed to reside in the dynamic store. It may be modified.
-