Class TransliteratorRegistry


  • class TransliteratorRegistry
    extends java.lang.Object
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private java.lang.Object[] find​(java.lang.String ID)
      Convenience method.
      private java.lang.Object[] find​(java.lang.String source, java.lang.String target, java.lang.String variant)
      Top-level find method.
      private java.lang.Object[] findInBundle​(TransliteratorRegistry.Spec specToOpen, TransliteratorRegistry.Spec specToFind, java.lang.String variant, int direction)
      Attempt to find an entry in a single resource bundle.
      private java.lang.Object[] findInDynamicStore​(TransliteratorRegistry.Spec src, TransliteratorRegistry.Spec trg, java.lang.String variant)
      Attempt to find a source-target/variant in the dynamic registry store.
      private java.lang.Object[] findInStaticStore​(TransliteratorRegistry.Spec src, TransliteratorRegistry.Spec trg, java.lang.String variant)
      Attempt to find a source-target/variant in the static locale resource store.
      Transliterator get​(java.lang.String ID, java.lang.StringBuffer aliasReturn)
      Given a simple ID (forward direction, no inline filter, not compound) attempt to instantiate it from the registry.
      java.util.Enumeration<java.lang.String> getAvailableIDs()
      Returns an enumeration over the programmatic names of visible registered transliterators.
      java.util.Enumeration<java.lang.String> getAvailableSources()
      Returns an enumeration over all visible source names.
      java.util.Enumeration<java.lang.String> getAvailableTargets​(java.lang.String source)
      Returns an enumeration over visible target names for the given source.
      java.util.Enumeration<java.lang.String> getAvailableVariants​(java.lang.String source, java.lang.String target)
      Returns an enumeration over visible variant names for the given source and target.
      private Transliterator instantiateEntry​(java.lang.String ID, java.lang.Object[] entryWrapper, java.lang.StringBuffer aliasReturn)
      Given an Entry object, instantiate it.
      void put​(java.lang.String ID, Transliterator.Factory factory, boolean visible)
      Register an ID and a factory function pointer.
      void put​(java.lang.String ID, Transliterator trans, boolean visible)
      Register an ID and a Transliterator object.
      void put​(java.lang.String ID, java.lang.Class<? extends Transliterator> transliteratorSubclass, boolean visible)
      Register a class.
      void put​(java.lang.String ID, java.lang.String alias, boolean visible)
      Register an ID and an alias ID.
      void put​(java.lang.String ID, java.lang.String resourceName, int dir, boolean visible)
      Register an ID and a resource name.
      private void registerEntry​(java.lang.String ID, java.lang.Object entry, boolean visible)
      Convenience method.
      private void registerEntry​(java.lang.String source, java.lang.String target, java.lang.String variant, java.lang.Object entry, boolean visible)
      Convenience method.
      private void registerEntry​(java.lang.String ID, java.lang.String source, java.lang.String target, java.lang.String variant, java.lang.Object entry, boolean visible)
      Register an entry object (adopted) with the given ID, source, target, and variant strings.
      private void registerSTV​(java.lang.String source, java.lang.String target, java.lang.String variant)
      Register a source-target/variant in the specDAG.
      void remove​(java.lang.String ID)
      Unregister an ID.
      private void removeSTV​(java.lang.String source, java.lang.String target, java.lang.String variant)
      Remove a source-target/variant from the specDAG.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • registry

        private java.util.Map<CaseInsensitiveString,​java.lang.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

        private java.util.Map<CaseInsensitiveString,​java.util.Map<CaseInsensitiveString,​java.util.List<CaseInsensitiveString>>> 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 java.util.Set<CaseInsensitiveString> availableIDs
        Vector of public full IDs (CaseInsensitiveString objects).
    • Constructor Detail

      • TransliteratorRegistry

        public TransliteratorRegistry()
    • Method Detail

      • get

        public Transliterator get​(java.lang.String ID,
                                  java.lang.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​(java.lang.String ID,
                        java.lang.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​(java.lang.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​(java.lang.String ID,
                        java.lang.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​(java.lang.String ID,
                        java.lang.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​(java.lang.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​(java.lang.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 java.util.Enumeration<java.lang.String> getAvailableIDs()
        Returns an enumeration over the programmatic names of visible registered transliterators.
        Returns:
        An Enumeration over String objects
      • getAvailableSources

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

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

        public java.util.Enumeration<java.lang.String> getAvailableVariants​(java.lang.String source,
                                                                            java.lang.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​(java.lang.String source,
                                   java.lang.String target,
                                   java.lang.String variant,
                                   java.lang.Object entry,
                                   boolean visible)
        Convenience method. Calls 6-arg registerEntry().
      • registerEntry

        private void registerEntry​(java.lang.String ID,
                                   java.lang.Object entry,
                                   boolean visible)
        Convenience method. Calls 6-arg registerEntry().
      • registerEntry

        private void registerEntry​(java.lang.String ID,
                                   java.lang.String source,
                                   java.lang.String target,
                                   java.lang.String variant,
                                   java.lang.Object entry,
                                   boolean visible)
        Register an entry object (adopted) with the given ID, source, target, and variant strings.
      • registerSTV

        private void registerSTV​(java.lang.String source,
                                 java.lang.String target,
                                 java.lang.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​(java.lang.String source,
                               java.lang.String target,
                               java.lang.String variant)
        Remove a source-target/variant from the specDAG.
      • findInStaticStore

        private java.lang.Object[] findInStaticStore​(TransliteratorRegistry.Spec src,
                                                     TransliteratorRegistry.Spec trg,
                                                     java.lang.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 java.lang.Object[] findInBundle​(TransliteratorRegistry.Spec specToOpen,
                                                TransliteratorRegistry.Spec specToFind,
                                                java.lang.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 java.lang.Object[] find​(java.lang.String ID)
        Convenience method. Calls 3-arg find().
      • find

        private java.lang.Object[] find​(java.lang.String source,
                                        java.lang.String target,
                                        java.lang.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​(java.lang.String ID,
                                                java.lang.Object[] entryWrapper,
                                                java.lang.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.