chemaxon.naming
Class NameConverters

java.lang.Object
  extended by chemaxon.naming.NameConverters

public class NameConverters
extends java.lang.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
Author:
Daniel Bonniot

Method Summary
static void add(NameConverter converter, int priority)
          Add a name to structure converter.
static void addThreadLocal(NameConverter converter, int priority)
          Add a thread-local name to structure converter.
static boolean remove(NameConverter converter)
          Remove the converter from the converter list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

add

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

Parameters:
converter - the converter to be added.
priority - the priority of the 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.

This 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.


addThreadLocal

public static void addThreadLocal(NameConverter converter,
                                  int priority)
Add a thread-local name to structure converter. This convert 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.

Parameters:
converter - the converter to be added.
priority - the priority of the 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.

This 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.


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.