Class TransliteratorRegistry

java.lang.Object
com.ibm.icu.text.TransliteratorRegistry

class TransliteratorRegistry extends Object
  • Field Details

    • LOCALE_SEP

      private static final char LOCALE_SEP
      See Also:
    • NO_VARIANT

      private static final String NO_VARIANT
      See Also:
    • ANY

      private static final String ANY
      See Also:
    • registry

      private Map<CaseInsensitiveString,Object[]> 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

      private final Set<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

      public Transliterator get(String ID, StringBuffer aliasReturn)
      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

      public void put(String ID, Class<? extends Transliterator> transliteratorSubclass, boolean visible)
      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

      public void put(String ID, Transliterator.Factory factory, boolean visible)
      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

      public void put(String ID, String resourceName, int dir, boolean visible)
      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

      public void put(String ID, String alias, boolean visible)
      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

      public void put(String ID, Transliterator trans, boolean visible)
      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

      public void remove(String ID)
      Unregister an ID. This removes an entry from the dynamic store if there is one. The static locale resource store is unaffected.
    • getAvailableIDs

      public Enumeration<String> getAvailableIDs()
      Returns an enumeration over the programmatic names of visible registered transliterators.
      Returns:
      An Enumeration over String objects
    • getAvailableSources

      public Enumeration<String> getAvailableSources()
      Returns an enumeration over all visible source names.
      Returns:
      An Enumeration over String objects
    • getAvailableTargets

      public Enumeration<String> getAvailableTargets(String source)
      Returns an enumeration over visible target names for the given source.
      Returns:
      An Enumeration over String objects
    • getAvailableVariants

      public Enumeration<String> getAvailableVariants(String source, String target)
      Returns an enumeration over visible variant names for the given source and target.
      Returns:
      An Enumeration over String objects
    • registerEntry

      private void registerEntry(String source, String target, String variant, Object entry, boolean visible)
      Convenience method. Calls 6-arg registerEntry().
    • registerEntry

      private void registerEntry(String ID, Object entry, boolean visible)
      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

      private void registerSTV(String source, String target, String variant)
      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

      private void removeSTV(String source, String target, String variant)
      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

      private Object[] find(String ID)
      Convenience method. Calls 3-arg find().
    • find

      private Object[] find(String source, String target, String variant)
      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

      private Transliterator instantiateEntry(String ID, Object[] entryWrapper, StringBuffer aliasReturn)
      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.