Class NameConverters


  • @PublicAPI
    public class NameConverters
    extends Object
    Maintains the list of custom and built-in name-to-structures converters.

    It can be used to extend the behaviour of name-to-structure conversion by adding a NameConverter instance that performs custom conversions, for instance by doing database lookups or using a specific name-to-structure algorithm.

    Since:
    Marvin 5.3
    • Method Detail

      • add

        public static void add​(NameConverter converter,
                               int priority)
        Add a name to structure converter.

        When several converters are present, they are run one by one in decreasing order of priority until one converter returns a structure, or all converters have been run.

        The priority can also be used to specify if custom converters have priority over built-in ones, given the following priorities for built-in converters:

        • -100: user dictionary (custom-names.smi)
        • -200: built-in traditional dictionary
        • -300: built-in systematic name converter

        For instance, a custom converter with a positive priority will take precedence over built-in ones. A custom converter with a priority below -300 will only be run when all built-in conversions have failed to recognize the name.

        Parameters:
        converter - the converter to be added.
        priority - the priority of the converter.
      • addThreadLocal

        public static void addThreadLocal​(NameConverter converter,
                                          int priority)
        Add a thread-local name to structure converter.

        This converter will only be used by name to structure conversions running in the same thread as the thread calling this method. This allows to customize some name to structure conversion without affecting other name to structure conversions that would be running simultaneously in other threads.

        When several converters are present, they are run one by one in decreasing order of priority until one converter returns a structure, or all converters have been run.

        The priority can also be used to specify if custom converters have priority over built-in ones, given the following priorities for built-in converters:

        • -100: user dictionary (custom-names.smi)
        • -200: built-in traditional dictionary
        • -300: built-in systematic name converter

        For instance, a custom converter with a positive priority will take precedence over built-in ones. A custom converter with a priority below -300 will only be run when all built-in conversions have failed to recognize the name.

        Parameters:
        converter - the converter to be added.
        priority - the priority of the converter.
      • remove

        public static boolean remove​(NameConverter converter)
        Remove the converter from the converter list.

        The return value can be used to check that the converter was indeed present before the removal.

        Parameters:
        converter - the converter to be removed
        Returns:
        true if the converter was found and removed, false if it was not found.